aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2022-02-21 15:30:35 +0000
committerStephan Seitz <stephan.seitz@fau.de>2022-02-22 14:13:48 +0100
commit09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902 (patch)
treee06bbe4427d73c86e4134e14445c5bda6d943fde
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.tar
nvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.tar.gz
nvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.tar.bz2
nvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.tar.lz
nvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.tar.xz
nvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.tar.zst
nvim-treesitter-09ea6ccd1d75e3896a66a2cbde6b24b7b1c6d902.zip
Add many perl keywords; highlight on those in preference to structural elements
-rw-r--r--queries/perl/highlights.scm166
1 files changed, 87 insertions, 79 deletions
diff --git a/queries/perl/highlights.scm b/queries/perl/highlights.scm
index 1375107bb..66403530d 100644
--- a/queries/perl/highlights.scm
+++ b/queries/perl/highlights.scm
@@ -1,70 +1,109 @@
-; Variables
-(variable_declaration
- .
- (scope) @keyword)
+; Misc keywords
[
-(single_var_declaration)
-(scalar_variable)
-(array_variable)
-(hash_variable)
-(hash_variable)
-] @variable
+ "my" "our" "local"
+ "next" "last" "redo"
+ "goto"
+ "package"
+; "do"
+; "eval"
+] @keyword
+
+; Keywords for including
+[ "use" "no" "require" ] @include
+
+; Keywords that mark conditional statements
+[ "if" "elsif" "unless" "else" ] @conditional
+
+; Keywords that mark repeating loops
+[ "while" "until" "for" "foreach" ] @repeat
+
+; Keyword for return expressions
+[ "return" ] @keyword.return
+; Keywords for phaser blocks
+; TODO: Ideally these would be @keyword.phaser but vim-treesitter doesn't
+; have such a thing yet
+[ "BEGIN" "CHECK" "UNITCHECK" "INIT" "END" ] @keyword.function
+; Keywords to define a function
+[ "sub" ] @keyword.function
+
+; Lots of builtin functions, except tree-sitter-perl doesn't emit most of
+; these yet
+;[
+; "print" "printf" "sprintf" "say"
+; "push" "pop" "shift" "unshift" "splice"
+; "exists" "delete" "keys" "values"
+; "each"
+;] @function.builtin
+
+; Keywords that are regular infix operators
+[
+ "and" "or" "not" "xor"
+ "eq" "ne" "lt" "le" "ge" "gt" "cmp"
+] @keyword.operator
+
+; Variables
[
-(package_name)
-(special_scalar_variable)
-(special_array_variable)
-(special_hash_variable)
-(special_literal)
-(super)
-] @constant
+ (scalar_variable)
+ (array_variable)
+ (hash_variable)
+] @variable
-(
- [
- (package_name)
+; Special builtin variables
+[
+ (special_scalar_variable)
+ (special_array_variable)
+ (special_hash_variable)
+ (special_literal)
(super)
- ]
- .
- ("::" @operator)
-)
+] @variable.builtin
-(comments) @comment
-(pod_statement) @comment
+; Integer numbers
+[
+ (integer)
+ (hexadecimal)
+] @number
+; Float numbers
[
-(use_no_statement)
-(use_no_feature_statement)
-(use_no_if_statement)
-(use_no_version)
-(use_constant_statement)
-(use_parent_statement)
-] @include
+ (floating_point)
+ (scientific_notation)
+] @float
-(use_constant_statement
- constant: (identifier) @constant)
+; version sortof counts as a kind of multipart integer
+(version) @constant
-[
-"require"
-] @include
+; Package names are types
+(package_name) @type
-(method_invocation
- .
- (identifier) @variable)
+; The special SUPER:: could be called a namespace. It isn't really but it
+; should highlight differently and we might as well do it this way
+(super) @namespace
+
+; Comments are comments
+(comments) @comment
+
+; POD should be handled specially with its own embedded subtype but for now
+; we'll just have to do this.
+(pod_statement) @text
(method_invocation
- (arrow_operator)
- .
- (identifier) @function)
-(method_invocation
+ function_name: (identifier) @method)
+(call_expression
function_name: (identifier) @function)
+
+;; ----------
+
+(use_constant_statement
+ constant: (identifier) @constant)
+
(named_block_statement
function_name: (identifier) @function)
-(call_expression
- function_name: (identifier) @function)
(function_definition
name: (identifier) @function)
+
[
(function)
(map)
@@ -73,14 +112,6 @@
] @function
[
-"return"
-"sub"
-"package"
-"BEGIN"
-"END"
-] @keyword.function
-
-[
"("
")"
"["
@@ -92,7 +123,7 @@
[
"=~"
-"or"
+"!~"
"="
"=="
"+"
@@ -119,10 +150,6 @@
(type_glob
(identifier) @variable)
-(
- (scalar_variable)
- .
- ("->" @operator))
[
(word_list_qw)
@@ -150,25 +177,6 @@
(ellipsis_statement)
] @punctuation.delimiter
-[
-(integer)
-(floating_point)
-(scientific_notation)
-(hexadecimal)
-] @number
-
-[
-(if_statement)
-(unless_statement)
-(if_simple_statement)
-(unless_simple_statement)
-] @conditional
-
-(foreach_statement) @repeat
-(foreach_statement
- .
- (scope) @keyword)
-
(function_attribute) @field
(function_signature) @type