mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(treesitter): recalculate folds on VimEnter #32240
**Problem:** In the case where the user sets the treesitter foldexpr upon startup in their `init.lua`, the fold info will be calculated before the parser has been loaded in, meaning folds will be properly calculated until edits or `:e`. **Solution:** Refresh fold information upon `VimEnter` as a sanity check to ensure that a parser really doesn't exist before always returning `'0'` in the foldexpr.
This commit is contained in:
@ -380,7 +380,7 @@ function M.foldexpr(lnum)
|
||||
|
||||
if not foldinfos[bufnr] then
|
||||
foldinfos[bufnr] = FoldInfo.new(bufnr)
|
||||
api.nvim_create_autocmd('BufUnload', {
|
||||
api.nvim_create_autocmd({ 'BufUnload', 'VimEnter' }, {
|
||||
buffer = bufnr,
|
||||
once = true,
|
||||
callback = function()
|
||||
|
Reference in New Issue
Block a user