diff --git a/docs/release-notes/rl-0.5.adoc b/docs/release-notes/rl-0.5.adoc index 3cef9ed..f6416fb 100644 --- a/docs/release-notes/rl-0.5.adoc +++ b/docs/release-notes/rl-0.5.adoc @@ -36,4 +36,8 @@ https://github.com/notashelf[notashelf]: * Fixed mismatching zig language description +* Added support for `statix` and `deadnix` through <> + * Added lsp_lines plugin for showing diagnostic messages + +* Added a configuration option for choosing the leader key diff --git a/modules/languages/nix.nix b/modules/languages/nix.nix index 4a1c892..26f9285 100644 --- a/modules/languages/nix.nix +++ b/modules/languages/nix.nix @@ -82,6 +82,32 @@ with builtins; let # Never need to use null-ls for nixpkgs-fmt }; }; + + defaultDiagnostics = ["statix" "deadnix"]; + diagnostics = { + statix = { + package = pkgs.statix; + nullConfig = pkg: '' + table.insert( + ls_sources, + null_ls.builtins.diagnostics.statix.with({ + command = "${pkg}/bin/statix", + }) + ) + ''; + }; + deadnix = { + package = pkgs.deadnix; + nullConfig = pkg: '' + table.insert( + ls_sources, + null_ls.builtins.diagnostics.deadnix.with({ + command = "${pkg}/bin/deadnix", + }) + ) + ''; + }; + }; in { options.vim.languages.nix = { enable = mkEnableOption "Nix language support"; @@ -124,6 +150,19 @@ in { default = formats.${cfg.format.type}.package; }; }; + + extraDiagnostics = { + enable = mkOption { + description = "Enable extra Nix diagnostics"; + type = types.bool; + default = config.vim.languages.enableExtraDiagnostics; + }; + types = lib.nvim.types.diagnostics { + langDesc = "Nix"; + inherit diagnostics; + inherit defaultDiagnostics; + }; + }; }; config = mkIf cfg.enable (mkMerge [ @@ -147,5 +186,14 @@ in { vim.lsp.null-ls.enable = true; vim.lsp.null-ls.sources.nix-format = formats.${cfg.format.type}.nullConfig; }) + + (mkIf cfg.extraDiagnostics.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { + lang = "nix"; + config = cfg.extraDiagnostics.types; + inherit diagnostics; + }; + }) ]); }