mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 15:39:49 +01:00
a452a0b0e7
mkEnableOption already adds the phrase "Whether to enable ..." to the beginning of the option description, such that the string argument should only be "thing to be enabled"
63 lines
1.7 KiB
Nix
63 lines
1.7 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
with lib;
|
|
with builtins; let
|
|
cfg = config.vim.languages.zig;
|
|
in {
|
|
options.vim.languages.zig = {
|
|
enable = mkEnableOption "Zig language support";
|
|
|
|
treesitter = {
|
|
enable = mkEnableOption "Zig treesitter" // {default = config.vim.languages.enableTreesitter;};
|
|
package = nvim.types.mkGrammarOption pkgs "zig";
|
|
};
|
|
|
|
lsp = {
|
|
enable = mkEnableOption "Zig LSP support (zls)" // {default = config.vim.languages.enableLSP;};
|
|
|
|
package = mkOption {
|
|
description = "ZLS package, or the command to run as a list of strings";
|
|
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
|
|
type = with types; either package (listOf str);
|
|
default = pkgs.zls;
|
|
};
|
|
|
|
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 = ${
|
|
if isList cfg.lsp.package
|
|
then nvim.lua.expToLua cfg.lsp.package
|
|
else ''{"${cfg.lsp.package}/bin/zls"}''
|
|
},
|
|
settings = {
|
|
["zls"] = {
|
|
zig_exe_path = "${cfg.lsp.zigPackage}/bin/zig",
|
|
zig_lib_path = "${cfg.lsp.zigPackage}/lib/zig",
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
})
|
|
]);
|
|
}
|