|
1 | 1 | local helpers = require('nvim-test.helpers') |
2 | | -local clear = helpers.clear |
3 | 2 | local exec_lua = helpers.exec_lua |
4 | 3 | local cmd = helpers.api.nvim_command |
5 | 4 | local feed = helpers.feed |
@@ -71,7 +70,7 @@ local function install_langs_for_file(filename, root_lang) |
71 | 70 | if seen_langs[current_lang] then |
72 | 71 | goto continue |
73 | 72 | end |
74 | | - install_langs(current_lang) |
| 73 | + exec_lua(install_langs, current_lang) |
75 | 74 |
|
76 | 75 | -- Query for injections in the current language, and queue them for installation. |
77 | 76 | --- @diagnostic disable-next-line: redefined-local Not actually redefining locals |
@@ -121,28 +120,24 @@ end |
121 | 120 |
|
122 | 121 | local lang_to_test_files = {} --- @type table<string,string[]> |
123 | 122 | setup(function() |
124 | | - clear() |
125 | | - cmd([[set runtimepath+=.,./deps/nvim-treesitter]]) |
| 123 | + helpers.clear() |
| 124 | + exec_lua(tc_helpers.setup) |
126 | 125 |
|
127 | | - -- Required to load custom predicates |
128 | | - exec_lua([[require'nvim-treesitter'.setup()]]) |
| 126 | + exec_lua(install_langs, 'lua') |
129 | 127 |
|
130 | 128 | local test_files = fn.globpath('test/lang', '*', true, true) --- @type string[] |
131 | 129 | for _, test_file in ipairs(test_files) do |
132 | 130 | cmd('edit ' .. test_file) |
133 | 131 | local bufnr = api.nvim_get_current_buf() |
134 | 132 | --- @type string |
135 | | - local treesitter_lang = exec_lua( |
136 | | - [[ |
137 | | - local ok, parser = pcall(vim.treesitter.get_parser, ...) |
138 | | - if not ok then |
139 | | - return nil |
140 | | - end |
141 | | - return parser:lang() |
142 | | - ]], |
143 | | - bufnr |
144 | | - ) |
145 | | - if treesitter_lang ~= vim.NIL and treesitter_lang ~= '' then |
| 133 | + local treesitter_lang = exec_lua(function(...) |
| 134 | + local ok, parser = pcall(vim.treesitter.get_parser, ...) |
| 135 | + if not ok then |
| 136 | + return nil |
| 137 | + end |
| 138 | + return parser:lang() |
| 139 | + end, bufnr) |
| 140 | + if treesitter_lang ~= nil and treesitter_lang ~= '' then |
146 | 141 | if not lang_to_test_files[treesitter_lang] then |
147 | 142 | lang_to_test_files[treesitter_lang] = {} |
148 | 143 | end |
|
0 commit comments