diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-12-14 22:54:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-14 22:54:58 +0000 |
commit | 0887ad1cbb050d2bc6169ad46aa07cf42c90493f (patch) | |
tree | 24d25ed427dc36acc9d1a3c8a92ac5b1da9c0aa5 /runtime/lua/vim/treesitter/highlighter.lua | |
parent | 4a78ed60a3acd3a5694cc34debd4d91bed96195a (diff) | |
download | rneovim-0887ad1cbb050d2bc6169ad46aa07cf42c90493f.tar.gz rneovim-0887ad1cbb050d2bc6169ad46aa07cf42c90493f.tar.bz2 rneovim-0887ad1cbb050d2bc6169ad46aa07cf42c90493f.zip |
fix(ts): check buffer is loaded when restoring options (#21419)
fix(treesitter): check buffer is loaded when restoring options
Also restore spelloptions
Fixes #21416
Diffstat (limited to 'runtime/lua/vim/treesitter/highlighter.lua')
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 99aedf60c5..e99994c8a9 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -89,6 +89,8 @@ function TSHighlighter.new(tree, opts) end self.orig_syntax = vim.bo[self.bufnr].syntax + self.orig_spelloptions = vim.bo[self.bufnr].spelloptions + vim.bo[self.bufnr].syntax = '' vim.b[self.bufnr].ts_highlight = true @@ -117,7 +119,10 @@ function TSHighlighter:destroy() TSHighlighter.active[self.bufnr] = nil end - vim.bo[self.bufnr].syntax = self.orig_syntax + 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 + end end ---@private |