From 918b47d2c126f25ca5ea41c9ab30eb4307b22be9 Mon Sep 17 00:00:00 2001 From: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:58:11 +0300 Subject: [PATCH] plugins/treesitter: extract combine-plugins test to separate file --- .../languages/treesitter/combine-plugins.nix | 37 +++++++++++++++++++ .../languages/treesitter/treesitter.nix | 35 ------------------ 2 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 tests/test-sources/plugins/languages/treesitter/combine-plugins.nix diff --git a/tests/test-sources/plugins/languages/treesitter/combine-plugins.nix b/tests/test-sources/plugins/languages/treesitter/combine-plugins.nix new file mode 100644 index 0000000000..074c95ad86 --- /dev/null +++ b/tests/test-sources/plugins/languages/treesitter/combine-plugins.nix @@ -0,0 +1,37 @@ +{ pkgs, ... }: +{ + combine-plugins = { + performance.combinePlugins.enable = true; + + plugins.treesitter = { + enable = true; + + # Exclude nixvim injections for test to pass + nixvimInjections = false; + }; + + extraConfigLuaPost = '' + -- Ensure that queries from nvim-treesitter are first in rtp + local queries_path = "${pkgs.vimPlugins.nvim-treesitter}/queries" + for name, type in vim.fs.dir(queries_path, {depth = 10}) do + if type == "file" then + -- Resolve all symlinks and compare nvim-treesitter's path with + -- whatever we've got from runtime + local nvim_treesitter_path = assert(vim.uv.fs_realpath(vim.fs.joinpath(queries_path, name))) + local rtp_path = assert( + vim.uv.fs_realpath(vim.api.nvim_get_runtime_file("queries/" .. name, false)[1]), + 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 + ) + ) + end + end + ''; + }; +} diff --git a/tests/test-sources/plugins/languages/treesitter/treesitter.nix b/tests/test-sources/plugins/languages/treesitter/treesitter.nix index aa5dd9b62a..00f5a22633 100644 --- a/tests/test-sources/plugins/languages/treesitter/treesitter.nix +++ b/tests/test-sources/plugins/languages/treesitter/treesitter.nix @@ -120,39 +120,4 @@ ]; }; }; - - combine-plugins = { - performance.combinePlugins.enable = true; - - plugins.treesitter = { - enable = true; - - # Exclude nixvim injections for test to pass - nixvimInjections = false; - }; - - extraConfigLuaPost = '' - -- Ensure that queries from nvim-treesitter are first in rtp - local queries_path = "${pkgs.vimPlugins.nvim-treesitter}/queries" - for name, type in vim.fs.dir(queries_path, {depth = 10}) do - if type == "file" then - -- Resolve all symlinks and compare nvim-treesitter's path with - -- whatever we've got from runtime - local nvim_treesitter_path = assert(vim.uv.fs_realpath(vim.fs.joinpath(queries_path, name))) - local rtp_path = assert( - vim.uv.fs_realpath(vim.api.nvim_get_runtime_file("queries/" .. name, false)[1]), - 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 - ) - ) - end - end - ''; - }; }