nvim-lsp: add installLanguageServer option for servers

This commit is contained in:
Gaetan Lepage 2023-05-22 13:34:08 +02:00 committed by Gaétan Lepage
parent efdcbe225f
commit 21f2e43568
2 changed files with 13 additions and 4 deletions

View file

@ -32,7 +32,7 @@
then { then {
package = mkOption { package = mkOption {
default = package; default = package;
type = types.nullOr types.package; type = types.package;
}; };
} }
else {}; else {};
@ -42,9 +42,18 @@
{ {
enable = mkEnableOption description; enable = mkEnableOption description;
installLanguageServer = mkOption {
type = types.bool;
default = true;
description = "Whether nixvim should take care of installing the language server.";
};
cmd = mkOption { cmd = mkOption {
type = with types; nullOr (listOf str); type = with types; nullOr (listOf str);
default = cmd cfg; default =
if cfg.installLanguageServer
then cmd cfg
else null;
}; };
filetypes = helpers.mkNullOrOption (types.listOf types.str) '' filetypes = helpers.mkNullOrOption (types.listOf types.str) ''
@ -103,7 +112,7 @@
extraPackages = extraPackages =
( (
optional optional
((package != null) && (cfg.package != null)) (cfg.installLanguageServer && (package != null))
cfg.package cfg.package
) )
++ (mapAttrsToList (name: _: cfg."${name}Package") extraPackages); ++ (mapAttrsToList (name: _: cfg."${name}Package") extraPackages);

View file

@ -34,7 +34,7 @@
# Do not install the language server using nixvim # Do not install the language server using nixvim
gopls = { gopls = {
enable = true; enable = true;
package = null; installLanguageServer = false;
}; };
nil_ls.enable = true; nil_ls.enable = true;
rust-analyzer.enable = true; rust-analyzer.enable = true;