-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathHTML (HEEx).sublime-syntax
More file actions
160 lines (134 loc) · 4.42 KB
/
HTML (HEEx).sublime-syntax
File metadata and controls
160 lines (134 loc) · 4.42 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
%YAML 1.2
---
version: 2
name: HTML (HEEx)
scope: text.html.heex
extends: Packages/HTML/HTML.sublime-syntax
file_extensions: [heex]
authors:
- Aziz Köksal <aziz.koeksal@gmail.com>
- deathaxe <https://github.com/deathaxe>
variables:
heex_tag_char: '[^ \n."''/=<>\x{7F}-\x{9F}]'
heex_tag_name: '[A-Z]{{heex_tag_char}}*'
heex_slot_name: ':[a-zA-Z]{{heex_tag_char}}*'
is_heex_tag_name: (?=[A-Z]|\.[a-z]|:[a-zA-Z])
contexts:
# HTML overrides:
tag-attributes:
- meta_prepend: true
- include: heex-phx-attributes
- include: heex-special-attributes
- include: elixir-embedded
- match: =
scope: invalid.attribute.heex punctuation.separator.key-value.html
push: [tag-generic-attribute-meta, tag-generic-attribute-value]
tag-other:
- meta_prepend: true
- include: heex-tags
- include: HTML (EEx).sublime-syntax#eex-embedded
tag-generic-attribute-value:
- meta_prepend: true
- include: elixir-embedded-pop
tag-class-attribute-value:
- meta_prepend: true
- include: elixir-embedded-pop
tag-event-attribute-value:
- meta_prepend: true
- include: elixir-embedded-pop
tag-href-attribute-value:
- meta_prepend: true
- include: elixir-embedded-pop
tag-id-attribute-value:
- meta_prepend: true
- include: elixir-embedded-pop
tag-style-attribute-value:
- meta_prepend: true
- include: elixir-embedded-pop
# HEEx:
heex-tags:
- match: <{{is_heex_tag_name}}
scope: punctuation.definition.tag.begin.html
push: [heex-begin-tag-content-pop, heex-begin-tag-name-pop]
- match: </{{is_heex_tag_name}}
scope: punctuation.definition.tag.begin.html
push: [heex-end-tag-content-pop, heex-end-tag-name-pop]
- include: elixir-embedded
heex-begin-tag-content-pop:
- meta_scope: meta.tag.other.heex
- include: tag-end-maybe-self-closing
- include: tag-attributes
heex-end-tag-content-pop:
- meta_scope: meta.tag.other.heex
- include: tag-end
- include: else-pop
heex-begin-tag-name-pop:
- match: '{{heex_tag_name}}|{{heex_slot_name}}'
scope: entity.name.tag.begin.heex
- include: heex-tag-function-name-pop
heex-end-tag-name-pop:
- match: '{{heex_tag_name}}|{{heex_slot_name}}'
scope: entity.name.tag.end.heex
- include: heex-tag-function-name-pop
heex-tag-function-name-pop:
- match: ({{heex_tag_char}}+)|(\.)
captures:
1: variable.function.heex
2: punctuation.accessor.dot.heex
- include: immediately-pop
heex-phx-attributes:
# https://hexdocs.pm/phoenix_live_view/bindings.html
- match: |-
(?x) phx- (?>
value-.+?
| click(?:-away)?
| change | submit | feedback-for | disable-with | trigger-action | auto-recover
| blur | focus | window(?:-blur|-focus|-keydown|-keyup)
| key(?:down|up)?
| update | remove
| hook
| debounce | throttle
| track-static
){{attribute_name_break}}
scope: entity.other.attribute-name.heex
push: [tag-generic-attribute-meta, tag-generic-attribute-assignment]
heex-special-attributes:
- match: (:)(if|let)(?=={)
captures:
2: entity.other.attribute-name.heex
push: [tag-generic-attribute-meta, tag-generic-attribute-assignment]
- match: (:)(for)(?=={)
captures:
2: entity.other.attribute-name.heex
push: [tag-generic-attribute-meta, heex-for-attribute-pop]
heex-for-attribute-pop:
- match: (=)(\{)
captures:
1: punctuation.separator.key-value.html
2: punctuation.section.embedded.begin.elixir
set:
- meta_scope: meta.embedded.heex
- meta_content_scope: source.elixir.embedded.html
- match: \}
scope: punctuation.section.embedded.end.elixir
pop: 1
- include: scope:source.elixir#one_arrow_clause_or_argument
apply_prototype: true
# Elixir:
elixir-embedded:
- match: (?={)
push: elixir-embedded-pop
elixir-embedded-pop:
- match: \{
scope: punctuation.section.embedded.begin.elixir
set: elixir-embedded-content-pop
elixir-embedded-content-pop:
- meta_scope: meta.embedded.heex
- meta_content_scope: source.elixir.embedded.html
- include: elixir-embedded-content-nometa-pop
elixir-embedded-content-nometa-pop:
- match: \}
scope: punctuation.section.embedded.end.elixir
pop: 1
- include: scope:source.elixir
apply_prototype: true