Konfekt/FastFold

Question: Best simple markdown foldexpr?

hgvhgv opened this issue · 4 comments

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 (vim-pandoc/vim-pandoc#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.

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 tpope/vim-markdown#154 as well?

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.

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

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