mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-02 21:34:33 +02:00
lsp: added package
option to basic lsp servers (#61)
* nvim-lsp: added package options for basic servers * nvim-lsp: updated package options * nvim-lsp: added cmd to plugins that share dependency
This commit is contained in:
parent
50bda39cd2
commit
2180675750
2 changed files with 46 additions and 35 deletions
|
@ -5,9 +5,10 @@
|
|||
{ name
|
||||
, description ? "Enable ${name}."
|
||||
, serverName ? name
|
||||
, packages ? [ pkgs.${name} ]
|
||||
, cmd ? null
|
||||
, settings ? null
|
||||
, package ? pkgs.${name}
|
||||
, extraPackages ? { }
|
||||
, cmd ? (cfg: null)
|
||||
, settings ? (cfg: { })
|
||||
, extraOptions ? { }
|
||||
, ...
|
||||
}:
|
||||
|
@ -16,24 +17,34 @@
|
|||
with lib;
|
||||
let
|
||||
cfg = config.plugins.lsp.servers.${name};
|
||||
|
||||
packageOption =
|
||||
if package != null then {
|
||||
package = mkOption {
|
||||
default = package;
|
||||
type = types.nullOr types.package;
|
||||
};
|
||||
} else { };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
plugins.lsp.servers.${name} = {
|
||||
enable = mkEnableOption description;
|
||||
} // extraOptions;
|
||||
} // packageOption // extraOptions;
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
extraPackages = packages;
|
||||
config = mkIf cfg.enable
|
||||
{
|
||||
extraPackages = (optional (package != null) cfg.package) ++
|
||||
(mapAttrsToList (name: _: cfg."${name}Package") extraPackages);
|
||||
|
||||
plugins.lsp.enabledServers = [{
|
||||
name = serverName;
|
||||
extraOptions = {
|
||||
inherit cmd;
|
||||
settings = if settings != null then settings cfg else { };
|
||||
};
|
||||
}];
|
||||
};
|
||||
plugins.lsp.enabledServers = [{
|
||||
name = serverName;
|
||||
extraOptions = {
|
||||
cmd = cmd cfg;
|
||||
settings = settings cfg;
|
||||
};
|
||||
}];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue