mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
perf(image): async treesitter parsing for images
This commit is contained in:
parent
453333530b
commit
e55ae37beb
1 changed files with 31 additions and 33 deletions
|
@ -84,9 +84,6 @@ M.transforms = {
|
|||
end,
|
||||
}
|
||||
|
||||
---@diagnostic disable-next-line: invisible
|
||||
M.TS_ASYNC = (vim.treesitter.languagetree or {})._async_parse ~= nil
|
||||
|
||||
local hover ---@type snacks.image.Hover?
|
||||
local uv = vim.uv or vim.loop
|
||||
local dir_cache = {} ---@type table<string, boolean>
|
||||
|
@ -221,7 +218,7 @@ function M.find(buf, cb, opts)
|
|||
end
|
||||
opts = opts or {}
|
||||
local from, to = opts.from, opts.to
|
||||
parser:parse(from and to and { from, to } or true)
|
||||
Snacks.util.parse(parser, from and to and { from, to } or true, function()
|
||||
local ret = {} ---@type snacks.image.match[]
|
||||
parser:for_each_tree(function(tstree, tree)
|
||||
if not tstree then
|
||||
|
@ -253,6 +250,7 @@ function M.find(buf, cb, opts)
|
|||
end
|
||||
end)
|
||||
cb(ret)
|
||||
end)
|
||||
end
|
||||
|
||||
---@param ctx snacks.image.ctx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue