summaryrefslogtreecommitdiff
path: root/runtime/queries/templ/highlights.scm
blob: e5b2ede016562c1cdb8c56b9df5cc63656c87779 (plain) (blame)
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
(package_identifier) @namespace

(parameter_declaration (identifier) @variable.parameter)
(variadic_parameter_declaration (identifier) @variable.parameter)

(function_declaration
  name: (identifier) @function)

(type_spec name: (type_identifier) @type)
(type_identifier) @type
(field_identifier) @variable.other.member
(identifier) @variable

; Function calls

(call_expression
  function: (identifier) @function)

(call_expression
  function: (selector_expression
    field: (field_identifier) @function))

;
; These are Templ specific
;

(component_declaration
  name: (component_identifier) @function)

(tag_start) @tag
(tag_end) @tag
(self_closing_tag) @tag
(style_element) @tag

(attribute
  name: (attribute_name) @attribute)
(attribute
  value: (quoted_attribute_value) @string)

(element_text) @string.special
(style_element_text) @string.special

(css_property
  name: (css_property_name) @attribute)

(expression) @function.method
(dynamic_class_attribute_value) @function.method

(component_import
  name: (component_identifier) @function)

(component_render) @function

[
  "@"
] @operator

[
  "func"
  "var"
  "const"
  "templ"
  "css"
  "type"
  "struct"
  "range"
  "script"
] @keyword.storage.type

[
  "return"
] @keyword.control.return

[
  "import"
  "package"
] @keyword.control.import

[
  "else"
  "case"
  "switch"
  "if"
  "default"
] @keyword.control.conditional

"for" @keyword.control.repeat

[
  (interpreted_string_literal)
  (raw_string_literal)
  (rune_literal)
] @string

; Comments

(comment) @comment

(element_comment) @comment