diff --git a/plugins/languages/treesitter/treesitter.nix b/plugins/languages/treesitter/treesitter.nix index 63131c32..4e4e7212 100644 --- a/plugins/languages/treesitter/treesitter.nix +++ b/plugins/languages/treesitter/treesitter.nix @@ -142,12 +142,19 @@ helpers.neovim-plugin.mkNeovimPlugin config { List of parsers to ignore installing. Used when `ensure_installed` is set to "all". ''; - parser_install_dir = helpers.defaultNullOpts.mkStr "$XDG_DATA_HOME/nvim/treesitter" '' - Location of the parsers to be installed by the plugin (only needed when `nixGrammars` is disabled). + parser_install_dir = helpers.mkNullOrOption' { + type = with helpers.nixvimTypes; maybeRaw str; + # Backport the default from nvim-treesitter 1.0 + # The current default doesn't work on nix, as it is readonly + default.__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'site')"; + pluginDefault = lib.literalMD "the plugin's package directory"; + description = '' + Location of the parsers to be installed by the plugin (only needed when `nixGrammars` is disabled). - This default might not work on your own install, please make sure that `$XDG_DATA_HOME` is set if you want to use the default. - Otherwise, change it to something that will work for you! - ''; + By default, parsers are installed to the "site" dir. + If set to `null` the _plugin default_ is used, which will not work on nix. + ''; + }; sync_install = helpers.defaultNullOpts.mkBool false '' Install parsers synchronously (only applied to `ensure_installed`). @@ -158,7 +165,7 @@ helpers.neovim-plugin.mkNeovimPlugin config { auto_install = false; ensure_installed = [ "all" ]; ignore_install = [ "rust" ]; - parser_install_dir = "$XDG_DATA_HOME/nvim/treesitter"; + parser_install_dir.__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')"; sync_install = false; highlight = { @@ -284,7 +291,7 @@ helpers.neovim-plugin.mkNeovimPlugin config { # NOTE: Upstream state that the parser MUST be at the beginning of runtimepath. # Otherwise the parsers from Neovim takes precedent, which may be incompatible with some queries. (optionalString (cfg.settings.parser_install_dir != null) '' - vim.opt.runtimepath:prepend("${cfg.settings.parser_install_dir}") + vim.opt.runtimepath:prepend(${helpers.toLuaObject cfg.settings.parser_install_dir}) '') + '' require('nvim-treesitter.configs').setup(${helpers.toLuaObject cfg.settings}) diff --git a/tests/test-sources/plugins/languages/treesitter/treesitter.nix b/tests/test-sources/plugins/languages/treesitter/treesitter.nix index 11ea7c05..00f5a226 100644 --- a/tests/test-sources/plugins/languages/treesitter/treesitter.nix +++ b/tests/test-sources/plugins/languages/treesitter/treesitter.nix @@ -8,7 +8,9 @@ auto_install = false; ensure_installed = [ ]; ignore_install = [ ]; - parser_install_dir = null; + # NOTE: This is our default, not the plugin's + parser_install_dir.__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'site')"; + sync_install = false; highlight = {