mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/treesitter: don't exclude nvim-treesitter from combining by default
Nvim-treesitter's parsers from nixpkgs don't include grammars anymore. Originally it was added to standalonePlugins as workaround. If the user has some other plugin containing treesitter queries, this change can cause a build failure due to collisions. But since it is easier to add the plugin to standalonePlugins compared to removing it, I think this should be the default.
This commit is contained in:
parent
65d35db5ca
commit
d063d0dd5e
2 changed files with 31 additions and 35 deletions
|
@ -475,10 +475,5 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
foldmethod = mkDefault "expr";
|
foldmethod = mkDefault "expr";
|
||||||
foldexpr = mkDefault "nvim_treesitter#foldexpr()";
|
foldexpr = mkDefault "nvim_treesitter#foldexpr()";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Since https://github.com/NixOS/nixpkgs/pull/321550 upstream queries are added
|
|
||||||
# to grammar plugins. Exclude nvim-treesitter itself from combining to avoid
|
|
||||||
# collisions with grammar's queries
|
|
||||||
performance.combinePlugins.standalonePlugins = [ cfg.package ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,38 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
{
|
||||||
combine-plugins = {
|
combine-plugins =
|
||||||
performance.combinePlugins.enable = true;
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
performance.combinePlugins.enable = true;
|
||||||
|
|
||||||
plugins.treesitter = {
|
plugins.treesitter = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# Exclude nixvim injections for test to pass
|
# Exclude nixvim injections for test to pass
|
||||||
nixvimInjections = false;
|
nixvimInjections = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfigLuaPost = ''
|
extraConfigLuaPost = ''
|
||||||
-- Ensure that queries from nvim-treesitter are first in rtp
|
-- Ensure that queries from nvim-treesitter are first in rtp
|
||||||
local queries_path = "${pkgs.vimPlugins.nvim-treesitter}/queries"
|
local queries_path = "${config.plugins.treesitter.package}/queries"
|
||||||
for name, type in vim.fs.dir(queries_path, {depth = 10}) do
|
for name, type in vim.fs.dir(queries_path, {depth = 10}) do
|
||||||
if type == "file" then
|
if type == "file" then
|
||||||
-- Resolve all symlinks and compare nvim-treesitter's path with
|
-- Get the file from rtp, resolve all symlinks and check
|
||||||
-- whatever we've got from runtime
|
-- that the file is from nvim-treesitter. Only name is compared,
|
||||||
local nvim_treesitter_path = assert(vim.uv.fs_realpath(vim.fs.joinpath(queries_path, name)))
|
-- because 'combinePlugins' overrides packages.
|
||||||
local rtp_path = assert(
|
local rtp_path = assert(
|
||||||
vim.uv.fs_realpath(vim.api.nvim_get_runtime_file("queries/" .. name, false)[1]),
|
vim.uv.fs_realpath(vim.api.nvim_get_runtime_file("queries/" .. name, false)[1]),
|
||||||
name .. " not found in runtime"
|
name .. " not found in runtime"
|
||||||
)
|
|
||||||
assert(
|
|
||||||
nvim_treesitter_path == rtp_path,
|
|
||||||
string.format(
|
|
||||||
"%s from rtp (%s) is not the same as from nvim-treesitter (%s)",
|
|
||||||
name,
|
|
||||||
rtp_path, nvim_treesitter_path
|
|
||||||
)
|
)
|
||||||
)
|
assert(
|
||||||
|
rtp_path:find("nvim-treesitter", 1, true),
|
||||||
|
string.format(
|
||||||
|
"%s from rtp (%s) is not from nvim-treesitter",
|
||||||
|
name,
|
||||||
|
rtp_path
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
'';
|
||||||
'';
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue