summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorObserverOfTime <chronobserver@disroot.org>2023-08-03 13:49:22 +0300
committerObserverOfTime <chronobserver@disroot.org>2023-08-03 15:45:39 +0300
commit131f665f9008d69d130f76f77603886e75c4b146 (patch)
treee7d6d6cb8b793cf19b36bac5806e1f79281ee7a4
parentUpdate parsers: awk, cuda, diff, elm, foam, gleam, gomod, hlsl, ini, java, pe... (diff)
downloadnvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.tar
nvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.tar.gz
nvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.tar.bz2
nvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.tar.lz
nvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.tar.xz
nvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.tar.zst
nvim-treesitter-131f665f9008d69d130f76f77603886e75c4b146.zip
feat(perl): improve highlights
-rw-r--r--queries/perl/highlights.scm129
1 files changed, 70 insertions, 59 deletions
diff --git a/queries/perl/highlights.scm b/queries/perl/highlights.scm
index ef1ca57ea..c7403b6e7 100644
--- a/queries/perl/highlights.scm
+++ b/queries/perl/highlights.scm
@@ -30,15 +30,6 @@
; 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"
@@ -61,6 +52,9 @@
(super)
] @variable.builtin
+((scalar_variable) @variable.builtin
+ (#eq? @variable.builtin "$#ARGV"))
+
; Integer numbers
[
(integer)
@@ -84,8 +78,7 @@
(super) @namespace
; Comments are comments
-(comments) @comment
-(comments) @spell
+(comments) @comment @spell
((source_file . (comments) @preproc)
(#lua-match? @preproc "^#!/"))
@@ -99,6 +92,21 @@
(call_expression
function_name: (identifier) @function.call)
+; Built-in functions
+((call_expression
+ function_name: (identifier) @function.builtin)
+ (#any-of? @function.builtin
+ "print" "printf" "sprintf" "say"
+ "push" "pop" "shift" "unshift" "splice"
+ "exists" "delete" "keys" "values"
+ "each"))
+
+[
+ (map)
+ (grep)
+ (bless)
+] @function.builtin
+
;; ----------
(use_constant_statement
@@ -110,76 +118,79 @@
(function_definition
name: (identifier) @function)
-[
-(function)
-(map)
-(grep)
-(bless)
-] @function
+(function) @function
[
-"("
-")"
-"["
-"]"
-"{"
-"}"
+ "(" ")"
+ "[" "]"
+ "{" "}"
+ (standard_input_to_variable)
] @punctuation.bracket
-(standard_input_to_variable) @punctuation.bracket
+
+[ "`" "\"" ] @punctuation.special
[
-"=~"
-"!~"
-"="
-"=="
-"+"
-"-"
-"."
-"//"
-"||"
-(arrow_operator)
-(hash_arrow_operator)
-(array_dereference)
-(hash_dereference)
-(to_reference)
-(type_glob)
-(hash_access_variable)
+ "=~"
+ "!~"
+ "="
+ "=="
+ "+"
+ "-"
+ "."
+ "//"
+ "||"
+ "&&"
+ "<<"
+ (arrow_operator)
+ (hash_arrow_operator)
+ (array_dereference)
+ (hash_dereference)
+ (to_reference)
+ (type_glob)
+ (hash_access_variable)
] @operator
[
-(regex_option)
-(regex_option_for_substitution)
-(regex_option_for_transliteration)
+ (regex_option)
+ (regex_option_for_substitution)
+ (regex_option_for_transliteration)
] @parameter
(type_glob
(identifier) @variable)
[
-(word_list_qw)
-(command_qx_quoted)
-(string_single_quoted)
-(string_double_quoted)
-(string_qq_quoted)
-(bareword)
-(transliteration_tr_or_y)
+ (word_list_qw)
+ (command_qx_quoted)
+ (string_single_quoted)
+ (string_double_quoted)
+ (string_qq_quoted)
+ (bareword)
+ (transliteration_tr_or_y)
] @string
[
-(pattern_matcher)
-(regex_pattern_qr)
-(patter_matcher_m)
-(substitution_pattern_s)
+ (heredoc_start_identifier)
+ (heredoc_end_identifier)
+] @label
+
+(heredoc_body_statement) @text.literal
+
+[
+ (pattern_matcher)
+ (regex_pattern_qr)
+ (patter_matcher_m)
+ (substitution_pattern_s)
] @string.regex
(escape_sequence) @string.escape
[
-","
-(semi_colon)
-(start_delimiter)
-(end_delimiter)
-(ellipsis_statement)
+ ","
+ (semi_colon)
+ (start_delimiter)
+ (end_delimiter)
+ (ellipsis_statement)
] @punctuation.delimiter
(function_attribute) @field