X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/642730fccce7e78c995389f3c430747d266efa96..51d98df7639dda404c5fe4c154716fdf81b1899a:/indent/markdown.vim diff --git a/indent/markdown.vim b/indent/markdown.vim index 23944f2..b38a37c 100755 --- a/indent/markdown.vim +++ b/indent/markdown.vim @@ -18,6 +18,11 @@ setlocal comments+=b:> " Only define the function once if exists("*GetMarkdownIndent") | finish | endif +function! s:is_mkdCode(lnum) + let name = synIDattr(synID(a:lnum, 1, 0), 'name') + return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)') +endfunction + function! s:is_li_start(line) return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' && \ a:line =~ '^\s*[*+-] \+' @@ -36,6 +41,9 @@ function! s:prevnonblank(lnum) endfunction function GetMarkdownIndent() + if v:lnum > 2 && s:is_blank_line(getline(v:lnum - 1)) && s:is_blank_line(getline(v:lnum - 2)) + return 0 + endif let list_ind = 4 " Find a non-blank line above the current line. let lnum = prevnonblank(v:lnum - 1) @@ -48,8 +56,12 @@ function GetMarkdownIndent() " Current line is the first line of a list item, do not change indent return indent(v:lnum) elseif s:is_li_start(line) - " Last line is the first line of a list item, increase indent - return ind + list_ind + if s:is_mkdCode(lnum) + return ind + else + " Last line is the first line of a list item, increase indent + return ind + list_ind + end else return ind endif