mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-24 09:48:42 +02:00
modules/lsp/server: declare package
defaults
Convert the `attrsOf (servers.nix)` option to a freeform submodule. Declare a `servers.nix` option for each lsp server listed in `lsp-packages.nix` that has a known nixpkgs package.
This commit is contained in:
parent
276abde288
commit
e34eaf8395
3 changed files with 98 additions and 29 deletions
|
@ -1,59 +1,74 @@
|
|||
# Usage: lib.importApply ./server.nix { /*args*/ }
|
||||
{
|
||||
name ? null,
|
||||
package ? null,
|
||||
# Avoid naming conflict with the `config` module arg
|
||||
# TODO: consider renaming the `config` option to something like `settings`?
|
||||
configOption ? null,
|
||||
pkgs ? { },
|
||||
}@args:
|
||||
{ lib, name, ... }:
|
||||
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 "the language server";
|
||||
enable = lib.mkEnableOption displayName;
|
||||
|
||||
name = lib.mkOption {
|
||||
type = types.maybeRaw types.str;
|
||||
description = ''
|
||||
The name of the language server, supplied to functions like `vim.lsp.enable()`.
|
||||
The name to use for ${displayName}.
|
||||
Supplied to functions like `vim.lsp.enable()`.
|
||||
'';
|
||||
default = name;
|
||||
defaultText = lib.literalMD "the attribute name";
|
||||
# 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 this server.
|
||||
Whether to call `vim.lsp.enable()` for ${displayName}.
|
||||
'';
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
|
||||
package = lib.mkOption {
|
||||
type = with types; nullOr package;
|
||||
default = null;
|
||||
description = ''
|
||||
Package to use for this language server.
|
||||
package = lib.mkPackageOption pkgs packageName {
|
||||
nullable = true;
|
||||
default = package.default or package;
|
||||
example = package.example or null;
|
||||
extraDescription = ''
|
||||
${package.extraDescription or ""}
|
||||
|
||||
Alternatively, the language server should be available on your `$PATH`.
|
||||
Alternatively, ${displayName} should be installed on your `$PATH`.
|
||||
'';
|
||||
};
|
||||
|
||||
config = lib.mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
description = ''
|
||||
Configurations for each language server.
|
||||
Configurations for ${displayName}. ${configOption.extraDescription or ""}
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
cmd = [
|
||||
"clangd"
|
||||
"--background-index"
|
||||
];
|
||||
root_markers = [
|
||||
"compile_commands.json"
|
||||
"compile_flags.txt"
|
||||
];
|
||||
filetypes = [
|
||||
"c"
|
||||
"cpp"
|
||||
];
|
||||
};
|
||||
example =
|
||||
configOption.example or {
|
||||
cmd = [
|
||||
"clangd"
|
||||
"--background-index"
|
||||
];
|
||||
root_markers = [
|
||||
"compile_commands.json"
|
||||
"compile_flags.txt"
|
||||
];
|
||||
filetypes = [
|
||||
"c"
|
||||
"cpp"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue