mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35:30 +00:00
feat: refactor and separate LSP/language configurations
This commit is contained in:
parent
7a71f06763
commit
6b512f132a
30 changed files with 1266 additions and 522 deletions
68
modules/languages/zig.nix
Normal file
68
modules/languages/zig.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.languages.zig;
|
||||
in {
|
||||
options.vim.languages.zig = {
|
||||
enable = mkEnableOption "SQL language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkOption {
|
||||
description = "Enable Zig treesitter";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableTreesitter;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "Zig treesitter grammar to use";
|
||||
type = types.package;
|
||||
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.zig;
|
||||
};
|
||||
};
|
||||
lsp = {
|
||||
enable = mkOption {
|
||||
description = "Zig LSP support (zls)";
|
||||
type = types.bool;
|
||||
default = config.vim.languages.enableLSP;
|
||||
};
|
||||
package = mkOption {
|
||||
description = "ZLS package";
|
||||
type = types.package;
|
||||
default = pkgs.nodePackages.pyright;
|
||||
};
|
||||
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",
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue