mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 02:11:33 +00:00
Initialize changes for nix
This commit is contained in:
parent
852c378bf9
commit
bc93d67416
3 changed files with 116 additions and 112 deletions
|
@ -1,9 +1,13 @@
|
|||
{lib}: let
|
||||
inherit (builtins) isString getAttr;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr;
|
||||
inherit (lib.strings) concatStringsSep;
|
||||
inherit (lib.types) listOf bool str submodule attrsOf anything either nullOr oneOf enum;
|
||||
inherit (lib.attrsets) attrNames;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib) genAttrs recursiveUpdate;
|
||||
in {
|
||||
# TODO: remove
|
||||
diagnosticsToLua = {
|
||||
|
@ -34,6 +38,18 @@ in {
|
|||
description = "Turn on ${desc} for enabled languages by default";
|
||||
};
|
||||
|
||||
# resolveLspOptions
|
||||
# servers: AttrsOf lspOptions
|
||||
# selected: AttrsOf lspOptions | List of string keys from servers
|
||||
# Returns: AttrsOf lspOptions
|
||||
resolveLspOptions = {
|
||||
servers,
|
||||
selected,
|
||||
}:
|
||||
if isList selected
|
||||
then genAttrs selected (name: servers.${name})
|
||||
else selected;
|
||||
|
||||
lspOptions = submodule {
|
||||
freeformType = attrsOf anything;
|
||||
options = {
|
||||
|
@ -77,4 +93,27 @@ in {
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
mkLspOption = {servers, ...} @ args: let
|
||||
serverNames = attrNames servers;
|
||||
defaultAttrs = {
|
||||
type = oneOf [
|
||||
(attrsOf lib.nvim.languages.lspOptions)
|
||||
(listOf (enum serverNames))
|
||||
];
|
||||
description = ''
|
||||
Either a full set of selected LSP options as an attribute set,
|
||||
or a list of server names from: ${concatStringsSep ", " serverNames}.
|
||||
'';
|
||||
default = {};
|
||||
example = {
|
||||
clangd = {
|
||||
filetypes = ["c"];
|
||||
root_markers = ["CMakeLists.txt"];
|
||||
};
|
||||
};
|
||||
};
|
||||
cleanedArgs = removeAttrs args ["servers"];
|
||||
in
|
||||
mkOption (recursiveUpdate defaultAttrs cleanedArgs);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue