File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
5574end
5675
You can’t perform that action at this time.
0 commit comments