mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(treesitter-main): set vim.bo.indentexpr in FileType autocmd
This commit is contained in:
parent
45181a76dd
commit
82f330e52c
1 changed files with 10 additions and 8 deletions
|
|
@ -31,19 +31,21 @@ return {
|
||||||
vim.list_extend(installed, install)
|
vim.list_extend(installed, install)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- backwards compatibility with the old treesitter config for indent
|
-- backwards compatibility with the old treesitter config for highlight and indent
|
||||||
if vim.tbl_get(opts, "indent", "enable") then
|
local highlight, indent = vim.tbl_get(opts, "highlight", "enable"), vim.tbl_get(opts, "indent", "enable")
|
||||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
if highlight or indent then
|
||||||
end
|
|
||||||
|
|
||||||
-- backwards compatibility with the old treesitter config for highlight
|
|
||||||
if vim.tbl_get(opts, "highlight", "enable") then
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
local lang = vim.treesitter.language.get_lang(ev.match)
|
local lang = vim.treesitter.language.get_lang(ev.match)
|
||||||
if vim.tbl_contains(installed, lang) then
|
if not vim.tbl_contains(installed, lang) then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if highlight then
|
||||||
pcall(vim.treesitter.start)
|
pcall(vim.treesitter.start)
|
||||||
end
|
end
|
||||||
|
if indent then
|
||||||
|
vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue