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.
This commit is contained in:
zeertzjq
2024-07-03 07:40:42 +08:00
committed by GitHub
parent aec7f1979a
commit d413038b4f
2 changed files with 24 additions and 2 deletions

View File

@@ -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()