From 2918519dd2c4e22223533e3f6f4823cf05784fb1 Mon Sep 17 00:00:00 2001 From: Hiroshi Shirosaki Date: Tue, 22 Dec 2015 18:44:31 +0900 Subject: [PATCH] No autoindent in code block Fix #78 --- indent/markdown.vim | 12 ++++++++++-- test/indent.vader | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/indent/markdown.vim b/indent/markdown.vim index 23944f2..3f89b5c 100755 --- a/indent/markdown.vim +++ b/indent/markdown.vim @@ -18,6 +18,10 @@ setlocal comments+=b:> " Only define the function once if exists("*GetMarkdownIndent") | finish | endif +function! s:is_mkdCode(lnum) + return synIDattr(synID(a:lnum, 1, 0), 'name') == 'mkdCode' +endfunction + function! s:is_li_start(line) return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' && \ a:line =~ '^\s*[*+-] \+' @@ -48,8 +52,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 diff --git a/test/indent.vader b/test/indent.vader index 76f4990..3cc5010 100644 --- a/test/indent.vader +++ b/test/indent.vader @@ -1,7 +1,7 @@ Given markdown; * item1 -Do (Insert enter at list end): +Do (insert enter at list end): A\item2 Expect (auto insert * and indent level is same): @@ -13,7 +13,7 @@ Given markdown; Execute: syntax off -Do (Insert enter at list end with syntax off): +Do (insert enter at list end with syntax off): i* item1\item2 Expect (auto insert * and indent level is same): @@ -22,3 +22,15 @@ Expect (auto insert * and indent level is same): Execute: syntax on + +Given markdown; +``` +* item1 + +Do (insert after list items in code block): + jotext + +Expect (no autoindent in code block): + ``` + * item1 + text -- 2.39.2