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.
This commit is contained in:
Pedro Alves 2022-01-15 02:37:09 +00:00
parent 929659b7a1
commit ba4afda369

View file

@ -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 {