All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 if exists("b:did_indent") | finish | endif
4 setlocal indentexpr=GetMarkdownIndent()
8 " Automatically continue blockquote on line break
9 setlocal formatoptions+=r
11 if get(g:, "vim_markdown_auto_insert_bullets", 1)
12 " Do not automatically insert bullets when auto-wrapping with text-width
13 setlocal formatoptions-=c
14 " Accept various markers as bullets
15 setlocal comments+=b:*,b:+,b:-
18 " Only define the function once
19 if exists("*GetMarkdownIndent") | finish | endif
21 function! s:IsMkdCode(lnum)
22 let name = synIDattr(synID(a:lnum, 1, 0), 'name')
23 return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
26 function! s:IsLiStart(line)
27 return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' &&
28 \ a:line =~ '^\s*[*+-] \+'
31 function! s:IsHeaderLine(line)
32 return a:line =~ '^\s*#'
35 function! s:IsBlankLine(line)
39 function! s:PrevNonBlank(lnum)
41 while i > 1 && s:IsBlankLine(getline(i))
47 function GetMarkdownIndent()
48 if v:lnum > 2 && s:IsBlankLine(getline(v:lnum - 1)) && s:IsBlankLine(getline(v:lnum - 2))
51 let list_ind = get(g:, "vim_markdown_new_list_item_indent", 4)
52 " Find a non-blank line above the current line.
53 let lnum = s:PrevNonBlank(v:lnum - 1)
54 " At the start of the file use zero indent.
55 if lnum == 0 | return 0 | endif
56 let ind = indent(lnum)
57 let line = getline(lnum) " Last line
58 let cline = getline(v:lnum) " Current line
60 " Current line is the first line of a list item, do not change indent
62 elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum)
63 " Current line is the header, do not indent
65 elseif s:IsLiStart(line)
69 " Last line is the first line of a list item, increase indent