diff --git a/home/editors/lsp.nix b/home/editors/lsp.nix index 87733b2..8518592 100644 --- a/home/editors/lsp.nix +++ b/home/editors/lsp.nix @@ -19,6 +19,13 @@ # linters & formatters nodePackages.eslint + # TODO uses custom script until json support is fixed + (pkgs.writeScriptBin "nix-linter" '' + echo '[' + ${nix-linter}/bin/nix-linter --json-stream "$1" | sed '$!s/$/,/' + echo ']' + '') + nixfmt # nodePackages.stylelint nodePackages.prettier ]; diff --git a/home/editors/neovim/lsp/lsp.lua b/home/editors/neovim/lsp/lsp.lua index 7f0ec06..6f7c2f8 100644 --- a/home/editors/neovim/lsp/lsp.lua +++ b/home/editors/neovim/lsp/lsp.lua @@ -61,6 +61,7 @@ config.diagnosticls.setup{ "json", "yaml", "markdown", + "nix", "html", "css" }, @@ -117,6 +118,19 @@ config.diagnosticls.setup{ warning = "warning", }, }, + ["nix-linter"] = { + -- TODO uses custom script until json support is fixed + command = "nix-linter", + sourceName = "nix-linter", + debounce = 50, + parseJson = { + line = "pos.spanBegin.sourceLine", + column = "pos.spanBegin.sourceColumn", + endLine = "pos.spanEnd.sourceLine", + endColumn = "pos.spanEnd.sourceColumn", + message = "${description}", + }, + }, }, filetypes = { javascript = {"eslint"}, @@ -126,6 +140,7 @@ config.diagnosticls.setup{ ["typescript.jsx"] = {"eslint"}, typescriptreact = {"eslint"}, css = {"stylelint"}, + nix = {"nix-linter"}, }, formatters = { eslint = { @@ -159,6 +174,9 @@ config.diagnosticls.setup{ }, rootPatterns = {".prettierrc.json", ".git"}, }, + nixfmt = { + command = "nixfmt", + }, }, formatFiletypes = { javascript = {"eslint"},