mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 10:01:49 +00:00
feat(treesitter)!: don't parse tree in get_parser() or start()
**Problem:** `vim.treesitter.get_parser()` and `vim.treesitter.start()` both parse the tree before returning it. This is problematic because if this is a sync parse, it will stall the editor on large files. If it is an async parse, the functions return stale trees. **Solution:** Remove this parsing side effect and leave it to the user to parse the returned trees, either synchronously or asynchronously.
This commit is contained in:
@@ -158,6 +158,11 @@ TREESITTER
|
||||
if no languages are explicitly registered.
|
||||
• |vim.treesitter.language.add()| returns `true` if a parser was loaded
|
||||
successfully and `nil,errmsg` otherwise instead of throwing an error.
|
||||
• |vim.treesitter.get_parser()| and |vim.treesitter.start()| no longer parse
|
||||
the tree before returning. Scripts must call |LanguageTree:parse()| explicitly. >lua
|
||||
local p = vim.treesitter.get_parser(0, 'c')
|
||||
p:parse()
|
||||
<
|
||||
|
||||
TUI
|
||||
|
||||
|
||||
@@ -61,8 +61,6 @@ function M._create_parser(bufnr, lang, opts)
|
||||
{ on_bytes = bytes_cb, on_detach = detach_cb, on_reload = reload_cb, preview = true }
|
||||
)
|
||||
|
||||
self:parse(nil, function() end)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -148,8 +148,6 @@ function TSHighlighter.new(tree, opts)
|
||||
vim.opt_local.spelloptions:append('noplainbuffer')
|
||||
end)
|
||||
|
||||
self.tree:parse(nil, function() end)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user