1
0
Fork 0
dot/.config/nvim/syntax/markdown.vim

113 lines
4.7 KiB
VimL
Raw Normal View History

2024-01-27 21:12:38 +01:00
" Vim syntax file
" Language: Markdown
" Maintainer: urosm <urosm@kompot.si>
2024-02-14 15:13:12 +01:00
" Last Change: 2024 Feb 14
2024-01-27 21:12:38 +01:00
if exists("b:current_syntax")
finish
endif
syntax spell toplevel
2024-02-11 10:25:16 +01:00
" emphasis
2024-02-14 15:13:12 +01:00
syn region markdownItalic matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\*\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell
syn region markdownItalic matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@1<=_\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell
2024-02-11 10:25:16 +01:00
" bold
2024-02-14 15:13:12 +01:00
syn region markdownBold matchgroup=markdownDelimiter start=/\(\\\@<!\*\)\{2}/ end=/\(\\\@<!\*\)\{2}/ contains=@Spell
syn region markdownBold matchgroup=markdownDelimiter start=/__/ end=/__/ contains=@Spell
2024-02-11 10:25:16 +01:00
" bold italic
2024-02-14 15:13:12 +01:00
syn region markdownBoldItalic matchgroup=markdownDelimiter start=/\*\{3}\(\S[^*]*\(\*\S\|\n[^*]*\*\S\)\)\@=/ end=/\S\@<=\*\{3}/ contains=@Spell
syn region markdownBoldItalic matchgroup=markdownDelimiter start=/\(___\)\S\@=/ end=/\S\@<=___/ contains=@Spell
syn region markdownBoldInItalic matchgroup=markdownDelimiter start=/\*\*/ end=/\*\*/ contained containedin=markdownItalic contains=@Spell
syn region markdownBoldInItalic matchgroup=markdownDelimiter start=/__/ end=/__/ contained containedin=markdownItalic contains=@Spell
2024-02-11 10:25:16 +01:00
hi def link markdownBoldInItalic markdownBoldItalic
2024-02-14 15:13:12 +01:00
syn region markdownItalicInBold matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=\*\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=markdownBold contains=@Spell
syn region markdownItalicInBold matchgroup=markdownDelimiter start=/\\\@<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=_\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=markdownBold contains=@Spell
2024-02-11 10:25:16 +01:00
hi def link markdownItalicInBold markdownBoldItalic
2024-01-27 21:12:38 +01:00
" link
2024-02-14 15:13:12 +01:00
syn match markdownLink /!\=\[\_.\{-}\](\_.\{-})/ contains=markdownLinkLabel,markdownLinkURL
syn match markdownLinkLabel /\[\zs.*\ze\]/ contained
2024-01-27 21:12:38 +01:00
hi def link markdownLinkLabel markdownLabel
2024-02-14 15:13:12 +01:00
syn match markdownLinkURL /.*(\zs.*\ze)/ contained
hi def link markdownLinkURL markdownUnderlined
2024-01-27 21:12:38 +01:00
" automatic link
2024-02-14 15:13:12 +01:00
syn match markdownAutomaticLink /<\(https\{0,1}.\{-}\|[A-Za-z0-9!#$%&'*+\-/=?^_`{|}~.]\{-}@[A-Za-z0-9\-]\{-}\.\w\{-}\)>/
2024-01-27 21:12:38 +01:00
hi def link markdownAutomaticLink markdownUnderlined
" wikilink
2024-02-14 15:13:12 +01:00
" NOTE: update to support newlines in titles
syn match markdownWikilink /\[\[.*\]\]/ contains=markdownWikilinkLabel,markdownWikilinkURL
syn match markdownWikilinkLabel /\[\[\zs.\{-}\ze|.*\]\]/ contained
2024-01-27 21:12:38 +01:00
hi def link markdownWikilinkLabel markdownLabel
2024-02-14 15:13:12 +01:00
syn match markdownWikilinkURL /\%(\[\[\||\)\zs[^|]*\ze\]\]/ contained
2024-01-27 21:12:38 +01:00
hi def link markdownWikilinkURL markdownUnderlined
2024-02-14 15:13:12 +01:00
" footnote reference
syn match markdownFootnoteReference /\[\zs\^.\{-}\ze\]/
hi def link markdownFootnoteReference markdownLabel
2024-01-27 21:12:38 +01:00
2024-02-14 15:13:12 +01:00
" reference key
syn match markdownReferenceKey /@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&-+?<>~\/]*/
hi def link markdownReferenceKey markdownLabel
2024-01-27 21:12:38 +01:00
2024-02-14 15:13:12 +01:00
" html comment
syn region markdownHTMLcomment start=/<!--/ end=/-->/ keepend contains=@Spell
hi def link markdownHTMLcomment markdownComment
2024-01-27 21:12:38 +01:00
" yaml
syn include @YAML syntax/yaml.vim
unlet! b:current_syntax
syn region markdownYAMLHeader start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=@YAML containedin=TOP
2024-02-14 15:13:12 +01:00
" styling
2024-01-27 21:12:38 +01:00
hi def link markdownComment Comment
hi def link markdownConstant Constant
hi def link markdownString String
hi def link markdownCharacter Character
hi def link markdownNumber Number
hi def link markdownBoolean Boolean
hi def link markdownFloat Float
hi def link markdownIdentifier Identifier
hi def link markdownFunction Function
hi def link markdownStatement Statement
hi def link markdownConditional Conditional
hi def link markdownRepeat Repeat
hi def link markdownLabel Label
hi def link markdownOperator Operator
hi def link markdownKeyword Keyword
hi def link markdownException Exception
hi def link markdownPreProc PreProc
hi def link markdownInclude Include
hi def link markdownDefine Define
hi def link markdownMacro Macro
hi def link markdownPreCondit PreCondit
hi def link markdownType Type
hi def link markdownStorageClass StorageClass
hi def link markdownStructure Structure
hi def link markdownTypedef Typedef
hi def link markdownSpecial Special
hi def link markdownSpecialChar SpecialChar
hi def link markdownTag Tag
hi def link markdownDelimiter Delimiter
hi def link markdownSpecialComment SpecialComment
hi def link markdownDebug Debug
hi def link markdownUnderlined Underlined
hi def link markdownIgnore Ignore
2024-02-11 10:25:16 +01:00
hi def link markdownError Error
2024-01-27 21:12:38 +01:00
2024-02-14 15:13:12 +01:00
hi def link markdownItalic Italic
hi def link markdownBold Bold
hi def link markdownBoldItalic BoldItalic
hi def link markdownStrike Strike
2024-01-27 21:12:38 +01:00
hi def link markdownTitle Title
let b:current_syntax = "markdown"
" vim:set sw=2: