diff options
author | rsteube | 2023-10-21 12:15:18 +0000 |
---|---|---|
committer | GitHub | 2023-10-21 12:15:18 +0000 |
commit | 764715a6c069754b852ed9e8d98aaf7efd88abe6 (patch) | |
tree | a6a774c816423e0f3c9d8a5a8bd0cdcd43c702ea /runtime | |
parent | 8d44459c6ab1e1c7f26c8da4e6afafdb439c8450 (diff) |
languages: add templ (#8540)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/queries/templ/highlights.scm | 99 | ||||
-rw-r--r-- | runtime/queries/templ/injections.scm | 4 |
2 files changed, 103 insertions, 0 deletions
diff --git a/runtime/queries/templ/highlights.scm b/runtime/queries/templ/highlights.scm new file mode 100644 index 00000000..e5b2ede0 --- /dev/null +++ b/runtime/queries/templ/highlights.scm @@ -0,0 +1,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 diff --git a/runtime/queries/templ/injections.scm b/runtime/queries/templ/injections.scm new file mode 100644 index 00000000..4dd5a630 --- /dev/null +++ b/runtime/queries/templ/injections.scm @@ -0,0 +1,4 @@ +((script_block_text) @injection.content (#set! injection.language "javascript")) +((script_element_text) @injection.content (#set! injection.language "javascript")) + +((style_element_text) @injection.content (#set! injection.language "css")) |