mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
fix(lazyfile): account for treesitter disable highlights
This commit is contained in:
parent
29dab35619
commit
75d20e2cc9
2 changed files with 10 additions and 0 deletions
|
|
@ -9,6 +9,13 @@ return {
|
||||||
-- Add BibTeX/LaTeX to treesitter
|
-- Add BibTeX/LaTeX to treesitter
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-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 = function(_, opts)
|
||||||
opts.highlight = opts.highlight or {}
|
opts.highlight = opts.highlight or {}
|
||||||
if type(opts.ensure_installed) == "table" then
|
if type(opts.ensure_installed) == "table" then
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,9 @@ function M.lazy_file()
|
||||||
if ft then
|
if ft then
|
||||||
-- Add treesitter highlights and fallback to syntax
|
-- Add treesitter highlights and fallback to syntax
|
||||||
local lang = vim.treesitter.language.get_lang(ft)
|
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
|
if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then
|
||||||
vim.bo[event.buf].syntax = ft
|
vim.bo[event.buf].syntax = ft
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue