nix-community.nixvim/modules/lsp/server.nix
Matt Sturgeon 90eb4e681c
modules/lsp/servers: move the * server to its own module
Introduce a bespoke `global-server.nix` module. This is less DRY, but
much simpler.

The `lsp.servers."*"` options are different enough from the other
`lsp.servers.<name>` options that it is simpler to just declare them
separately.

Now that we have a dedicated `global-server.nix` module, we no longer
need to split the normal server module into `server.nix`+`server-base.nix`

This partially reverts f2e96b67a3
2025-05-03 20:20:19 +01:00

84 lines
2 KiB
Nix

# Usage: lib.importApply ./server.nix { /*args*/ }
{
name ? "the language server",
package ? null,
settings ? null,
pkgs ? { },
}@args:
{
lib,
name,
config,
...
}:
let
inherit (lib) types;
displayName = args.name or "the language server";
packageName = package.name or (lib.strings.removePrefix "the " displayName);
in
{
options = {
enable = lib.mkEnableOption displayName;
name = lib.mkOption {
type = types.maybeRaw types.str;
description = ''
The name to use for ${displayName}.
Supplied to functions like `vim.lsp.enable()`.
'';
# Use the supplied attr name, or fallback to the name module-arg
default = args.name or name;
defaultText = args.name or (lib.literalMD "the attribute name");
};
activate = lib.mkOption {
type = types.bool;
description = ''
Whether to call `vim.lsp.enable()` for ${displayName}.
'';
default = config.name != "*";
defaultText = lib.literalMD ''
`true`, unless the server's `name` is `*`
'';
example = false;
};
package = lib.mkPackageOption pkgs packageName {
nullable = true;
default = package.default or package;
example = package.example or null;
extraDescription = ''
${package.extraDescription or ""}
Alternatively, ${displayName} should be installed on your `$PATH`.
'';
};
settings = lib.mkOption {
type = with types; attrsOf anything;
description = ''
Configurations for ${displayName}. ${settings.extraDescription or ""}
'';
default = { };
example =
settings.example or {
cmd = [
"clangd"
"--background-index"
];
root_markers = [
"compile_commands.json"
"compile_flags.txt"
];
filetypes = [
"c"
"cpp"
];
};
};
};
imports = [
./server-renames.nix
];
}