1
0
Fork 0
mirror of synced 2024-11-04 08:28:57 -05:00
ultimate-vim/sources_non_forked/vim-pug/syntax/pug.vim

115 lines
6.6 KiB
VimL
Raw Normal View History

2016-02-20 08:13:10 -05:00
" Vim syntax file
" Language: Pug
" Maintainer: Joshua Borton
" Credits: Tim Pope
" Filenames: *.pug
if exists("b:current_syntax")
finish
endif
if !exists("main_syntax")
let main_syntax = 'pug'
endif
silent! syntax include @htmlCoffeescript syntax/coffee.vim
unlet! b:current_syntax
silent! syntax include @htmlStylus syntax/stylus.vim
unlet! b:current_syntax
silent! syntax include @htmlCss syntax/css.vim
unlet! b:current_syntax
silent! syntax include @htmlMarkdown syntax/markdown.vim
unlet! b:current_syntax
syn case match
syn region javascriptParenthesisBlock start="(" end=")" contains=@htmlJavascript contained keepend
syn cluster htmlJavascript add=javascriptParenthesisBlock
syn region pugJavascript matchgroup=pugJavascriptOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
2019-11-16 10:28:42 -05:00
syn region pugJavascript matchgroup=pugJavascriptChar start="\(^\|\s\)\@<=-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
2016-02-20 08:13:10 -05:00
syn cluster pugTop contains=pugBegin,pugComment,pugHtmlComment,pugJavascript
syn match pugBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=pugTag,pugClassChar,pugIdChar,pugPlainChar,pugJavascript,pugScriptConditional,pugScriptStatement,pugPipedText
2019-03-08 06:04:56 -05:00
syn match pugTag "+\?[[:alnum:]_-]\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName,pugJavascript nextgroup=@pugComponent
2016-02-20 08:13:10 -05:00
syn cluster pugComponent contains=pugAttributes,pugIdChar,pugBlockExpansionChar,pugClassChar,pugPlainChar,pugJavascript,pugTagBlockChar,pugTagInlineText
2019-03-08 06:04:56 -05:00
syn keyword pugCommentTodo contained TODO FIXME XXX TBD
2017-03-14 11:16:07 -04:00
syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo,@Spell
syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo,@Spell keepend
syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->" contains=pugCommentTodo,@Spell
2017-02-11 08:01:38 -05:00
syn region pugAngular2 start="(" end=")" contains=htmlEvent
2017-05-02 08:42:08 -04:00
syn region pugJavascriptString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contained
syn region pugJavascriptString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contained
2019-03-08 06:04:56 -05:00
syn region pugJavascriptString start=+`+ skip=+\\\(`\|$\)+ end=+`\|$+ contains=javascriptInterpolation contained
syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end="\(.\zs)\)\|)" contained contains=pugJavascriptString,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent
2017-02-11 08:01:38 -05:00
syn match pugClassChar "\." containedin=htmlTagName nextgroup=pugClass
2016-02-20 08:13:10 -05:00
syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar
syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId
syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent
syn match pugId "\%(\w\|-\)\+" contained nextgroup=@pugComponent
syn region pugDocType start="^\s*\(!!!\|doctype\)" end="$"
" Unless I'm mistaken, syntax/html.vim requires
" that the = sign be present for these matches.
" This adds the matches back for pug.
syn keyword pugHtmlArg contained href title
syn match pugPlainChar "\\" contained
syn region pugInterpolation matchgroup=pugInterpolationDelimiter start="[#!]{" end="}" contains=@htmlJavascript
syn match pugInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
2017-03-14 11:16:07 -04:00
syn match pugTagInlineText "\s.*$" contained contains=pugInterpolation,pugTextInlinePug,@Spell
2018-09-24 20:40:17 -04:00
syn region pugPipedText matchgroup=pugPipeChar start="|" end="$" contained contains=pugInterpolation,pugTextInlinePug,@Spell nextgroup=pugPipedText skipnl
2016-02-20 08:13:10 -05:00
syn match pugTagBlockChar "\.$" contained nextgroup=pugTagBlockText,pugTagBlockEnd skipnl
2017-03-14 11:16:07 -04:00
syn region pugTagBlockText start="\%(\s*\)\S" end="\ze\n" contained contains=pugInterpolation,pugTextInlinePug,@Spell nextgroup=pugTagBlockText,pugTagBlockEnd skipnl
2016-02-20 08:13:10 -05:00
syn region pugTagBlockEnd start="\s*\S" end="$" contained contains=pugInterpolation,pugTextInlinePug nextgroup=pugBegin skipnl
syn region pugTextInlinePug matchgroup=pugInlineDelimiter start="#\[" end="]" contains=pugTag keepend
syn region pugJavascriptFilter matchgroup=pugFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript
syn region pugMarkdownFilter matchgroup=pugFilter start=/^\z(\s*\):\%(markdown\|marked\)\s*$/ end=/^\%(\z1\s\|\s*$\)\@!/ contains=@htmlMarkdown
syn region pugStylusFilter matchgroup=pugFilter start="^\z(\s*\):stylus\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlStylus
syn region pugPlainFilter matchgroup=pugFilter start="^\z(\s*\):\%(sass\|less\|cdata\)\s*$" end="^\%(\z1\s\|\s*$\)\@!"
syn match pugScriptConditional "^\s*\<\%(if\|else\|else if\|elif\|unless\|while\|until\|case\|when\|default\)\>[?!]\@!"
syn match pugScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!"
2019-03-08 06:04:56 -05:00
syn region pugScriptLoopRegion start="^\s*\(for\|each\)" end="$" contains=pugScriptLoopKeywords
syn keyword pugScriptLoopKeywords contained for each in
2016-02-20 08:13:10 -05:00
2019-03-08 06:04:56 -05:00
syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend
syn region javascriptInterpolation start=/${/ end=/}/ contained
2016-02-20 08:13:10 -05:00
syn region pugCoffeescriptFilter matchgroup=pugFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained
syn region pugJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=pugBegin,pugTag
syn region pugCssBlock start="^\z(\s*\)style" nextgroup=@pugComponent,pugError end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCss keepend
syn match pugError "\$" contained
hi def link pugPlainChar Special
hi def link pugScriptConditional PreProc
hi def link pugScriptLoopKeywords PreProc
hi def link pugScriptStatement PreProc
hi def link pugHtmlArg htmlArg
hi def link pugAttributeString String
hi def link pugAttributesDelimiter Identifier
hi def link pugIdChar Special
hi def link pugClassChar Special
hi def link pugBlockExpansionChar Special
hi def link pugPipeChar Special
hi def link pugTagBlockChar Special
hi def link pugId Identifier
hi def link pugClass Type
hi def link pugInterpolationDelimiter Delimiter
hi def link pugInlineDelimiter Delimiter
hi def link pugFilter PreProc
hi def link pugDocType PreProc
2016-11-09 12:22:55 -05:00
hi def link pugCommentTodo Todo
2016-02-20 08:13:10 -05:00
hi def link pugComment Comment
hi def link pugCommentBlock Comment
hi def link pugHtmlConditionalComment pugComment
2017-05-02 08:42:08 -04:00
hi def link pugJavascriptString String
2019-03-08 06:04:56 -05:00
hi def link javascriptInterpolation Delimiter
2016-02-20 08:13:10 -05:00
let b:current_syntax = "pug"
if main_syntax == "pug"
unlet main_syntax
endif