feat: use mkGrammarOption

This commit is contained in:
NotAShelf 2023-04-18 00:55:27 +03:00
parent 84ecf8f3fd
commit 544792e0b9
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
13 changed files with 31 additions and 47 deletions

View file

@ -115,6 +115,7 @@ inputs: let
vim.git = {
enable = true;
gitsigns.enable = true;
gitsigns.codeActions = true;
};
vim.minimap = {

View file

@ -5,5 +5,5 @@
in {
inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt;
inherit (typesLanguage) diagnostics;
inherit (typesLanguage) diagnostics mkGrammarOption;
}

View file

@ -23,4 +23,9 @@ in {
type = with types; listOf (either (enum (attrNames diagnostics)) (submodule diagnosticSubmodule));
default = defaultDiagnostics;
};
mkGrammarOption = pkgs: grammar:
mkPackageOption pkgs ["${grammar} treesitter"] {
default = ["vimPlugins" "nvim-treesitter" "builtGrammars" grammar];
};
}

View file

@ -41,16 +41,8 @@ in {
type = types.bool;
default = config.vim.languages.enableTreesitter;
};
cPackage = mkOption {
description = "C treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.c;
};
cppPackage = mkOption {
description = "C++ treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.cpp;
};
cPackage = nvim.types.mkGrammarOption pkgs "c";
cppPackage = nvim.types.mkGrammarOption pkgs "cpp";
};
lsp = {

View file

@ -31,11 +31,7 @@ in {
type = types.bool;
default = config.vim.languages.enableTreesitter;
};
package = mkOption {
description = "Go treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.go;
};
package = nvim.types.mkGrammarOption pkgs "go";
};
lsp = {

View file

@ -9,6 +9,11 @@ with builtins; let
cfg = config.vim.languages.markdown;
in {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.glow.enable {
vim.startPlugins = ["glow-nvim"];

View file

@ -16,5 +16,14 @@ in {
default = true;
description = "Enable markdown preview in neovim with glow";
};
treesitter = {
enable = mkOption {
description = "Enable Markdown treesitter";
type = types.bool;
default = config.vim.languages.enableTreesitter;
};
package = nvim.types.mkGrammarOption pkgs "markdown";
};
};
}

View file

@ -92,11 +92,7 @@ in {
type = types.bool;
default = config.vim.languages.enableTreesitter;
};
package = mkOption {
description = "Nix treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.nix;
};
package = nvim.types.mkGrammarOption pkgs "nix";
};
lsp = {

View file

@ -64,11 +64,7 @@ in {
type = with types; enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Python LSP server package";
type = types.package;
default = servers.${cfg.lsp.server}.package;
};
package = nvim.types.mkGrammarOption pkgs "python";
};
format = {

View file

@ -17,11 +17,7 @@ in {
type = types.bool;
default = config.vim.languages.enableTreesitter;
};
package = mkOption {
description = "Rust treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.rust;
};
package = nvim.types.mkGrammarOption pkgs "rust";
};
crates = {

View file

@ -63,16 +63,8 @@ in {
type = types.bool;
default = config.vim.languages.enableTreesitter;
};
tsPackage = mkOption {
description = "Typescript treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.tsx;
};
jsPackage = mkOption {
description = "Javascript treesitter grammar to use";
type = types.package;
default = pkgs.vimPlugins.nvim-treesitter.builtGrammars.javascript;
};
tsPackage = nvim.types.mkGrammarOption pkgs "tsx";
jsPackage = nvim.types.mkGrammarOption pkgs "javascript";
};
lsp = {

View file

@ -17,11 +17,7 @@ in {
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;
};
package = nvim.types.mkGrammarOption pkgs "zig";
};
lsp = {
enable = mkOption {