X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/20704d86a0ae043664f3facca84a61eded05de6e..291fa48a67c77ced79a33db8fe9d71dfe04004ac:/after/ftplugin/mkd.vim?ds=sidebyside diff --git a/after/ftplugin/mkd.vim b/after/ftplugin/mkd.vim index f04ae2b..ed78895 100644 --- a/after/ftplugin/mkd.vim +++ b/after/ftplugin/mkd.vim @@ -7,8 +7,8 @@ " original version from Steve Losh's gist: https://gist.github.com/1038710 func! Foldexpr_markdown(lnum) - if (a:lnum == 0) - let l0 = getline(a:lnum) + if (a:lnum == 1) + let l0 = '' else let l0 = getline(a:lnum-1) endif @@ -29,23 +29,23 @@ func! Foldexpr_markdown(lnum) elseif l0 =~ '^#' " current line starts with hashes return '>'.matchend(l0, '^#\+') - elseif a:lnum == 1 - " fold any 'preamble' - return '>1' else " keep previous foldlevel return '=' endif endfunc -setlocal foldexpr=Foldexpr_markdown(v:lnum) -setlocal foldmethod=expr -"---------- everything after this is optional ----------------------- -" change the following fold options to your liking -" see ':help fold-options' for more -setlocal foldenable -setlocal foldlevel=0 -setlocal foldcolumn=0 -set foldmethod=expr -set foldopen-=search +if !exists("g:vim_markdown_folding_disabled") + setlocal foldexpr=Foldexpr_markdown(v:lnum) + setlocal foldmethod=expr + + "---------- everything after this is optional ----------------------- + " change the following fold options to your liking + " see ':help fold-options' for more + setlocal foldenable + setlocal foldlevel=0 + setlocal foldcolumn=0 + set foldmethod=expr + set foldopen-=search +endif