Closed tonyspiff closed 3 years ago
Folding based on expr
is generally very slow in vim.
Note that 'foldenable' only makes all folds folded/unfolded. For that folds have to be detected first, which foldmethod
and foldexpr
are for. And they are turned on or off for asciidoctor filetype with g:asciidoctor_folding
.
PS, there is a plugin that makes folds usable https://github.com/Konfekt/FastFold
'foldenable' 'fen' boolean (default on)
local to window
When off, all folds are open. This option can be used to quickly
switch between showing all text unfolded and viewing the text with
folds (including manually opened or closed folds). It can be toggled
with the |zi| command. The 'foldcolumn' will remain blank when
'foldenable' is off.
This option is set by commands that create a new fold or close a fold.
See |folding|.
If foldenable
is off and "all folds are open" - why would a process spend time in a function called AsciidoctorFold
? What does it have to do if folding is disabled and all folds are open? 🤔
Edit: for future travelers, I fixed my particular issue with let g:easy_align_bypass_fold = 1
Folds are open, but they have to be found first. Vim runs foldexpr if foldmethod is expr.
You can try to use OptionSet
autocommand to set foldexpr and foldmethod depending on foldenable
(didn't test it):
func! AdocFoldEnable()
if &filetype != 'asciidoctor'
return
endif
if &foldenable
set foldmethod=expr
else
set foldmethod=manual
endif
endfunc
augroup FoldEnable | au!
au OptionSet foldenable call AdocFoldEnable()
augroup END
I run vim-easy-align to help keep my ever growing tables neat and this have been taking longer and longer. I finally had the time to do some profiling and at first glance the issue is related the fold function.
My relevant global settings are:
Disabling
g:asciidoctor_folding
solves the performance issue. As you can notice I havenofoldenable
on my startup and that doesn't help (probablyAsciidoctorFold
should check for that too).