commit 20b7be2d1024b6e9eac68e0cb92cf663e95e51ca
parent 0344bfad0fc87d2e256ea2b80de7abd069ba1dd2
Author: Lewis Russell <lewis6991@gmail.com>
Date: Tue, 17 Jan 2023 16:56:23 +0000
fix(treesitter): really restore syntax
- also unset b:ts_highlight on stop()
Fixes: #21836
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua
@@ -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