fix(treesitter): really restore syntax

- also unset b:ts_highlight on stop()

Fixes: #21836
This commit is contained in:
Lewis Russell 2023-01-17 16:56:23 +00:00 committed by GitHub
parent 0344bfad0f
commit 20b7be2d10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,7 +88,6 @@ function TSHighlighter.new(tree, opts)
end
end
self.orig_syntax = vim.bo[self.bufnr].syntax
self.orig_spelloptions = vim.bo[self.bufnr].spelloptions
vim.bo[self.bufnr].syntax = ''
@ -120,8 +119,11 @@ function TSHighlighter:destroy()
end
if vim.api.nvim_buf_is_loaded(self.bufnr) then
vim.bo[self.bufnr].syntax = self.orig_syntax
vim.bo[self.bufnr].spelloptions = self.orig_spelloptions
vim.b[self.bufnr].ts_highlight = nil
if vim.g.syntax_on == 1 then
a.nvim_exec_autocmds('FileType', { group = 'syntaxset', buffer = self.bufnr })
end
end
end