From 75d20e2cc96ce46a46e29bc8b92e097b08df8c20 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Sun, 3 Nov 2024 13:35:25 +0200 Subject: [PATCH] fix(lazyfile): account for treesitter disable highlights --- lua/lazyvim/plugins/extras/lang/tex.lua | 7 +++++++ lua/lazyvim/util/plugin.lua | 3 +++ 2 files changed, 10 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/tex.lua b/lua/lazyvim/plugins/extras/lang/tex.lua index 870a3fda..2f7b6017 100644 --- a/lua/lazyvim/plugins/extras/lang/tex.lua +++ b/lua/lazyvim/plugins/extras/lang/tex.lua @@ -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 diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 92c75540..b84d4590 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -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