From: Hiroshi Shirosaki Date: Wed, 27 Jan 2016 02:12:58 +0000 (+0900) Subject: No indent hash header after list X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/21d86a45e166a877a9e79c3ca638efe754e37acf?hp=8d3d1132bfd271842f1da6835bc22a9f1efc1012 No indent hash header after list Fix #146 --- diff --git a/indent/markdown.vim b/indent/markdown.vim index 540bc04..faa7629 100755 --- a/indent/markdown.vim +++ b/indent/markdown.vim @@ -28,6 +28,10 @@ function! s:IsLiStart(line) \ a:line =~ '^\s*[*+-] \+' endfunction +function! s:IsHeaderLine(line) + return a:line =~ '^\s*#' +endfunction + function! s:IsBlankLine(line) return a:line =~ '^$' endfunction @@ -55,6 +59,9 @@ function GetMarkdownIndent() if s:IsLiStart(cline) " Current line is the first line of a list item, do not change indent return indent(v:lnum) + elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum) + " Current line is the header, do not indent + return 0 elseif s:IsLiStart(line) if s:IsMkdCode(lnum) return ind diff --git a/test/indent.vader b/test/indent.vader index aabf54f..baa2d34 100644 --- a/test/indent.vader +++ b/test/indent.vader @@ -48,3 +48,16 @@ Expect (no autoindent outside list): ba + +Given markdown; +- a + + # b + +Do (insert header after list): + jjwi# + +Expect (no indent header after list): + - a + + ## b