vimwiki-backup / vimwiki

Automatically exported from code.google.com/p/vimwiki
1 stars 1 forks source link

Foldmethod=expr too slow to be useful #247

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
With folding enabled vimwiki slows down so much it becomes useless.

My suggestion: bring back the old syntax folding based on headers as an option. 
It's such a joy to quickly browse my wiki files with this folding functionality 
enabled.

Temporary quick and dirty changes to get syntax folding for headers to work are 
below.

To syntax/vimwiki.vim add:

execute 'syntax region wikiH1Folding start=/'.g:vimwiki_rxFoldH1Start.
      \ '/ end=/'.g:vimwiki_rxFoldH1End.'/me=s-1 transparent fold'
execute 'syntax region wikiH2Folding start=/'.g:vimwiki_rxFoldH2Start.
      \ '/ end=/'.g:vimwiki_rxFoldH2End.'/me=s-1 transparent fold'
execute 'syntax region wikiH3Folding start=/'.g:vimwiki_rxFoldH3Start.
      \ '/ end=/'.g:vimwiki_rxFoldH3End.'/me=s-1 transparent fold'
execute 'syntax region wikiH4Folding start=/'.g:vimwiki_rxFoldH4Start.
      \ '/ end=/'.g:vimwiki_rxFoldH4End.'/me=s-1 transparent fold'
execute 'syntax region wikiH5Folding start=/'.g:vimwiki_rxFoldH5Start.
      \ '/ end=/'.g:vimwiki_rxFoldH5End.'/me=s-1 transparent fold'
execute 'syntax region wikiH6Folding start=/'.g:vimwiki_rxFoldH6Start.
      \ '/ end=/'.g:vimwiki_rxFoldH6End.'/me=s-1 transparent fold'

And to syntax/vimwiki_default.vim add:

let g:vimwiki_rxFoldH1Start = '^![^!]\+.*'
let g:vimwiki_rxFoldH1End = '^![^!]\+.*'

let g:vimwiki_rxFoldH2Start = '^==[^=]\+.*'
let g:vimwiki_rxFoldH2End = '^==\{,1}[^=]\+.*'

let g:vimwiki_rxFoldH3Start = '^===[^=]\+.*'
let g:vimwiki_rxFoldH3End = '^==\{,2}[^=]\+.*'

let g:vimwiki_rxFoldH4Start = '^====[^=]\+.*'
let g:vimwiki_rxFoldH4End = '^==\{,3}[^=]\+.*'

let g:vimwiki_rxFoldH5Start = '^=====[^=]\+.*'
let g:vimwiki_rxFoldH5End = '^==\{,4}[^=]\+.*'

let g:vimwiki_rxFoldH6Start = '^======[^=]\+.*'
let g:vimwiki_rxFoldH6End = '^==\{,5}[^=]\+.*'

I hope this will help someone else out desperately looking for syntax-based 
folding. Also, Vimwiki rocks. ;)

Original issue reported on code.google.com by pieter.v...@gmail.com on 31 Aug 2011 at 11:08

GoogleCodeExporter commented 9 years ago

Original comment by habamax on 31 Aug 2011 at 11:23

GoogleCodeExporter commented 9 years ago
Can you provide some example files which exhibit an obvious slowdown with 
expression folding enabled?

How would the syntax folding work with the very last section on the page?

Would it work for people who skip some section header levels? 

Also, this syntax based folding does not nest subsections, does it? That might 
not be a welcome change to some people.

Original comment by tpospi...@gmail.com on 13 Jan 2012 at 2:15

GoogleCodeExporter commented 9 years ago

Original comment by tpospi...@gmail.com on 3 Feb 2012 at 4:42

GoogleCodeExporter commented 9 years ago
What about lists folding?

Original comment by habamax on 5 Feb 2012 at 12:43

GoogleCodeExporter commented 9 years ago

Original comment by tpospi...@gmail.com on 27 Mar 2012 at 9:16