robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqMerge pull request #38176 from zeertzjq/vim-99ea2b5f111b954a2

master
7.2 KiB144 linesraw
1" Vim syntax file
2" Language:     Handlebars
3" Maintainer:   Devin Weaver
4" Last Change:  2026 Feb 20
5" Origin:       https://github.com/joukevandermaas/vim-ember-hbs
6" Credits:      Jouke van der Maas
7" License:      MIT
8" The MIT License (MIT)
9"
10" Copyright (c) 2026 Devin Weaver
11" Copyright (c) 2015 Jouke van der Maas
12"
13" Permission is hereby granted, free of charge, to any person obtaining a copy
14" of this software and associated documentation files (the "Software"), to deal
15" in the Software without restriction, including without limitation the rights
16" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17" copies of the Software, and to permit persons to whom the Software is
18" furnished to do so, subject to the following conditions:
19"
20" The above copyright notice and this permission notice shall be included in all
21" copies or substantial portions of the Software.
22"
23" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29" SOFTWARE.
30
31if exists("b:current_syntax")
32  finish
33endif
34
35runtime! syntax/html.vim
36syntax cluster htmlPreproc add=hbsComponent,hbsMustache,hbsUnescaped,hbsMustacheBlock,hbsComment,hbsElseBlock,hbsEscapedMustache
37
38syntax match hbsEscapedMustache "\v\\\{\{"
39
40syntax region hbsComponent matchgroup=hbsComponentStatement start="\v\<\/?:?\a+(\.\a+|::-?\a+)*" end="\v\/?\>" keepend
41syntax region hbsMustache matchgroup=hbsHandles start="\v\{\{" skip="\v\\\}\}" end="\v\}\}" containedin=hbsComponent,hbsString keepend
42syntax region hbsMustacheBlock matchgroup=hbsHandles start="\v\{\{[#/]" skip="\v\\\}\}" end="\v\}\}" keepend
43" modern hbs supports {{else <block>}} where <block> starts a new block
44syntax region hbsElseBlock matchgroup=hbsHandles start="\v\{\{else\ "rs=e-5 skip="\v\\\}\}" end="\v\}\}" keepend
45
46syntax region hbsPencil matchgroup=hbsOperator start="\v\(" end="\v\)" contained containedin=hbsMustache,hbsMustacheBlock,hbsElseBlock,hbsPencil
47
48" identifier is any word inside a mustache or a pencil that is not followed by a = sign (see hbsArg below)
49syntax match hbsIdentifier "\v(\(|\{\{[#/]?)@<!<(\w+)|(\@\w+)>" contained containedin=hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock,hbsStatement
50
51" unescaped are special forms of mustaches that don't have other stuff except for an identifier in it
52syntax region hbsUnescaped matchgroup=hbsUnescapedHandles start="\v\{\{\{" skip="\v\\\}\}\}" end="\v\}\}\}" keepend
53syntax match hbsUnescapedIdentifier "\v(\{\{\{)@<=<\S+>(\}\}\})" contained containedin=hbsUnescaped
54
55syntax match hbsMustacheName "\v(\{\{[#/]?)@<=<\S+>" contained containedin=hbsMustache,hbsMustacheBlock,hbsPencil
56syntax match hbsPencilName "\v(\()@<=<\S+>" contained containedin=hbsMustache,hbsMustacheBlock,hbsPencil
57syntax match hbsBuiltInHelper "\v\(@<=<(query-params|mut|fn|array|hash|get|action|unbound|concat)>" contained containedin=hbsPencil
58syntax match hbsBuiltInHelper "\v(\{\{)@<=<(textarea|mut|fn|array|hash|input|get|action|on|input|unbound)>" contained containedin=hbsMustache
59syntax match hbsBuiltInHelper "\v(\{\{[#/]?)@<=<(component|with|link\-to)>" contained containedin=hbsMustacheBlock,hbsElseBlock
60syntax match hbsBuiltInHelperInElse "\v(\{\{else\ )@<=<(component|link\-to)>" contained containedin=hbsMustacheBlock,hbsElseBlock
61syntax match hbsControlFlow "\v(\{\{)@<=<else>( ?)@=" contained containedin=hbsElseBlock
62syntax match hbsControlFlow "\v\(@<=<(if|unless)>" contained containedin=hbsPencil
63syntax match hbsControlFlow "\v(\{\{)@<=<(debugger|unless|yield|outlet|else)>" contained containedin=hbsMustache
64syntax match hbsControlFlow "\v(\{\{[#/]?)@<=<(with|let|if|each(\-in)?|unless)>" contained containedin=hbsMustacheBlock,hbsElseBlock
65syntax match hbsKeyword "\v\s+as\s+" contained containedin=hbsComponent,hbsMustacheBlock,hbsElseBlock
66syntax region hbsStatement matchgroup=hbsDelimiter start="\v\|" end="\v\|" contained containedin=hbsComponent,hbsMustacheBlock,hbsElseBlock
67
68syntax region hbsString matchgroup=hbsString start=/\v\"/ skip=/\v\\\"/ end=/\v\"/ extend contained containedin=hbsComponent,hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock
69syntax region hbsString matchgroup=hbsString start=/\v\'/ skip=/\v\\\'/ end=/\v\'/ extend contained containedin=hbsComponent,hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock
70syntax match hbsNumber "\v<\d+>" contained containedin=hbsComponent,hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock
71syntax match hbsBool "\v<(true|false)>" contained containedin=hbsComponent,hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock
72syntax match hbsArg "\v(\@\S+|\S+)\=@=" contained containedin=hbsComponent,hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock
73syntax match hbsOperator "\v(\S+)@<=\=" contained containedin=hbsComponent,hbsMustache,hbsMustacheBlock,hbsPencil,hbsElseBlock
74
75syntax region hbsComment start="\v\{\{\!" end="\v\}\}" keepend
76syntax region hbsComment start="\v\{\{\!\-\-" end="\v\-\-\}\}" keepend
77
78" *Comment	any comment
79
80" *Constant	any constant
81"  String		a string constant: "this is a string"
82"  Character	a character constant: 'c', '\n'
83"  Number		a number constant: 234, 0xff
84"  Boolean	a boolean constant: TRUE, false
85"  Float		a floating point constant: 2.3e10
86
87" *Identifier	any variable name
88"  Function	function name (also: methods for classes)
89
90" *Statement	any statement
91"  Conditional	if, then, else, endif, switch, etc.
92"  Repeat		for, do, while, etc.
93"  Label		case, default, etc.
94"  Operator	"sizeof", "+", "*", etc.
95"  Keyword	any other keyword
96"  Exception	try, catch, throw
97
98" *PreProc	generic Preprocessor
99"  Include	preprocessor #include
100"  Define		preprocessor #define
101"  Macro		same as Define
102"  PreCondit	preprocessor #if, #else, #endif, etc.
103
104" *Type		int, long, char, etc.
105"  StorageClass	static, register, volatile, etc.
106"  Structure	struct, union, enum, etc.
107"  Typedef	A typedef
108
109" *Special	any special symbol
110"  SpecialChar	special character in a constant
111"  Tag		you can use CTRL-] on this
112"  Delimiter	character that needs attention
113"  SpecialComment	special things inside a comment
114"  Debug		debugging statements
115
116" *Underlined	text that stands out, HTML links
117
118" *Ignore		left blank, hidden  |hl-Ignore|
119
120" *Error		any erroneous construct
121
122" *Todo		anything that needs extra attention; mostly the
123" 		keywords TODO FIXME and XXX
124
125highlight link hbsBuiltInHelper Function
126highlight link hbsBuiltInHelperInElse Function
127highlight link hbsControlFlow Function
128highlight link hbsKeyword Keyword
129highlight link hbsOperator Operator
130highlight link hbsDelimiter Delimiter
131highlight link hbsMustacheName Statement
132highlight link hbsPencilName Statement
133highlight link hbsIdentifier Identifier
134highlight link hbsString String
135highlight link hbsNumber Special
136highlight link hbsBool Boolean
137highlight link hbsHandles Define
138highlight link hbsComponentStatement Define
139highlight link hbsUnescapedHandles Identifier
140highlight link hbsUnescapedIdentifier Identifier
141highlight link hbsComment Comment
142highlight link hbsArg Type
143
144let b:current_syntax = "handlebars"