robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
9701c9dc9f
master
1" Vim syntax file 2" Language: Markdown 3" Maintainer: Tim Pope <https://github.com/tpope/vim-markdown> 4" Filenames: *.markdown 5" Last Change: 2022 Oct 13 6 7if exists ( "b:current_syntax" ) 8finish 9endif 10 11if ! exists ( 'main_syntax' ) 12let main_syntax = 'markdown' 13endif 14 15if has ( 'folding' ) 16let s: foldmethod = & l: foldmethod 17let s: foldtext = & l: foldtext 18endif 19let s: iskeyword = & l: iskeyword 20 21runtime ! syntax/html.vim 22unlet ! b: current_syntax 23 24if ! exists ( 'g:markdown_fenced_languages' ) 25let g: markdown_fenced_languages = [] 26endif 27let s: done_include = {} 28for s: type in map ( copy ( g: markdown_fenced_languages ), 'matchstr(v:val,"[^=]*$")' ) 29if has_key ( s: done_include , matchstr ( s: type , '[^.]*' )) 30continue 31endif 32if s: type =~ '\.' 33let b: { matchstr ( s: type , '[^.]*' )} _subtype = matchstr ( s: type , '\.\zs.*' ) 34endif 35syn case match 36exe 'syn include @markdownHighlight_' . tr ( s: type , '.' , '_' ) . ' syntax/' . matchstr ( s: type , '[^.]*' ) . '.vim' 37unlet ! b: current_syntax 38let s: done_include [ matchstr ( s: type , '[^.]*' )] = 1 39endfor 40unlet ! s: type 41unlet ! s: done_include 42 43syn spell toplevel 44if exists ( 's:foldmethod' ) && s: foldmethod !=# & l: foldmethod 45let & l: foldmethod = s: foldmethod 46unlet s: foldmethod 47endif 48if exists ( 's:foldtext' ) && s: foldtext !=# & l: foldtext 49let & l: foldtext = s: foldtext 50unlet s: foldtext 51endif 52if s: iskeyword !=# & l: iskeyword 53let & l: iskeyword = s: iskeyword 54endif 55unlet s: iskeyword 56 57if ! exists ( 'g:markdown_minlines' ) 58let g: markdown_minlines = 50 59endif 60execute 'syn sync minlines=' . g: markdown_minlines 61syn sync linebreaks= 1 62syn case ignore 63 64syn match markdownValid '[ <> ] \c [ a-z/$! ] \@! 'transparent contains = NONE 65syn match markdownValid '&\%(#\=\w * ;\)\@! 'transparent contains = NONE 66 67syn match markdownLineStart "^ [ <@ ] \@! "nextgroup = @markdownBlock , htmlSpecialChar 68 69syn cluster markdownBlock contains = markdownH1 , markdownH2 , markdownH3 , markdownH4 , markdownH5 , markdownH6 , markdownBlockquote , markdownListMarker , markdownOrderedListMarker , markdownCodeBlock , markdownRule 70syn cluster markdownInline contains = markdownLineBreak , markdownLinkText , markdownItalic , markdownBold , markdownCode , markdownEscape , @htmlTop , markdownError , markdownValid 71 72syn match markdownH1 "^.\+\n=\+$ "contained contains = @markdownInline , markdownHeadingRule , markdownAutomaticLink 73syn match markdownH2 "^.\+\n-\+$ "contained contains = @markdownInline , markdownHeadingRule , markdownAutomaticLink 74 75syn match markdownHeadingRule "^ [ =- ] \+$ "contained 76 77syn region markdownH1 matchgroup = markdownH1Delimiter start = "\{,3}#\s "end = "# * \s * $ "keepend oneline contains = @markdownInline , markdownAutomaticLink contained 78syn region markdownH2 matchgroup = markdownH2Delimiter start = "\{,3}##\s "end = "# * \s * $ "keepend oneline contains = @markdownInline , markdownAutomaticLink contained 79syn region markdownH3 matchgroup = markdownH3Delimiter start = "\{,3}###\s "end = "# * \s * $ "keepend oneline contains = @markdownInline , markdownAutomaticLink contained 80syn region markdownH4 matchgroup = markdownH4Delimiter start = "\{,3}####\s "end = "# * \s * $ "keepend oneline contains = @markdownInline , markdownAutomaticLink contained 81syn region markdownH5 matchgroup = markdownH5Delimiter start = "\{,3}#####\s "end = "# * \s * $ "keepend oneline contains = @markdownInline , markdownAutomaticLink contained 82syn region markdownH6 matchgroup = markdownH6Delimiter start = "\{,3}######\s "end = "# * \s * $ "keepend oneline contains = @markdownInline , markdownAutomaticLink contained 83 84syn match markdownBlockquote ">\%(\s\|$\) "contained nextgroup = @markdownBlock 85 86syn region markdownCodeBlock start = "^\n\( \{4,}\|\t\) "end = "^\ze \{,3}\S. * $ "keepend 87 88" TODO: real nesting 89syn match markdownListMarker "\%(\t\| \{0,4\}\) [ -*+ ] \%(\s\+\S\)\@= "contained 90syn match markdownOrderedListMarker "\%(\t\| \{0,4}\)\<\d\+\.\%(\s\+\S\)\@= "contained 91 92syn match markdownRule "\* * \* * \* [ * ] * $ "contained 93syn match markdownRule "- * - * - [ - ] * $ "contained 94 95syn match markdownLineBreak "\{2,\}$ " 96 97syn region markdownIdDeclaration matchgroup = markdownLinkDelimiter start = "^ \{0,3\}!\=\[ "end = "\]: "oneline keepend nextgroup = markdownUrl skipwhite 98syn match markdownUrl "\S\+ "nextgroup = markdownUrlTitle skipwhite contained 99syn region markdownUrl matchgroup = markdownUrlDelimiter start = "< "end = "> "oneline keepend nextgroup = markdownUrlTitle skipwhite contained 100syn region markdownUrlTitle matchgroup = markdownUrlTitleDelimiter start = +" +end = +" +keepend contained 101syn region markdownUrlTitle matchgroup = markdownUrlTitleDelimiter start = +' +end = +' +keepend contained 102syn region markdownUrlTitle matchgroup = markdownUrlTitleDelimiter start = +( +end = +) +keepend contained 103 104syn region markdownLinkText matchgroup = markdownLinkTextDelimiter start = "!\=\[\%(\_ [ ^ ][] * \%(\[\_ [ ^ ][] * \]\_ [ ^ ][] * \) * ]\%( \= [ [( ] \)\)\@= "end = "\]\%( \= [ [( ] \)\@= "nextgroup = markdownLink , markdownId skipwhite contains = @markdownInline , markdownLineStart 105syn region markdownLink matchgroup = markdownLinkDelimiter start = "( "end = ") "contains = markdownUrl keepend contained 106syn region markdownId matchgroup = markdownIdDelimiter start = "\[ "end = "\] "keepend contained 107syn region markdownAutomaticLink matchgroup = markdownUrlDelimiter start = "<\%(\w\+:\| [ [:alnum: ] _+-]\+@\)\@= "end = "> "keepend oneline 108 109let s: concealends = '' 110if has ( 'conceal' ) && get ( g:, 'markdown_syntax_conceal' , 1 ) == 1 111let s: concealends = ' concealends' 112endif 113exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\*\S\@=" end="\S\@<=\*\|^$" skip="\\\*" contains=markdownLineStart,@Spell' . s: concealends 114exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\w\@<!_\S\@=" end="\S\@<=_\w\@!\|^$" skip="\\_" contains=markdownLineStart,@Spell' . s: concealends 115exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\*\*\S\@=" end="\S\@<=\*\*\|^$" skip="\\\*" contains=markdownLineStart,markdownItalic,@Spell' . s: concealends 116exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\w\@<!__\S\@=" end="\S\@<=__\w\@!\|^$" skip="\\_" contains=markdownLineStart,markdownItalic,@Spell' . s: concealends 117exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\*\*\*\S\@=" end="\S\@<=\*\*\*\|^$" skip="\\\*" contains=markdownLineStart,@Spell' . s: concealends 118exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\w\@<!___\S\@=" end="\S\@<=___\w\@!\|^$" skip="\\_" contains=markdownLineStart,@Spell' . s: concealends 119exe 'syn region markdownStrike matchgroup=markdownStrikeDelimiter start="\~\~\S\@=" end="\S\@<=\~\~\|^$" contains=markdownLineStart,@Spell' . s: concealends 120 121syn region markdownCode matchgroup = markdownCodeDelimiter start = "` "end = "` "keepend contains = markdownLineStart 122syn region markdownCode matchgroup = markdownCodeDelimiter start = "`` \= "end = "\=`` "keepend contains = markdownLineStart 123syn region markdownCodeBlock matchgroup = markdownCodeDelimiter start = "^\s * \z(`\{3,\}\). * $ "end = "^\s * \z1\ze\s * $ "keepend 124syn region markdownCodeBlock matchgroup = markdownCodeDelimiter start = "^\s * \z(\~\{3,\}\). * $ "end = "^\s * \z1\ze\s * $ "keepend 125 126syn match markdownFootnote "\[^ [ ^\] ] \+\] " 127syn match markdownFootnoteDefinition "^\[^ [ ^\] ] \+\]: " 128 129let s: done_include = {} 130for s: type in g: markdown_fenced_languages 131if has_key ( s: done_include , matchstr ( s: type , '[^.]*' )) 132continue 133endif 134exe 'syn region markdownHighlight_' . substitute ( matchstr ( s: type , '[^=]*$' ), '\..*' , '' , '' ) . ' matchgroup=markdownCodeDelimiter start="^\s*\z(`\{3,\}\)\s*\%({.\{-}\.\)\=' . matchstr ( s: type , '[^=]*' ) . '}\=\S\@!.*$" end="^\s*\z1\ze\s*$" keepend contains=@markdownHighlight_' . tr ( matchstr ( s: type , '[^=]*$' ), '.' , '_' ) . s: concealends 135exe 'syn region markdownHighlight_' . substitute ( matchstr ( s: type , '[^=]*$' ), '\..*' , '' , '' ) . ' matchgroup=markdownCodeDelimiter start="^\s*\z(\~\{3,\}\)\s*\%({.\{-}\.\)\=' . matchstr ( s: type , '[^=]*' ) . '}\=\S\@!.*$" end="^\s*\z1\ze\s*$" keepend contains=@markdownHighlight_' . tr ( matchstr ( s: type , '[^=]*$' ), '.' , '_' ) . s: concealends 136let s: done_include [ matchstr ( s: type , '[^.]*' )] = 1 137endfor 138unlet ! s: type 139unlet ! s: done_include 140 141if get ( b:, 'markdown_yaml_head' , get ( g:, 'markdown_yaml_head' , main_syntax ==# 'markdown' )) 142syn include @markdownYamlTop syntax/yaml.vim 143unlet ! b: current_syntax 144syn region markdownYamlHead start = "\%^---$ "end = "^\%(---\|\.\.\.\)\s * $ "keepend contains = @markdownYamlTop , @Spell 145endif 146 147syn match markdownEscape "\\ [][ \\`*_{}()<>#+.!- ] " 148syn match markdownError "\w\@<=_\w\@= " 149 150hi def link markdownH1 htmlH1 151hi def link markdownH2 htmlH2 152hi def link markdownH3 htmlH3 153hi def link markdownH4 htmlH4 154hi def link markdownH5 htmlH5 155hi def link markdownH6 htmlH6 156hi def link markdownHeadingRule markdownRule 157hi def link markdownH1Delimiter markdownHeadingDelimiter 158hi def link markdownH2Delimiter markdownHeadingDelimiter 159hi def link markdownH3Delimiter markdownHeadingDelimiter 160hi def link markdownH4Delimiter markdownHeadingDelimiter 161hi def link markdownH5Delimiter markdownHeadingDelimiter 162hi def link markdownH6Delimiter markdownHeadingDelimiter 163hi def link markdownHeadingDelimiter Delimiter 164hi def link markdownOrderedListMarker markdownListMarker 165hi def link markdownListMarker htmlTagName 166hi def link markdownBlockquote Comment 167hi def link markdownRule PreProc 168 169hi def link markdownFootnote Typedef 170hi def link markdownFootnoteDefinition Typedef 171 172hi def link markdownLinkText htmlLink 173hi def link markdownIdDeclaration Typedef 174hi def link markdownId Type 175hi def link markdownAutomaticLink markdownUrl 176hi def link markdownUrl Float 177hi def link markdownUrlTitle String 178hi def link markdownIdDelimiter markdownLinkDelimiter 179hi def link markdownUrlDelimiter htmlTag 180hi def link markdownUrlTitleDelimiter Delimiter 181 182hi def link markdownItalic htmlItalic 183hi def link markdownItalicDelimiter markdownItalic 184hi def link markdownBold htmlBold 185hi def link markdownBoldDelimiter markdownBold 186hi def link markdownBoldItalic htmlBoldItalic 187hi def link markdownBoldItalicDelimiter markdownBoldItalic 188hi def link markdownStrike htmlStrike 189hi def link markdownStrikeDelimiter markdownStrike 190hi def link markdownCodeDelimiter Delimiter 191 192hi def link markdownEscape Special 193hi def link markdownError Error 194 195let b: current_syntax = "markdown" 196if main_syntax ==# 'markdown' 197unlet main_syntax 198endif 199 200" vim:set sw=2: