From 20b7be2d1024b6e9eac68e0cb92cf663e95e51ca Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Tue, 17 Jan 2023 16:56:23 +0000 Subject: fix(treesitter): really restore syntax - also unset b:ts_highlight on stop() Fixes: #21836 --- runtime/lua/vim/treesitter/highlighter.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime/lua') diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index e99994c8a9..d77a0d0d03 100644 --- 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 -- cgit