aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/highlighter.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-03 07:40:42 +0800
committerGitHub <noreply@github.com>2024-07-03 07:40:42 +0800
commitd413038b4fd71b7a335b6653aa64d2cb6daeac7b (patch)
tree6f6cc9e09bb6a3b4aecdb64d761bc93e5730dd88 /runtime/lua/vim/treesitter/highlighter.lua
parentaec7f1979ada1b34cfb3d8fd33769232d0323ea8 (diff)
downloadrneovim-d413038b4fd71b7a335b6653aa64d2cb6daeac7b.tar.gz
rneovim-d413038b4fd71b7a335b6653aa64d2cb6daeac7b.tar.bz2
rneovim-d413038b4fd71b7a335b6653aa64d2cb6daeac7b.zip
fix(treesitter): ensure syntaxset augroup exists (#29542)
Problem: Error when calling vim.treesitter.start() and vim.treesitter.stop() in init.lua. Solution: Ensure syntaxset augroup exists after loading synload.vim.
Diffstat (limited to 'runtime/lua/vim/treesitter/highlighter.lua')
-rw-r--r--runtime/lua/vim/treesitter/highlighter.lua3
1 files changed, 3 insertions, 0 deletions
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
index 052b839609..a94c408f4e 100644
--- a/runtime/lua/vim/treesitter/highlighter.lua
+++ b/runtime/lua/vim/treesitter/highlighter.lua
@@ -139,8 +139,11 @@ function TSHighlighter.new(tree, opts)
-- but use synload.vim rather than syntax.vim to not enable
-- syntax FileType autocmds. Later on we should integrate with the
-- `:syntax` and `set syntax=...` machinery properly.
+ -- Still need to ensure that syntaxset augroup exists, so that calling :destroy()
+ -- immediately afterwards will not error.
if vim.g.syntax_on ~= 1 then
vim.cmd.runtime({ 'syntax/synload.vim', bang = true })
+ vim.api.nvim_create_augroup('syntaxset', { clear = false })
end
vim._with({ buf = self.bufnr }, function()