Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

typescript: Add highlighting for Angular inline components (#26553)

Sheik Althaffdcacb384917
diff --git a/crates/languages/src/typescript/injections.scm b/crates/languages/src/typescript/injections.scm
index c8bb72bdc59..7affdc5b758 100644
--- a/crates/languages/src/typescript/injections.scm
+++ b/crates/languages/src/typescript/injections.scm
@@ -62,3 +62,40 @@
arguments: (arguments (template_string (string_fragment) @injection.content
(#set! injection.language "graphql")))
)
+
+;; Angular Component template injection
+(call_expression
+ function: [
+ (identifier) @_decorator (#eq? @_decorator "Component")
+ (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
+ ]
+ arguments: (arguments (object
+ (pair
+ key: (property_identifier) @_prop (#eq? @_prop "template")
+ value: [
+ (string) @injection.content
+ (template_string) @injection.content
+ (template_string (string_fragment) @injection.content)
+ ]
+ )))
+ (#set! injection.language "angular"))
+
+;; Angular Component styles injection
+(call_expression
+ function: [
+ (identifier) @_decorator (#eq? @_decorator "Component")
+ (member_expression property: (property_identifier) @_decorator (#eq? @_decorator "Component"))
+ ]
+ arguments: (arguments (object
+ (pair
+ key: (property_identifier) @_prop (#eq? @_prop "styles")
+ value: [
+ (string) @injection.content
+ (template_string) @injection.content
+ (template_string (string_fragment) @injection.content)
+ (array (string) @injection.content)
+ (array (template_string) @injection.content)
+ (array (template_string (string_fragment)) @injection.content)
+ ]
+ )))
+ (#set! injection.language "css"))