diff options
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/treesitter.lua | 13 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/highlighter.lua | 9 |
2 files changed, 10 insertions, 12 deletions
diff --git a/runtime/lua/vim/treesitter.lua b/runtime/lua/vim/treesitter.lua index 9c43811e03..5ebccff8f7 100644 --- a/runtime/lua/vim/treesitter.lua +++ b/runtime/lua/vim/treesitter.lua @@ -250,23 +250,22 @@ end --- Can be used in an ftplugin or FileType autocommand --- --- Note: By default, disables regex syntax highlighting, which may be required for some plugins. ---- In this case, add `{ syntax = true }`. +--- In this case, add `vim.bo.syntax = 'on'` after the call to `start`. --- --- Example: --- --- <pre> --- vim.api.nvim_create_autocmd( 'FileType', { pattern = 'tex', --- callback = function(args) ---- vim.treesitter.start(args.buf, 'latex', { syntax = true }) +--- vim.treesitter.start(args.buf, 'latex') +--- vim.bo[args.buf].syntax = 'on' -- only if additional legacy syntax is needed --- end --- }) --- </pre> --- ---@param bufnr number|nil Buffer to be highlighted (default: current buffer) ---@param lang string|nil Language of the parser (default: buffer filetype) ----@param opts table|nil Optional keyword arguments: ---- - `syntax` boolean Run regex syntax highlighting (default false) -function M.start(bufnr, lang, opts) +function M.start(bufnr, lang) bufnr = bufnr or a.nvim_get_current_buf() local parser = M.get_parser(bufnr, lang) @@ -274,10 +273,6 @@ function M.start(bufnr, lang, opts) M.highlighter.new(parser) vim.b[bufnr].ts_highlight = true - - if opts and opts.syntax then - vim.bo[bufnr].syntax = 'on' - end end ---Stop treesitter highlighting for a buffer diff --git a/runtime/lua/vim/treesitter/highlighter.lua b/runtime/lua/vim/treesitter/highlighter.lua index 9e95af98db..1e625eddb8 100644 --- a/runtime/lua/vim/treesitter/highlighter.lua +++ b/runtime/lua/vim/treesitter/highlighter.lua @@ -86,7 +86,7 @@ function TSHighlighter.new(tree, opts) end end - a.nvim_buf_set_option(self.bufnr, 'syntax', '') + vim.bo[self.bufnr].syntax = '' TSHighlighter.active[self.bufnr] = self @@ -95,9 +95,12 @@ function TSHighlighter.new(tree, opts) -- syntax FileType autocmds. Later on we should integrate with the -- `:syntax` and `set syntax=...` machinery properly. if vim.g.syntax_on ~= 1 then - vim.api.nvim_command('runtime! syntax/synload.vim') + vim.cmd.runtime({ 'syntax/synload.vim', bang = true }) end - vim.bo[self.bufnr].spelloptions = 'noplainbuffer' + + a.nvim_buf_call(self.bufnr, function() + vim.opt_local.spelloptions:append('noplainbuffer') + end) self.tree:parse() |