diff --git a/ftplugin/mmd.vim b/ftplugin/mmd.vim new file mode 100644 index 0000000..d0ef57f --- /dev/null +++ b/ftplugin/mmd.vim @@ -0,0 +1,20 @@ +" VIM ftplugin for mail +" Author: Gautam Iyer +" Created: Tue 25 Feb 2014 04:23:18 PM EST +" Modified: Wed 26 Feb 2014 03:21:59 PM EST + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl tw< fo< com<" + +setl ai tw=78 fo+=n2c fdm=syntax et + +" Set header markers and list markers as comments. +setl com=fb:######,fb:#####,fb:####,fb:###,fb:##,fb:# "Headers +setl com+=b:> " Block quotes +setl com+=fb:*,fb:-,fb:+ " Lists +" fo+=tcql diff --git a/syntax/mmd.vim b/syntax/mmd.vim index 1347072..b62850f 100644 --- a/syntax/mmd.vim +++ b/syntax/mmd.vim @@ -91,11 +91,12 @@ syn match mkdRule /^\s*-\{3,}$/ syn match mkdRule /^\s*\*\{3,5}$/ syn match mkdListItem "^\s*[-*+]\s\+" syn match mkdListItem "^\s*\d\+\.\s\+" -syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ +syn match mkdCode /^\s*\n\%(\%(\s\{4,}\|\t\+\)\%(\%([-*+]\|[0-9]\+\.\)\s\+\)\@!\S.*\n\)\+/ syn match mkdLineBreak / \+$/ syn region mkdCode start=/\\\@/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell +"syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell +syn match mkdBlockquote /^\%(\s*>\)\+/ syn region mkdCode start="]*>" end="" syn region mkdCode start="]*>" end="" @@ -116,26 +117,48 @@ syn region mkdHeaderFold \ start="^\s*\z(#\+\)" \ skip="^\s*\z1#\+" \ end="^\(\s*#\)\@=" - \ fold contains=TOP + \ fold transparent contains=TOP " fold region for references syn region mkdReferenceFold \ start="^" \ end="^" - \ fold contains=TOP + \ fold transparent contains=TOP " fold region for lists syn region mkdListFold \ start="^\z(\s*\)\*\z(\s*\)" \ skip="^\z1 \z2\s*[^#]" \ end="^\(.\)\@=" - \ fold contains=TOP + \ fold transparent contains=TOP + +" Maths highlighting (TeX) +" Accepts either multimarkdown bracket notation or $ notation. +" Allows use of literal dollars if they are escaped (\$). If you +" want literal dollars without escaping, you'll have to comment out +" the texinlinemaths line. +syntax include syntax/tex.vim +syn region mmddisplaymaths matchgroup=mkdMath start="\\\\\[" end="\\\\\]" contains=@texMathZoneGroup +syn region texdisplaymaths matchgroup=mkdMath start="\$\$" end="\$\$" skip="\\\$" contains=@texMathZoneGroup +syn region texdisplaymaths matchgroup=mkdMath start='\\begin{\z(.\{-\}\)}' end='\\end{\z1}' contains=@texMathZoneGroup +syn region mmdinlinemaths matchgroup=mkdMath start="\\\\(" end="\\\\)" contains=@texMathZoneGroup +" inline maths with $ ... $ +" start is a $ not preceded by another $ - \(\$\)\@