Konfekt / FastFold

Speed up Vim by updating folds only when called-for.
708 stars 24 forks source link

Question: Best simple markdown foldexpr? #62

Closed hgvhgv closed 3 years ago

hgvhgv commented 3 years ago

I use vim-pandoc for my markdown filetype, and generally it works very well. But the folding module is very slow, and even integration with FastFold doesn't help much (https://github.com/vim-pandoc/vim-pandoc/issues/316). It seems like the authors of vim-pandoc don't use folding, so they haven't tested it much (and the code is beyond my pay grade).

I was wondering if anyone here can recommend a simpler foldexpr to use with markdown files? It seems like it might be ideal just to use tpope's foldexpr (https://github.com/tpope/vim-markdown/blob/master/ftplugin/markdown.vim) but I'm not sure the best way to integrate it into my vimrc, as his is written as a ft-plugin and thus better integrates with other plugins (like FastFold). Putting the relevant code from there into my vimrc seemed to work at first, but now I have conflicts between my session folds and the foldexpr folds.

If it bothers you to have queries like this in the issue tracker here, I'm sorry and I'll close. But with vim stuff you often get better responses on github than stackexchange etc.

Konfekt commented 3 years ago

In my vimrc there is

let g:markdown_folding = 1
" See https://github.com/tpope/vim-markdown/issues/154
if v:version <= 802 " && (g:javaScript_fold || g:ruby_fold)
  autocmd vimrc FileType markdown setlocal foldmethod=expr foldexpr=MarkdownFold()
endif

Does this help?

Perhaps you suffered from See https://github.com/tpope/vim-markdown/issues/154 as well?

hgvhgv commented 3 years ago

Thanks! But part of the issue is that tpope's modules don't get loaded because vim-pandoc already sets the filetype (so foldexpr=MarkdownFold() yields nothing). But I just tried moving his folding modules to my own after/ftplugin/markdown.vim file and will see how that works.

Konfekt commented 3 years ago

You could symlink this markdown.vim file to pandoc.vim.

hgvhgv commented 3 years ago

OK thanks for your help! Putting tpop's folding into my after/ftplugin file worked.