mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
convert odin module
This commit is contained in:
parent
2083f7d87f
commit
e95f57a8b3
1 changed files with 27 additions and 27 deletions
|
@ -7,26 +7,28 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.types) listOf enum;
|
||||||
inherit (lib.types) either listOf package str enum;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
defaultServer = "ols";
|
defaultServers = ["ols"];
|
||||||
servers = {
|
servers = {
|
||||||
ols = {
|
ols = {
|
||||||
package = pkgs.ols;
|
enable = true;
|
||||||
lspConfig = ''
|
cmd = [(getExe pkgs.ols)];
|
||||||
lspconfig.ols.setup {
|
filetypes = ["odin"];
|
||||||
capabilities = capabilities,
|
root_dir =
|
||||||
on_attach = default_on_attach,
|
mkLuaInline
|
||||||
cmd = ${
|
/*
|
||||||
if isList cfg.lsp.package
|
lua
|
||||||
then expToLua cfg.lsp.package
|
*/
|
||||||
else "{'${cfg.lsp.package}/bin/ols'}"
|
''
|
||||||
}
|
function(bufnr, on_dir)
|
||||||
}
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
'';
|
on_dir(util.root_pattern('ols.json', '.git', '*.odin')(fname))
|
||||||
|
end'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,16 +45,10 @@ in {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Odin LSP support" // {default = config.vim.lsp.enable;};
|
enable = mkEnableOption "Odin LSP support" // {default = config.vim.lsp.enable;};
|
||||||
|
|
||||||
server = mkOption {
|
servers = mkOption {
|
||||||
type = enum (attrNames servers);
|
|
||||||
default = defaultServer;
|
|
||||||
description = "Odin LSP server to use";
|
description = "Odin LSP server to use";
|
||||||
};
|
type = listOf (enum (attrNames servers));
|
||||||
|
default = defaultServers;
|
||||||
package = mkOption {
|
|
||||||
description = "Ols package, or the command to run as a list of strings";
|
|
||||||
type = either package (listOf str);
|
|
||||||
default = pkgs.ols;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -64,8 +60,12 @@ in {
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.servers =
|
||||||
vim.lsp.lspconfig.sources.odin-lsp = servers.${cfg.lsp.server}.lspConfig;
|
mapListToAttrs (n: {
|
||||||
|
name = n;
|
||||||
|
value = servers.${n};
|
||||||
|
})
|
||||||
|
cfg.lsp.servers;
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue