aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Luehrs2023-07-17 05:09:38 +0000
committerGitHub2023-07-17 05:09:38 +0000
commite7f60611acbfc6b22867240a166fcb7169843ee0 (patch)
tree591a460f939d7860c4044752642ad1b828a88cfe
parentad2061bab65682a2c46b51701dac0c88237f3da4 (diff)
switch to https://github.com/tree-sitter-perl/tree-sitter-perl (#7644)
-rw-r--r--book/src/generated/lang-support.md2
-rw-r--r--languages.toml2
-rw-r--r--runtime/queries/perl/fold.scm19
-rw-r--r--runtime/queries/perl/highlights.scm229
-rw-r--r--runtime/queries/perl/indents.scm15
-rw-r--r--runtime/queries/perl/injections.scm2
-rw-r--r--runtime/queries/perl/textobjects.scm17
7 files changed, 96 insertions, 190 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 403932c7..8941f735 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -109,7 +109,7 @@
| pascal | ✓ | ✓ | | `pasls` |
| passwd | ✓ | | | |
| pem | ✓ | | | |
-| perl | ✓ | ✓ | ✓ | `perlnavigator` |
+| perl | ✓ | | | `perlnavigator` |
| php | ✓ | ✓ | ✓ | `intelephense` |
| po | ✓ | ✓ | | |
| ponylang | ✓ | ✓ | ✓ | |
diff --git a/languages.toml b/languages.toml
index a13e35b4..7f774296 100644
--- a/languages.toml
+++ b/languages.toml
@@ -1112,7 +1112,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]]
name = "perl"
-source = { git = "https://github.com/ganezdragon/tree-sitter-perl", rev = "0ac2c6da562c7a2c26ed7e8691d4a590f7e8b90a" }
+source = { git = "https://github.com/tree-sitter-perl/tree-sitter-perl", rev = "ed21ecbcc128a6688770ebafd3ef68a1c9bc1ea9" }
[[language]]
name = "racket"
diff --git a/runtime/queries/perl/fold.scm b/runtime/queries/perl/fold.scm
new file mode 100644
index 00000000..17fd114b
--- /dev/null
+++ b/runtime/queries/perl/fold.scm
@@ -0,0 +1,19 @@
+(comment) @fold
+(pod) @fold
+
+; fold the block-typed package statements only
+(package_statement (block)) @fold
+
+[(subroutine_declaration_statement)
+ (conditional_statement)
+ (loop_statement)
+ (for_statement)
+ (cstyle_for_statement)
+ (block_statement)
+ (phaser_statement)] @fold
+
+(anonymous_subroutine_expression) @fold
+
+; perhaps folks want to fold these too?
+[(anonymous_array_expression)
+ (anonymous_hash_expression)] @fold
diff --git a/runtime/queries/perl/highlights.scm b/runtime/queries/perl/highlights.scm
index b6f04291..961ff5ea 100644
--- a/runtime/queries/perl/highlights.scm
+++ b/runtime/queries/perl/highlights.scm
@@ -1,181 +1,100 @@
-; Variables
-(variable_declaration
- .
- (scope) @keyword)
[
-(single_var_declaration)
-(scalar_variable)
-(array_variable)
-(hash_variable)
-(hash_variable)
-] @variable
-
+ "use" "no" "require" "package"
+] @keyword.control.import
[
-(package_name)
-(special_scalar_variable)
-(special_array_variable)
-(special_hash_variable)
-(special_literal)
-(super)
-] @constant
-
-(
- [
- (package_name)
- (super)
- ]
- .
- ("::" @operator)
-)
-
-(comments) @comment
-(pod_statement) @comment.block.documentation
+ "sub"
+] @keyword.function
[
-(use_no_statement)
-(use_no_feature_statement)
-(use_no_if_statement)
-(use_no_version)
-(use_constant_statement)
-(use_parent_statement)
-] @keyword
-
-(use_constant_statement
- constant: (identifier) @constant)
+ "if" "elsif" "else" "unless"
+] @keyword.control.conditional
[
-"require"
-] @keyword
-
-(method_invocation
- .
- (identifier) @variable)
-
-(method_invocation
- (arrow_operator)
- .
- (identifier) @function)
-(method_invocation
- function_name: (identifier) @function)
-(named_block_statement
- function_name: (identifier) @function)
-
-(call_expression
- function_name: (identifier) @function)
-(function_definition
- name: (identifier) @function)
-[
-(function)
-(map)
-(grep)
-(bless)
-] @function
+ "while" "until"
+ "for" "foreach"
+ "do"
+] @keyword.control.repeat
[
-"return"
-"sub"
-"package"
-"BEGIN"
-"END"
-] @keyword.function
+ "my" "our" "local"
+] @keyword.storage.modifier
[
-"("
-")"
-"["
-"]"
-"{"
-"}"
-] @punctuation.bracket
-(standard_input_to_variable) @punctuation.bracket
+ "last" "next" "redo" "goto" "return"
+] @keyword.control.return
[
-"=~"
-"or"
-"="
-"=="
-"+"
-"-"
-"."
-"//"
-"||"
-(arrow_operator)
-(hash_arrow_operator)
-(array_dereference)
-(hash_dereference)
-(to_reference)
-(type_glob)
-(hash_access_variable)
-(ternary_expression)
-(ternary_expression_in_hash)
-] @operator
+ "undef"
+] @constant.builtin
-[
-(regex_option)
-(regex_option_for_substitution)
-(regex_option_for_transliteration)
-] @variable.parameter
-
-(type_glob
- (identifier) @variable)
-(
- (scalar_variable)
- .
- ("->" @operator))
+(phaser_statement phase: _ @keyword.directive)
[
-(word_list_qw)
-(command_qx_quoted)
-(string_single_quoted)
-(string_double_quoted)
-(string_qq_quoted)
-(bareword)
-(transliteration_tr_or_y)
-] @string
+ "or" "and"
+ "eq" "ne" "cmp" "lt" "le" "ge" "gt"
+ "isa"
+] @keyword.operator
-[
-(regex_pattern_qr)
-(patter_matcher_m)
-(substitution_pattern_s)
-] @string.regexp
+(comment) @comment
-(escape_sequence) @string.special
+(eof_marker) @keyword.directive
+(data_section) @comment
-[
-","
-(semi_colon)
-(start_delimiter)
-(end_delimiter)
-(ellipsis_statement)
-] @punctuation.delimiter
+(pod) @comment.block.documentation
-[
-(integer)
-(floating_point)
-(scientific_notation)
-(hexadecimal)
-] @constant.numeric
+(number) @constant.numeric
+(version) @constant
-[
-; (if_statement)
-(unless_statement)
-(if_simple_statement)
-(unless_simple_statement)
-] @keyword.control.conditional
+(string_literal) @string
+(interpolated_string_literal) @string
+(quoted_word_list) @string
+(command_string) @string
+[(heredoc_token) (command_heredoc_token)] @string.special
+(heredoc_content) @string
+(heredoc_end) @string.special
+[(escape_sequence) (escaped_delimiter)] @constant.character.escape
-[
-"if"
-"elsif"
-"else"
-] @keyword.control.conditional
+[(quoted_regexp) (match_regexp)] @string.regexp
+
+(autoquoted_bareword _?) @string.special
+
+[(scalar) (arraylen)] @variable
+(scalar_deref_expression ["->" "$" "*"] @variable)
+(array) @variable
+(array_deref_expression ["->" "@" "*"] @variable)
+(hash) @variable
+(hash_deref_expression ["->" "%" "*"] @variable)
+
+(array_element_expression [array:(_) "->" "[" "]"] @variable)
+(slice_expression [array:(_) "->" "[" "]"] @variable)
+(keyval_expression [array:(_) "->" "[" "]"] @variable)
+
+(hash_element_expression [hash:(_) "->" "{" "}"] @variable)
+(slice_expression [hash:(_) "->" "[" "]"] @variable)
+(keyval_expression [hash:(_) "->" "[" "]"] @variable)
+
+(hash_element_expression key: (bareword) @string.special)
+
+(use_statement (package) @type)
+(package_statement (package) @type)
+(require_expression (bareword) @type)
+
+(subroutine_declaration_statement name: (_) @function)
+(attrlist (attribute) @attribute)
+
+(goto_expression (label) @label)
+(loopex_expression (label) @label)
+
+(statement_label label: _ @label)
-(foreach_statement) @keyword.control.repeat
-(foreach_statement
- .
- (scope) @keyword)
+(relational_expression operator: "isa" right: (bareword) @type)
-(function_attribute) @label
+(function_call_expression (function) @function)
+(method_call_expression (method) @function.method)
+(method_call_expression invocant: (bareword) @type)
-(function_signature) @type
+(func0op_call_expression function: _ @function.builtin)
+(func1op_call_expression function: _ @function.builtin)
+(function) @function
diff --git a/runtime/queries/perl/indents.scm b/runtime/queries/perl/indents.scm
deleted file mode 100644
index 5ae34f5e..00000000
--- a/runtime/queries/perl/indents.scm
+++ /dev/null
@@ -1,15 +0,0 @@
-[
- (function)
- (identifier)
- (method_invocation)
- (if_statement)
- (unless_statement)
- (if_simple_statement)
- (unless_simple_statement)
- (variable_declaration)
- (block)
- (list_item)
- (word_list_qw)
-] @indent
-
-"}" @outdent
diff --git a/runtime/queries/perl/injections.scm b/runtime/queries/perl/injections.scm
index cab5f53d..321c90ad 100644
--- a/runtime/queries/perl/injections.scm
+++ b/runtime/queries/perl/injections.scm
@@ -1,2 +1,2 @@
-((comments) @injection.content
+((comment) @injection.content
(#set! injection.language "comment"))
diff --git a/runtime/queries/perl/textobjects.scm b/runtime/queries/perl/textobjects.scm
deleted file mode 100644
index 972b8774..00000000
--- a/runtime/queries/perl/textobjects.scm
+++ /dev/null
@@ -1,17 +0,0 @@
-(function_definition
- (identifier) (_) @function.inside) @function.around
-
-(anonymous_function
- (_) @function.inside) @function.around
-
-(argument
- (_) @parameter.inside)
-
-[
- (comments)
- (pod_statement)
-] @comment.inside
-
-(comments)+ @comment.around
-
-(pod_statement) @comment.around