fix(lazyfile): change logic to add syntax=ft instead of disabling the parser

This commit is contained in:
Iordanis Petkakis 2024-11-03 18:15:43 +02:00
parent 75d20e2cc9
commit 56b8847c29
2 changed files with 4 additions and 4 deletions

View file

@ -13,7 +13,7 @@ return {
if
vim.fn.argc() > 0 and vim.fn.isdirectory(vim.fn.argv(0) --[[@as string]]) ~= 1
then
vim.g.treesitter_disable_highlight = { "latex" }
vim.g.treesitter_syntax_legacy = { "latex" }
end
end,
opts = function(_, opts)

View file

@ -86,12 +86,12 @@ function M.lazy_file()
if ft then
-- Add treesitter highlights and fallback to syntax
local lang = vim.treesitter.language.get_lang(ft)
if vim.tbl_contains(vim.g.treesitter_disable_highlight or {}, lang) then
lang = nil
end
if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then
vim.bo[event.buf].syntax = ft
end
if vim.tbl_contains(vim.g.treesitter_syntax_legacy or {}, lang) then
vim.bo[event.buf].syntax = ft
end
-- Trigger early redraw
vim.cmd([[redraw]])