-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTempl.sublime-syntax
92 lines (81 loc) · 2.53 KB
/
Templ.sublime-syntax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
%YAML 1.2
---
# Replaces "https://packagecontrol.io/packages/Templ%20%28go%29"
# https://templ.guide/
# http://www.sublimetext.com/docs/syntax.html
name: Templ
scope: source.go.templ
version: 2
extends: Packages/Go/Go.sublime-syntax
file_extensions:
- templ
contexts:
match-keywords:
- meta_prepend: true
- include: match-keyword-templ
match-keyword-templ:
- match: \btempl\b(?!\s*\.)
scope: keyword.declaration.component.go.templ
push:
- pop-templ-block
- pop-func-parameter-list
- pop-templ-name
pop-templ-name:
- match: '{{ident}}'
scope: entity.name.component.go.templ
pop: 1
- include: pop-before-nonblank
pop-templ-block:
- match: \{
scope: punctuation.section.block.begin.go.templ
set: pop-templ-block-body
- include: pop-before-nonblank
pop-templ-block-body:
- meta_scope: meta.block.go.templ
- match: \}
scope: punctuation.section.block.end.go.templ
pop: 1
- match: (@){{ident}}(?:(\.){{ident}})?
scope: variable.function.event.go.templ
captures:
1: punctuation.definition.variable.go.templ
push:
- pop-templ-block
- pop-arguments-starting-with-type
- include: scope:text.html.go.templ
apply_prototype: true
match-string-templates:
- meta_append: true
# This context is used for interpolation within quoted or unquoted strings.
# Matchs only if closing `}` is found on same line to avoid false positives.
# It clears the `string` scope of the owning context.
- match: ({)(-?)(?=.*?})
captures:
1: punctuation.section.interpolation.begin.go
2: keyword.operator.template.trim.left.go
push:
- pop-now-clear-scope
- match-template-inner
- match-template-function
- match-template-keyword
match-text-templates:
- meta_append: true
# This context is used for interpolation in text or normal content.
# It does not clear scopes of the owning context.
- match: ({)(-?)
captures:
1: punctuation.section.interpolation.begin.go
2: keyword.operator.template.trim.left.go
push:
- match-template-inner
- match-template-function
- match-template-keyword
match-template-inner:
- meta_scope: meta.interpolation.go
- meta_content_scope: source.go.template
- match: (-?)(})
captures:
1: keyword.operator.template.trim.right.go
2: punctuation.section.interpolation.end.go
pop: 1
- include: match-template-expressions