From ba4afda369b156214c5aa9574563ef66f7507f3b Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sat, 15 Jan 2022 02:37:09 +0000 Subject: [PATCH] treesitter: install parsers with nix This fixes weird issues where you might get errors about libstdc++ after updating your system without running :TSInstall again. Fixes it by just relying on Nix to do the managing itself! Unfortunately, for now this still needs work: you can't select which languages are to be installed, which is why it's off by default. In the hopefully not-too-distant future, this will be the default, and the other way will be deprecated. --- plugins/languages/treesitter.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 439f7898..5e68f1b2 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -9,6 +9,11 @@ in programs.nixvim.plugins.treesitter = { enable = mkEnableOption "Enable tree-sitter syntax highlighting"; + nixGrammars = mkOption { + type = types.bool; + default = false; + description = "Install grammars with Nix (beta)"; + }; ensureInstalled = mkOption { type = with types; oneOf [ (enum [ "all" "maintained" ]) (listOf str) ]; default = "maintained"; @@ -79,7 +84,9 @@ in require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) ''; - extraPlugins = [ pkgs.vimPlugins.nvim-treesitter ]; + extraPlugins = with pkgs; if cfg.nixGrammars then + [ (vimPlugins.nvim-treesitter.withPlugins(_: tree-sitter.allGrammars)) ] + else [ vimPlugins.nvim-treesitter ]; extraPackages = [ pkgs.tree-sitter pkgs.nodejs ]; options = mkIf cfg.folding {