mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-22 04:21:08 +00:00
perf(treesitter-main): only enable highlighting for installed treesitter langs
This commit is contained in:
parent
2f75d9a90f
commit
2f309fc8b5
1 changed files with 6 additions and 2 deletions
|
|
@ -28,6 +28,7 @@ return {
|
||||||
|
|
||||||
if #install > 0 then
|
if #install > 0 then
|
||||||
TS.install(install, { summary = true })
|
TS.install(install, { summary = true })
|
||||||
|
vim.list_extend(installed, install)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- backwards compatibility with the old treesitter config for indent
|
-- backwards compatibility with the old treesitter config for indent
|
||||||
|
|
@ -38,8 +39,11 @@ return {
|
||||||
-- backwards compatibility with the old treesitter config for highlight
|
-- backwards compatibility with the old treesitter config for highlight
|
||||||
if vim.tbl_get(opts, "highlight", "enable") then
|
if vim.tbl_get(opts, "highlight", "enable") then
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
callback = function()
|
callback = function(ev)
|
||||||
pcall(vim.treesitter.start)
|
local lang = vim.treesitter.language.get_lang(ev.match)
|
||||||
|
if vim.tbl_contains(installed, lang) then
|
||||||
|
pcall(vim.treesitter.start)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue