modules/dependencies: add tree-sitter

This commit is contained in:
Gaetan Lepage 2025-04-07 15:55:20 +02:00 committed by nix-infra-bot
parent 9cc70f8c03
commit 75f7ec4995
2 changed files with 17 additions and 12 deletions

View file

@ -13,6 +13,7 @@ let
default = "git"; default = "git";
example = [ "gitMinimal" ]; example = [ "gitMinimal" ];
}; };
tree-sitter.default = "tree-sitter";
ueberzug.default = "ueberzugpp"; ueberzug.default = "ueberzugpp";
which.default = "which"; which.default = "which";
}; };

View file

@ -2,7 +2,6 @@
lib, lib,
helpers, helpers,
config, config,
pkgs,
... ...
}: }:
with lib; with lib;
@ -229,6 +228,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
(lib.mkRenamedOptionModule (basePluginPath ++ [ "moduleConfig" ]) ( (lib.mkRenamedOptionModule (basePluginPath ++ [ "moduleConfig" ]) (
basePluginPath ++ [ "settings" ] basePluginPath ++ [ "settings" ]
)) ))
# TODO: added 2025-04-07, remove after 25.05
(lib.nixvim.mkRemovedPackageOptionModule {
plugin = "treesitter";
packageName = "treesitter";
})
]; ];
settingsOptions = { settingsOptions = {
@ -364,9 +369,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
gccPackage = lib.mkPackageOption pkgs "gcc" { gccPackage = lib.mkPackageOption pkgs "gcc" {
nullable = true; nullable = true;
example = "pkgs.gcc14"; example = "pkgs.gcc14";
extraDescription = '' extraDescription = ''This is required to build grammars if you are not using `nixGrammars '';
This is required to build grammars if you are not using `nixGrammars`.
'';
}; };
grammarPackages = mkOption { grammarPackages = mkOption {
@ -418,13 +421,6 @@ lib.nixvim.plugins.mkNeovimPlugin {
This is required to build grammars if you are not using `nixGrammars`. This is required to build grammars if you are not using `nixGrammars`.
''; '';
}; };
treesitterPackage = lib.mkPackageOption pkgs "tree-sitter" {
nullable = true;
extraDescription = ''
This is required to build grammars if you are not using `nixGrammars`.
'';
};
}; };
# NOTE: We call setup manually below. # NOTE: We call setup manually below.
@ -460,9 +456,17 @@ lib.nixvim.plugins.mkNeovimPlugin {
extraPackages = [ extraPackages = [
cfg.gccPackage cfg.gccPackage
cfg.nodejsPackage cfg.nodejsPackage
cfg.treesitterPackage
]; ];
dependencies.tree-sitter.enable = lib.mkIf (!cfg.nixGrammars) lib.mkDefault true;
warnings = lib.nixvim.mkWarnings "plugins.treesitter" {
when = !cfg.nixGrammars && (!config.dependencies.tree-sitter.enable);
message = ''
`tree-sitter` is required to build grammars as you are not using `nixGrammars`.
You may want to set `dependencies.tree-sitter.enable` to `true`.
'';
};
opts = mkIf cfg.folding { opts = mkIf cfg.folding {
foldmethod = mkDefault "expr"; foldmethod = mkDefault "expr";
foldexpr = mkDefault "nvim_treesitter#foldexpr()"; foldexpr = mkDefault "nvim_treesitter#foldexpr()";