fix(nvim): refactor treesitter to explicit parser list with deferred install
This commit is contained in:
@@ -3,7 +3,22 @@ return {
|
|||||||
lazy = false,
|
lazy = false,
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
config = function()
|
config = function()
|
||||||
-- New nvim-treesitter just installs parsers, Neovim handles highlighting
|
local ensure_installed = {
|
||||||
|
"lua", "vim", "vimdoc", "javascript", "typescript", "tsx",
|
||||||
|
"html", "css", "json", "yaml", "markdown", "bash", "python",
|
||||||
|
"php", "vue", "dockerfile", "go", "rust",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Auto-install missing parsers
|
||||||
|
vim.defer_fn(function()
|
||||||
|
for _, lang in ipairs(ensure_installed) do
|
||||||
|
local ok = pcall(vim.treesitter.language.inspect, lang)
|
||||||
|
if not ok then
|
||||||
|
vim.cmd("TSInstall " .. lang)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, 100)
|
||||||
|
|
||||||
-- Start treesitter highlighting for all buffers with a parser
|
-- Start treesitter highlighting for all buffers with a parser
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
|
|||||||
Reference in New Issue
Block a user