From 75f7ec499559cb271bd945ef209ecbf484b69a6f Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 7 Apr 2025 15:55:20 +0200 Subject: [PATCH] modules/dependencies: add tree-sitter --- modules/dependencies.nix | 1 + plugins/by-name/treesitter/default.nix | 28 +++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/modules/dependencies.nix b/modules/dependencies.nix index eee05493..d5f244fa 100644 --- a/modules/dependencies.nix +++ b/modules/dependencies.nix @@ -13,6 +13,7 @@ let default = "git"; example = [ "gitMinimal" ]; }; + tree-sitter.default = "tree-sitter"; ueberzug.default = "ueberzugpp"; which.default = "which"; }; diff --git a/plugins/by-name/treesitter/default.nix b/plugins/by-name/treesitter/default.nix index 4b24b88c..89ea0989 100644 --- a/plugins/by-name/treesitter/default.nix +++ b/plugins/by-name/treesitter/default.nix @@ -2,7 +2,6 @@ lib, helpers, config, - pkgs, ... }: with lib; @@ -229,6 +228,12 @@ lib.nixvim.plugins.mkNeovimPlugin { (lib.mkRenamedOptionModule (basePluginPath ++ [ "moduleConfig" ]) ( basePluginPath ++ [ "settings" ] )) + + # TODO: added 2025-04-07, remove after 25.05 + (lib.nixvim.mkRemovedPackageOptionModule { + plugin = "treesitter"; + packageName = "treesitter"; + }) ]; settingsOptions = { @@ -364,9 +369,7 @@ lib.nixvim.plugins.mkNeovimPlugin { gccPackage = lib.mkPackageOption pkgs "gcc" { nullable = true; example = "pkgs.gcc14"; - extraDescription = '' - This is required to build grammars if you are not using `nixGrammars`. - ''; + extraDescription = ''This is required to build grammars if you are not using `nixGrammars ''; }; grammarPackages = mkOption { @@ -418,13 +421,6 @@ lib.nixvim.plugins.mkNeovimPlugin { 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. @@ -460,9 +456,17 @@ lib.nixvim.plugins.mkNeovimPlugin { extraPackages = [ cfg.gccPackage 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 { foldmethod = mkDefault "expr"; foldexpr = mkDefault "nvim_treesitter#foldexpr()";