From f6654fa0db0e6d950f501cd22df3d0526036709e Mon Sep 17 00:00:00 2001 From: todesking Date: Tue, 8 Apr 2014 01:06:33 +0900 Subject: [PATCH 1/1] Foldmethod: more performance --- after/ftplugin/markdown.vim | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim index 997ab9d..497a5a2 100644 --- a/after/ftplugin/markdown.vim +++ b/after/ftplugin/markdown.vim @@ -16,26 +16,27 @@ func! s:effective_line(lnum) endfunc func! Foldexpr_markdown(lnum) - if (a:lnum == 1) - let l0 = '' - else - let l0 = s:effective_line(a:lnum-1) - endif - - let l1 = s:effective_line(a:lnum) - let l2 = s:effective_line(a:lnum+1) - if l2 =~ '^==\+\s*' " next line is underlined (level 1) return '>1' elseif l2 =~ '^--\+\s*' " next line is underlined (level 2) return '>2' - elseif l1 =~ '^#' + endif + + let l1 = s:effective_line(a:lnum) + if l1 =~ '^#' " don't include the section title in the fold return '-1' - elseif l0 =~ '^#' + endif + + if (a:lnum == 1) + let l0 = '' + else + let l0 = s:effective_line(a:lnum-1) + endif + if l0 =~ '^#' " current line starts with hashes return '>'.matchend(l0, '^#\+') else -- 2.39.5