CLI config/dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
6.4 KiB

  1. " Vim syntax file
  2. " Language: Pug
  3. " Maintainer: Joshua Borton
  4. " Credits: Tim Pope
  5. " Filenames: *.pug
  6. if exists("b:current_syntax")
  7. finish
  8. endif
  9. if !exists("main_syntax")
  10. let main_syntax = 'pug'
  11. endif
  12. silent! syntax include @htmlCoffeescript syntax/coffee.vim
  13. unlet! b:current_syntax
  14. silent! syntax include @htmlStylus syntax/stylus.vim
  15. unlet! b:current_syntax
  16. silent! syntax include @htmlCss syntax/css.vim
  17. unlet! b:current_syntax
  18. silent! syntax include @htmlMarkdown syntax/markdown.vim
  19. unlet! b:current_syntax
  20. syn case match
  21. syn region javascriptParenthesisBlock start="(" end=")" contains=@htmlJavascript contained keepend
  22. syn cluster htmlJavascript add=javascriptParenthesisBlock
  23. syn region pugJavascript matchgroup=pugJavascriptOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
  24. syn region pugJavascript matchgroup=pugJavascriptChar start="-" skip=",\s*$" end="$" contained contains=@htmlJavascript keepend
  25. syn cluster pugTop contains=pugBegin,pugComment,pugHtmlComment,pugJavascript
  26. syn match pugBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=pugTag,pugClassChar,pugIdChar,pugPlainChar,pugJavascript,pugScriptConditional,pugScriptStatement,pugPipedText
  27. syn match pugTag "+\?[[:alnum:]_-]\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@pugComponent
  28. syn cluster pugComponent contains=pugAttributes,pugIdChar,pugBlockExpansionChar,pugClassChar,pugPlainChar,pugJavascript,pugTagBlockChar,pugTagInlineText
  29. syntax keyword pugCommentTodo contained TODO FIXME XXX TBD
  30. syn match pugComment '\(\s\+\|^\)\/\/.*$' contains=pugCommentTodo,@Spell
  31. syn region pugCommentBlock start="\z(\s\+\|^\)\/\/.*$" end="^\%(\z1\s\|\s*$\)\@!" contains=pugCommentTodo,@Spell keepend
  32. syn region pugHtmlConditionalComment start="<!--\%(.*\)>" end="<!\%(.*\)-->" contains=pugCommentTodo,@Spell
  33. syn region pugAngular2 start="(" end=")" contains=htmlEvent
  34. syn region pugJavascriptString start=+"+ skip=+\\\("\|$\)+ end=+"\|$+ contained
  35. syn region pugJavascriptString start=+'+ skip=+\\\('\|$\)+ end=+'\|$+ contained
  36. syn region pugAttributes matchgroup=pugAttributesDelimiter start="(" end=")" contained contains=pugJavascriptString,pugHtmlArg,pugAngular2,htmlArg,htmlEvent,htmlCssDefinition nextgroup=@pugComponent
  37. syn match pugClassChar "\." containedin=htmlTagName nextgroup=pugClass
  38. syn match pugBlockExpansionChar ":\s\+" contained nextgroup=pugTag,pugClassChar,pugIdChar
  39. syn match pugIdChar "#[[{]\@!" contained nextgroup=pugId
  40. syn match pugClass "\%(\w\|-\)\+" contained nextgroup=@pugComponent
  41. syn match pugId "\%(\w\|-\)\+" contained nextgroup=@pugComponent
  42. syn region pugDocType start="^\s*\(!!!\|doctype\)" end="$"
  43. " Unless I'm mistaken, syntax/html.vim requires
  44. " that the = sign be present for these matches.
  45. " This adds the matches back for pug.
  46. syn keyword pugHtmlArg contained href title
  47. syn match pugPlainChar "\\" contained
  48. syn region pugInterpolation matchgroup=pugInterpolationDelimiter start="[#!]{" end="}" contains=@htmlJavascript
  49. syn match pugInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)"
  50. syn match pugTagInlineText "\s.*$" contained contains=pugInterpolation,pugTextInlinePug,@Spell
  51. syn region pugPipedText matchgroup=pugPipeChar start="|" end="$" contained contains=pugInterpolation,pugTextInlinePug nextgroup=pugPipedText skipnl
  52. syn match pugTagBlockChar "\.$" contained nextgroup=pugTagBlockText,pugTagBlockEnd skipnl
  53. syn region pugTagBlockText start="\%(\s*\)\S" end="\ze\n" contained contains=pugInterpolation,pugTextInlinePug,@Spell nextgroup=pugTagBlockText,pugTagBlockEnd skipnl
  54. syn region pugTagBlockEnd start="\s*\S" end="$" contained contains=pugInterpolation,pugTextInlinePug nextgroup=pugBegin skipnl
  55. syn region pugTextInlinePug matchgroup=pugInlineDelimiter start="#\[" end="]" contains=pugTag keepend
  56. syn region pugJavascriptFilter matchgroup=pugFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript
  57. syn region pugMarkdownFilter matchgroup=pugFilter start=/^\z(\s*\):\%(markdown\|marked\)\s*$/ end=/^\%(\z1\s\|\s*$\)\@!/ contains=@htmlMarkdown
  58. syn region pugStylusFilter matchgroup=pugFilter start="^\z(\s*\):stylus\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlStylus
  59. syn region pugPlainFilter matchgroup=pugFilter start="^\z(\s*\):\%(sass\|less\|cdata\)\s*$" end="^\%(\z1\s\|\s*$\)\@!"
  60. syn match pugScriptConditional "^\s*\<\%(if\|else\|else if\|elif\|unless\|while\|until\|case\|when\|default\)\>[?!]\@!"
  61. syn match pugScriptStatement "^\s*\<\%(each\|for\|block\|prepend\|append\|mixin\|extends\|include\)\>[?!]\@!"
  62. syn region pugScriptLoopRegion start="^\s*\(for \)" end="$" contains=pugScriptLoopKeywords
  63. syn keyword pugScriptLoopKeywords for in contained
  64. syn region pugJavascript start="^\z(\s*\)script\%(:\w\+\)\=" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlJavascript,pugJavascriptTag,pugCoffeescriptFilter keepend
  65. syn region pugCoffeescriptFilter matchgroup=pugFilter start="^\z(\s*\):coffee-\?script\s*$" end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCoffeescript contained
  66. syn region pugJavascriptTag contained start="^\z(\s*\)script\%(:\w\+\)\=" end="$" contains=pugBegin,pugTag
  67. syn region pugCssBlock start="^\z(\s*\)style" nextgroup=@pugComponent,pugError end="^\%(\z1\s\|\s*$\)\@!" contains=@htmlCss keepend
  68. syn match pugError "\$" contained
  69. hi def link pugPlainChar Special
  70. hi def link pugScriptConditional PreProc
  71. hi def link pugScriptLoopKeywords PreProc
  72. hi def link pugScriptStatement PreProc
  73. hi def link pugHtmlArg htmlArg
  74. hi def link pugAttributeString String
  75. hi def link pugAttributesDelimiter Identifier
  76. hi def link pugIdChar Special
  77. hi def link pugClassChar Special
  78. hi def link pugBlockExpansionChar Special
  79. hi def link pugPipeChar Special
  80. hi def link pugTagBlockChar Special
  81. hi def link pugId Identifier
  82. hi def link pugClass Type
  83. hi def link pugInterpolationDelimiter Delimiter
  84. hi def link pugInlineDelimiter Delimiter
  85. hi def link pugFilter PreProc
  86. hi def link pugDocType PreProc
  87. hi def link pugCommentTodo Todo
  88. hi def link pugComment Comment
  89. hi def link pugCommentBlock Comment
  90. hi def link pugHtmlConditionalComment pugComment
  91. hi def link pugJavascriptString String
  92. let b:current_syntax = "pug"
  93. if main_syntax == "pug"
  94. unlet main_syntax
  95. endif