-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: detect treesitter in the correct buffer
Problem: Wrong treesitter detection error message when the user enters another buffer right after opening a tex file. Solution: Detect in the buffer in which the ftplugin is loaded.
- Loading branch information
Showing
2 changed files
with
5 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,10 @@ | |
" 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(buf, ...) abort " {{{1 | ||
if empty(getbufvar(a:buf, '&syntax')) && luaeval('require("vim.treesitter.highlighter").active[_A[1]] ~= nil', [a:buf]) | ||
call vimtex#log#error('Syntax highlighting is controlled by Tree-sitter!') | ||
endif | ||
endfunction | ||
|
||
" }}}1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters