Skip to content

Commit 208f02f

Browse files
committed
lib/languages: add lspOptions submodule type for freeform LSP config
1 parent 0644475 commit 208f02f

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

lib/languages.nix

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
21
{lib}: let
32
inherit (builtins) isString getAttr;
4-
inherit (lib.options) mkOption;
5-
inherit (lib.types) bool;
3+
inherit (lib.options) mkOption mkEnableOption;
4+
inherit (lib.types) listOf bool str submodule attrsOf anything;
5+
inherit (lib.generators) mkLuaInline;
6+
inherit (lib.meta) getExe;
67
inherit (lib.nvim.attrsets) mapListToAttrs;
8+
inherit (lib.nvim.types) luaInline;
79
in {
810
diagnosticsToLua = {
911
lang,
@@ -32,4 +34,31 @@ in {
3234
type = bool;
3335
description = "Turn on ${desc} for enabled languages by default";
3436
};
37+
38+
lspOptions = submodule {
39+
freeformType = attrsOf anything;
40+
options = {
41+
capabilities = mkOption {
42+
type = luaInline;
43+
default = mkLuaInline "default_capabilities";
44+
description = "LSP capabilitiess to pass to lspconfig";
45+
};
46+
47+
on_attach = mkOption {
48+
type = luaInline;
49+
default = mkLuaInline "default_capabilities";
50+
description = "Function to execute when an LSP server attaches to a buffer";
51+
};
52+
53+
filetypes = mkOption {
54+
type = listOf str;
55+
description = "Filetypes to auto-attach LSP in";
56+
};
57+
58+
cmd = mkOption {
59+
type = listOf str;
60+
description = "Command used to start the LSP server";
61+
};
62+
};
63+
};
3564
}

0 commit comments

Comments
 (0)