2023-04-17 20:27:27 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
with builtins; let
|
|
|
|
cfg = config.vim.languages.zig;
|
|
|
|
in {
|
|
|
|
options.vim.languages.zig = {
|
2023-07-30 15:36:10 +00:00
|
|
|
enable = mkEnableOption "Zig language support";
|
2023-04-17 20:27:27 +00:00
|
|
|
|
|
|
|
treesitter = {
|
2023-06-05 20:10:25 +00:00
|
|
|
enable = mkEnableOption "Enable Zig treesitter" // {default = config.vim.languages.enableTreesitter;};
|
2023-04-17 21:55:27 +00:00
|
|
|
package = nvim.types.mkGrammarOption pkgs "zig";
|
2023-04-17 20:27:27 +00:00
|
|
|
};
|
2023-06-05 20:10:25 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
lsp = {
|
2023-06-05 20:10:25 +00:00
|
|
|
enable = mkEnableOption "Zig LSP support (zls)" // {default = config.vim.languages.enableLSP;};
|
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
package = mkOption {
|
|
|
|
description = "ZLS package";
|
|
|
|
type = types.package;
|
2023-05-01 15:32:47 +00:00
|
|
|
default = pkgs.zls;
|
2023-04-17 20:27:27 +00:00
|
|
|
};
|
2023-06-05 20:10:25 +00:00
|
|
|
|
2023-04-17 20:27:27 +00:00
|
|
|
zigPackage = mkOption {
|
|
|
|
description = "Zig package used by ZLS";
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.zig;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
(mkIf cfg.treesitter.enable {
|
|
|
|
vim.treesitter.enable = true;
|
|
|
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
|
|
vim.lsp.lspconfig.enable = true;
|
|
|
|
vim.lsp.lspconfig.sources.zig-lsp = ''
|
|
|
|
lspconfig.zls.setup {
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach=default_on_attach,
|
|
|
|
cmd = {"${cfg.lsp.package}/bin/zls"},
|
|
|
|
settings = {
|
|
|
|
["zls"] = {
|
|
|
|
zig_exe_path = "${cfg.lsp.zigPackage}/bin/zig",
|
|
|
|
zig_lib_path = "${cfg.lsp.zigPackage}/lib/zig",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|