fix(lazyfile): account for treesitter disable highlights

This commit is contained in:
Iordanis Petkakis 2024-11-03 13:35:25 +02:00
parent 29dab35619
commit 75d20e2cc9
2 changed files with 10 additions and 0 deletions

View file

@ -9,6 +9,13 @@ return {
-- Add BibTeX/LaTeX to treesitter
{
"nvim-treesitter/nvim-treesitter",
init = function()
if
vim.fn.argc() > 0 and vim.fn.isdirectory(vim.fn.argv(0) --[[@as string]]) ~= 1
then
vim.g.treesitter_disable_highlight = { "latex" }
end
end,
opts = function(_, opts)
opts.highlight = opts.highlight or {}
if type(opts.ensure_installed) == "table" then

View file

@ -86,6 +86,9 @@ 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