perf(ui): wrap treesitter.foldexpr and cache get_parser during a event loop tick. Fixes #1846

This commit is contained in:
Folke Lemaitre 2023-10-25 14:05:29 +02:00
parent 99598ef7c7
commit a5c9708736
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 39 additions and 1 deletions

View file

@ -82,7 +82,7 @@ end
-- HACK: causes freezes on <= 0.9, so only enable on >= 0.10 for now
if vim.fn.has("nvim-0.10") == 1 then
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
else
vim.opt.foldmethod = "indent"
end