Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ftplugin/mmd.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
" VIM ftplugin for mail
" Author: Gautam Iyer <gautam@math.uchicago.edu>
" 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
49 changes: 41 additions & 8 deletions syntax/mmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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=/\\\@<!`/
syn region mkdCode start=/\s*``[^`]*/ end=/[^`]*``\s*/
syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell
"syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell
syn match mkdBlockquote /^\%(\s*>\)\+/
syn region mkdCode start="<pre[^>]*>" end="</pre>"
syn region mkdCode start="<code[^>]*>" end="</code>"

Expand All @@ -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="^<!--\z(\S*\)-->"
\ end="^<!--END\z1-->"
\ 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 $ - \(\$\)\@<!\$
" and not preceded by a \ (concat) - \(\$\)\@<!\&\(\\\)\@<!\$
" and not followed by another $ - \$\(\$\)\@!
" ending in a $ not preceded by a \ - \((\$\)\@<!\$
" skipping any \$ - \\\$
" see :help \@<! for more
syn region texinlinemaths matchgroup=mkdMath start="\(\$\)\@<!\&\(\\\)\@<!\$\(\$\)\@!" end="\(\$\)\@<!\$" skip="\\\$" contains=@texMathZoneGroup
" restriction is that you can't have something like \$$maths$ - there
" has to be a space after all of the \$ (literal $)

" Also match \eqref{..} as tex commands
syn match mkdTeXCommand '\\eqref{.\{-\}}' contains=mkdEqRef
syn match mkdEqRef '{\zs.\{-\}\ze}' contained


syn sync fromstart
setlocal foldmethod=syntax



"highlighting for Markdown groups
HtmlHiLink mkdString String
Expand Down Expand Up @@ -164,6 +187,16 @@ HtmlHiLink mkdLinkAttrib Function

HtmlHiLink mkdDelimiter Delimiter

HtmlHiLink mkdMath SpecialComment
HtmlHiLink mmddisplaymaths mkdMath
HtmlHiLink texdisplaymaths mkdMath
HtmlHiLink texinlinemaths mkdMath
HtmlHiLink mmdinlinemaths mkdMath

HtmlHiLink mkdTeXCommand Statement
HtmlHiLink mkdEqRef SpecialComment


let b:current_syntax = "mmd"

delcommand HtmlHiLink
Expand Down