Skip to content

Commit

Permalink
merge: use correct bufnr for treesitter detection
Browse files Browse the repository at this point in the history
refer: #2798
  • Loading branch information
lervag committed Oct 3, 2023
2 parents 7d453a6 + f27d79d commit a59a49b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions autoload/vimtex/nvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
" Email: [email protected]
"

function! vimtex#nvim#check_treesitter(...) abort " {{{1
lua <<EOF
local highlighter = require "vim.treesitter.highlighter"
local bufnr = vim.api.nvim_get_current_buf()
if vim.bo[bufnr].syntax == "" and highlighter.active[bufnr] then
vim.fn['vimtex#log#error'](
'Syntax highlighting is controlled by Tree-sitter!'
)
end
EOF
function! vimtex#nvim#check_treesitter(bufnr, ...) abort " {{{1
if empty(getbufvar(a:bufnr, '&syntax')) && luaeval(
\ 'require("vim.treesitter.highlighter").active[_A] ~= nil',
\ a:bufnr
\)
call vimtex#log#error('Syntax highlighting is controlled by Treesitter!')
endif
endfunction

" }}}1
2 changes: 1 addition & 1 deletion ftplugin/tex.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ call vimtex#init()
if has('nvim-0.5')
\ && g:vimtex_syntax_enabled
\ && !g:vimtex_syntax_conceal_disable
call timer_start(1000, 'vimtex#nvim#check_treesitter')
call timer_start(1000, function('vimtex#nvim#check_treesitter', [bufnr()]))
endif

0 comments on commit a59a49b

Please sign in to comment.