mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
languages/cue: convert module
This commit is contained in:
parent
675dbc677f
commit
25f4d62f6a
1 changed files with 21 additions and 18 deletions
|
@ -4,30 +4,35 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) package;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.types) mkGrammarOption mkServersOption;
|
||||
|
||||
cfg = config.vim.languages.cue;
|
||||
|
||||
defaultServers = ["cue"];
|
||||
servers = {
|
||||
cue = {
|
||||
enable = true;
|
||||
cmd = [(getExe pkgs.cue) "lsp"];
|
||||
filetypes = ["cue"];
|
||||
root_markers = ["cue.mod" ".git"];
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.cue = {
|
||||
enable = mkEnableOption "CUE language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "CUE treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = mkGrammarOption pkgs "cue";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "CUE LSP support" // {default = config.vim.lsp.enable;};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.cue;
|
||||
description = "cue lsp implementation";
|
||||
};
|
||||
servers = mkServersOption "CUE" servers defaultServers;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -38,14 +43,12 @@ in {
|
|||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.cue-lsp = ''
|
||||
lspconfig.cue.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = {"${cfg.lsp.package}/bin/cue", "lsp"},
|
||||
}
|
||||
'';
|
||||
vim.lsp.servers =
|
||||
mapListToAttrs (n: {
|
||||
name = n;
|
||||
value = servers.${n};
|
||||
})
|
||||
cfg.lsp.servers;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue