aboutsummaryrefslogtreecommitdiffstats
path: root/queries/hack
diff options
context:
space:
mode:
authorStephan Seitz <stephan.seitz@fau.de>2021-11-23 18:23:57 +0100
committerStephan Seitz <stephan.seitz@fau.de>2022-01-17 10:53:35 +0100
commitcc0bdabe5f9a9705bf2992831dd45e95d116fe0c (patch)
treeed755e7e9dc1122d52b1431271fbe3c814347c93 /queries/hack
parentAdd ftdect for hack (diff)
downloadnvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.tar
nvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.tar.gz
nvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.tar.bz2
nvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.tar.lz
nvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.tar.xz
nvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.tar.zst
nvim-treesitter-cc0bdabe5f9a9705bf2992831dd45e95d116fe0c.zip
highlights(hack): extend queries add tests
Diffstat (limited to 'queries/hack')
-rw-r--r--queries/hack/highlights.scm142
1 files changed, 137 insertions, 5 deletions
diff --git a/queries/hack/highlights.scm b/queries/hack/highlights.scm
index 29139aaff..1bde66632 100644
--- a/queries/hack/highlights.scm
+++ b/queries/hack/highlights.scm
@@ -1,4 +1,16 @@
+(variable) @variable
+(identifier) @variable
+((variable) @variable.builtin
+ (#eq? @variable.builtin "$this"))
+
+(braced_expression) @none
+
+(scoped_identifier
+ (qualified_identifier
+ (identifier) @type))
+
(comment) @comment
+(heredoc) @comment
[
"function"
@@ -10,14 +22,28 @@
"type"
"interface"
"class"
+ "protected"
+ "private"
+ "public"
+ "using"
+ "namespace"
+ "attribute"
+ "const"
+ (xhp_modifier)
+ (final_modifier)
+ "extends"
+ "insteadof"
] @keyword
+"use" @include
+
[
"new"
"print"
"echo"
"newtype"
"clone"
+ "as"
] @keyword.operator
[
@@ -39,10 +65,30 @@
"mixed"
"dynamic"
"noreturn"
-] @type
+] @type.builtin
+
+(type_specifier) @type
+(new_expression
+ (_) @type)
+
+(alias_declaration "newtype" . (_) @type)
+(alias_declaration "type" . (_) @type)
+
+(class_declaration
+ name: (identifier) @type)
+(type_parameter
+ name: (identifier) @type)
-(type_specifier
- (qualified_identifier) @type)
+(collection
+ (qualified_identifier
+ (identifier) @type .))
+
+(function_type_specifier) @function
+(attribute_modifier) @attribute
+[
+ "@required"
+ "@lateinit"
+] @attribute
[
"="
@@ -79,6 +125,7 @@
"<=>"
"<<"
">>"
+ "->"
"+"
"-"
"."
@@ -107,6 +154,7 @@
"/="
"%="
"**="
+ "=>"
;; type modifiers
"@"
@@ -121,15 +169,90 @@
(variable) @parameter)
(call_expression
- function: (qualified_identifier) @function)
+ function: (qualified_identifier (identifier) @function .))
+
+(call_expression
+ function: (scoped_identifier (identifier) @function .))
+
+(call_expression
+ function: (selection_expression
+ (qualified_identifier (identifier) @method .)))
+
+(qualified_identifier
+ (_) @namespace .
+ (_))
+
+(use_statement
+ (qualified_identifier
+ (_) @namespace .)
+ (use_clause))
+
+(use_statement
+ (use_type "namespace")
+ (use_clause
+ (qualified_identifier
+ (identifier) @namespace .)
+ alias: (identifier)? @namespace))
+
+(use_statement
+ (use_type "const")
+ (use_clause
+ (qualified_identifier
+ (identifier) @constant .)
+ alias: (identifier)? @constant))
+
+(use_statement
+ (use_type "function")
+ (use_clause
+ (qualified_identifier
+ (identifier) @function .)
+ alias: (identifier)? @function))
+
+(use_statement
+ (use_type "type")
+ (use_clause
+ (qualified_identifier
+ (identifier) @type .)
+ alias: (identifier)? @type))
+
+(use_clause
+ (use_type "namespace")
+ (qualified_identifier
+ (_) @namespace .)
+ alias: (identifier)? @namespace)
+
+(use_clause
+ (use_type "function")
+ (qualified_identifier
+ (_) @function .)
+ alias: (identifier)? @function)
+
+(use_clause
+ (use_type "const")
+ (qualified_identifier
+ (_) @constant .)
+ alias: (identifier)? @constant)
+
+(use_clause
+ (use_type "type")
+ (qualified_identifier
+ (_) @type .)
+ alias: (identifier)? @type)
(function_declaration
name: (identifier) @function)
+(method_declaration
+ name: (identifier) @method)
(type_arguments
[ "<" ">" ] @punctuation.bracket)
[ "(" ")" "[" "]" "{" "}" "<<" ">>"] @punctuation.bracket
+(xhp_open
+ [ "<" ">" ] @tag.delimiter)
+(xhp_close
+ [ "</" ">" ] @tag.delimiter)
+
[ "." ";" "::" ":" "," ] @punctuation.delimiter
(ternary_expression
@@ -152,11 +275,20 @@
[
"for"
"while"
+ "foreach"
"do"
"continue"
"break"
] @repeat
-(string) @string
+[
+ (string)
+ (xhp_string)
+] @string
+
+[
+ (xhp_open)
+ (xhp_close)
+] @tag
(ERROR) @error