mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
Merge pull request #113 from NotAShelf/feature/nix-diagnostics
This commit is contained in:
commit
a100d26e51
2 changed files with 52 additions and 0 deletions
|
@ -36,4 +36,8 @@ https://github.com/notashelf[notashelf]:
|
|||
|
||||
* Fixed mismatching zig language description
|
||||
|
||||
* Added support for `statix` and `deadnix` through <<opt-vim.languages.nix.extraDiagnostics.types>>
|
||||
|
||||
* Added lsp_lines plugin for showing diagnostic messages
|
||||
|
||||
* Added a configuration option for choosing the leader key
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue