Last active
November 27, 2017 00:57
-
-
Save bramswenson/7a476df2c7e670ecf3d525bd9f25e969 to your computer and use it in GitHub Desktop.
Syntax highlighting for markdown. I mean Idyll.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vim syntax file | |
" Language: Idyll | |
" Maintainer: Ricky Reusser <[email protected]> | |
" Filenames: *.idl | |
" Last Change: 2017 May 27 | |
if exists("b:current_syntax") | |
finish | |
endif | |
if !exists('main_syntax') | |
let main_syntax = 'idyll' | |
endif | |
runtime! syntax/html.vim | |
unlet! b:current_syntax | |
if !exists('g:idyll_fenced_languages') | |
let g:idyll_fenced_languages = [] | |
endif | |
for s:type in map(copy(g:idyll_fenced_languages),'matchstr(v:val,"[^=]*$")') | |
if s:type =~ '\.' | |
let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') | |
endif | |
exe 'syn include @idyllHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim' | |
unlet! b:current_syntax | |
endfor | |
unlet! s:type | |
syn sync minlines=10 | |
syn case ignore | |
syn match idyllValid '[<>]\c[a-z/$!]\@!' | |
syn match idyllValid '&\%(#\=\w*;\)\@!' | |
syn match idyllLineStart "^[<@]\@!" nextgroup=@idyllBlock,htmlSpecialChar | |
syn cluster idyllBlock contains=idyllH1,idyllH2,idyllH3,idyllH4,idyllH5,idyllH6,idyllBlockquote,idyllListMarker,idyllOrderedListMarker,idyllCodeBlock,idyllRule | |
syn cluster idyllInline contains=idyllLineBreak,idyllLinkText,idyllItalic,idyllBold,idyllCode,idyllEscape,@htmlTop,idyllError | |
syn match idyllH1 "^.\+\n=\+$" contained contains=@idyllInline,idyllHeadingRule,idyllAutomaticLink | |
syn match idyllH2 "^.\+\n-\+$" contained contains=@idyllInline,idyllHeadingRule,idyllAutomaticLink | |
syn match idyllHeadingRule "^[=-]\+$" contained | |
syn region idyllH1 matchgroup=idyllHeadingDelimiter start="##\@!" end="#*\s*$" keepend oneline contains=@idyllInline,idyllAutomaticLink contained | |
syn region idyllH2 matchgroup=idyllHeadingDelimiter start="###\@!" end="#*\s*$" keepend oneline contains=@idyllInline,idyllAutomaticLink contained | |
syn region idyllH3 matchgroup=idyllHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@idyllInline,idyllAutomaticLink contained | |
syn region idyllH4 matchgroup=idyllHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@idyllInline,idyllAutomaticLink contained | |
syn region idyllH5 matchgroup=idyllHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@idyllInline,idyllAutomaticLink contained | |
syn region idyllH6 matchgroup=idyllHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@idyllInline,idyllAutomaticLink contained | |
syn match idyllBlockquote ">\%(\s\|$\)" contained nextgroup=@idyllBlock | |
syn region idyllCodeBlock start=" \|\t" end="$" contained | |
"TODO: real nesting | |
syn match idyllListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained | |
syn match idyllOrderedListMarker "\%(\t\| \{0,4}\)\<\d\+\.\%(\s\+\S\)\@=" contained | |
syn match idyllRule "\* *\* *\*[ *]*$" contained | |
syn match idyllRule "- *- *-[ -]*$" contained | |
syn match idyllLineBreak " \{2,\}$" | |
syn region idyllIdDeclaration matchgroup=idyllLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=idyllUrl skipwhite | |
syn match idyllUrl "\S\+" nextgroup=idyllUrlTitle skipwhite contained | |
syn region idyllUrl matchgroup=idyllUrlDelimiter start="<" end=">" oneline keepend nextgroup=idyllUrlTitle skipwhite contained | |
syn region idyllUrlTitle matchgroup=idyllUrlTitleDelimiter start=+"+ end=+"+ keepend contained | |
syn region idyllUrlTitle matchgroup=idyllUrlTitleDelimiter start=+'+ end=+'+ keepend contained | |
syn region idyllUrlTitle matchgroup=idyllUrlTitleDelimiter start=+(+ end=+)+ keepend contained | |
syn region idyllLinkText matchgroup=idyllLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" keepend nextgroup=idyllLink,idyllId skipwhite contains=@idyllInline,idyllLineStart | |
syn region idyllLink matchgroup=idyllLinkDelimiter start="(" end=")" contains=idyllUrl keepend contained | |
syn region idyllId matchgroup=idyllIdDelimiter start="\[" end="\]" keepend contained | |
syn region idyllAutomaticLink matchgroup=idyllUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline | |
" syn region idyllItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=idyllLineStart | |
" syn region idyllItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=idyllLineStart | |
" syn region idyllBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=idyllLineStart,idyllItalic | |
" syn region idyllBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=idyllLineStart,idyllItalic | |
" syn region idyllBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=idyllLineStart | |
" syn region idyllBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=idyllLineStart | |
syn region idyllCode matchgroup=idyllCodeDelimiter start="`" end="`" keepend contains=idyllLineStart | |
syn region idyllCode matchgroup=idyllCodeDelimiter start="`` \=" end=" \=``" keepend contains=idyllLineStart | |
syn region idyllCode matchgroup=idyllCodeDelimiter start="^\s*```.*$" end="^\s*```\ze\s*$" keepend | |
if main_syntax ==# 'idyll' | |
for s:type in g:idyll_fenced_languages | |
exe 'syn region idyllHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=idyllCodeDelimiter start="^\s*```'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@idyllHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') | |
endfor | |
unlet! s:type | |
endif | |
syn match idyllEscape "\\[][\\`*_{}()#+.!-]" | |
syn match idyllError "\w\@<=_\w\@=" | |
hi def link idyllH1 htmlH1 | |
hi def link idyllH2 htmlH2 | |
hi def link idyllH3 htmlH3 | |
hi def link idyllH4 htmlH4 | |
hi def link idyllH5 htmlH5 | |
hi def link idyllH6 htmlH6 | |
hi def link idyllHeadingRule idyllRule | |
hi def link idyllHeadingDelimiter Delimiter | |
hi def link idyllOrderedListMarker idyllListMarker | |
hi def link idyllListMarker htmlTagName | |
hi def link idyllBlockquote Comment | |
hi def link idyllRule PreProc | |
hi def link idyllLinkText htmlLink | |
hi def link idyllIdDeclaration Typedef | |
hi def link idyllId Type | |
hi def link idyllAutomaticLink idyllUrl | |
hi def link idyllUrl Float | |
hi def link idyllUrlTitle String | |
hi def link idyllIdDelimiter idyllLinkDelimiter | |
hi def link idyllUrlDelimiter htmlTag | |
hi def link idyllUrlTitleDelimiter Delimiter | |
" hi def link idyllItalic htmlItalic | |
" hi def link idyllBold htmlBold | |
" hi def link idyllBoldItalic htmlBoldItalic | |
hi def link idyllCodeDelimiter Delimiter | |
hi def link idyllEscape Special | |
hi def link idyllError Error | |
let b:current_syntax = "idyll" | |
if main_syntax ==# 'idyll' | |
unlet main_syntax | |
endif | |
" vim:set sw=2: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment