Skip to content

Commit 1c6a872

Browse files
committed
test: config
1 parent 5897724 commit 1c6a872

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

tests/mininit.lua

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,27 @@ function M.setup()
4949

5050
vim.cmd [[packloadall]]
5151

52+
-- Initialize nvim-treesitter to make commands available
53+
pcall(require, 'nvim-treesitter')
54+
55+
-- Configure parser install directory (for compatibility with older versions)
56+
local ok, configs = pcall(require, 'nvim-treesitter.configs')
57+
if ok and configs.setup then
58+
pcall(configs.setup, {
59+
parser_install_dir = parser_install_dir,
60+
})
61+
end
62+
63+
-- Install parsers using the command if available, otherwise use the API
5264
for _, lang in ipairs(langs) do
53-
vim.cmd('TSInstallSync ' .. lang)
65+
local install_ok = pcall(vim.cmd, 'TSInstallSync ' .. lang)
66+
if not install_ok then
67+
-- Fallback to direct API if command doesn't exist
68+
local install = pcall(require, 'nvim-treesitter.install')
69+
if install then
70+
pcall(require('nvim-treesitter.install').update, { with_sync = true }, lang)
71+
end
72+
end
5473
end
5574
end
5675

0 commit comments

Comments
 (0)