mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 12:09:48 +01:00
feat(languages/nix): statix & deadnix diagnostics
This commit is contained in:
parent
32a13428ec
commit
35f3be1306
2 changed files with 50 additions and 0 deletions
|
@ -35,3 +35,5 @@ https://github.com/notashelf[notashelf]:
|
||||||
* Addeed nvim-navic integration for catppuccin theme
|
* Addeed nvim-navic integration for catppuccin theme
|
||||||
|
|
||||||
* Fixed mismatching zig language description
|
* Fixed mismatching zig language description
|
||||||
|
|
||||||
|
* Added support for `statix` and `deadnix` through <<opt-vim.languages.nix.extraDiagnostics.types>>
|
||||||
|
|
|
@ -82,6 +82,32 @@ with builtins; let
|
||||||
# Never need to use null-ls for nixpkgs-fmt
|
# 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 {
|
in {
|
||||||
options.vim.languages.nix = {
|
options.vim.languages.nix = {
|
||||||
enable = mkEnableOption "Nix language support";
|
enable = mkEnableOption "Nix language support";
|
||||||
|
@ -124,6 +150,19 @@ in {
|
||||||
default = formats.${cfg.format.type}.package;
|
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 [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
@ -147,5 +186,14 @@ in {
|
||||||
vim.lsp.null-ls.enable = true;
|
vim.lsp.null-ls.enable = true;
|
||||||
vim.lsp.null-ls.sources.nix-format = formats.${cfg.format.type}.nullConfig;
|
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;
|
||||||
|
};
|
||||||
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue