mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 10:20:11 -04:00
feat(perl)!: switch to tree-sitter-perl org's parser
This commit is contained in:
parent
7c67a1a923
commit
bb3f8f40b1
5 changed files with 156 additions and 187 deletions
|
|
@ -414,7 +414,7 @@
|
||||||
"revision": "e01767921df18142055d97407595329d7629e643"
|
"revision": "e01767921df18142055d97407595329d7629e643"
|
||||||
},
|
},
|
||||||
"perl": {
|
"perl": {
|
||||||
"revision": "79e88f64681660f3961939bf764d8f3b4bbb0d27"
|
"revision": "99bbcb0faddfc79db3fd2996cb56689a4685e78c"
|
||||||
},
|
},
|
||||||
"php": {
|
"php": {
|
||||||
"revision": "0e02e7fab7913a0e77343edb347c8f17cac1f0ba"
|
"revision": "0e02e7fab7913a0e77343edb347c8f17cac1f0ba"
|
||||||
|
|
|
||||||
|
|
@ -1240,10 +1240,11 @@ list.pem = {
|
||||||
|
|
||||||
list.perl = {
|
list.perl = {
|
||||||
install_info = {
|
install_info = {
|
||||||
url = "https://github.com/ganezdragon/tree-sitter-perl",
|
url = "https://github.com/tree-sitter-perl/tree-sitter-perl",
|
||||||
files = { "src/parser.c", "src/scanner.cc" },
|
files = { "src/parser.c", "src/scanner.c" },
|
||||||
|
branch = "release",
|
||||||
},
|
},
|
||||||
maintainers = { "@lcrownover" },
|
maintainers = { "@RabbiVeesh", "@LeoNerd" },
|
||||||
}
|
}
|
||||||
|
|
||||||
list.php = {
|
list.php = {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
[
|
(comment)+ @fold
|
||||||
(function_definition)
|
(pod) @fold
|
||||||
(if_statement)
|
|
||||||
(unless_statement)
|
; fold the block-typed package statements only
|
||||||
(while_statement)
|
(package_statement (block)) @fold
|
||||||
(until_statement)
|
|
||||||
(for_statement_1)
|
[(subroutine_declaration_statement)
|
||||||
(for_statement_2)
|
(conditional_statement)
|
||||||
(standalone_block)
|
(loop_statement)
|
||||||
(pod_statement)
|
(for_statement)
|
||||||
] @fold
|
(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
|
||||||
|
|
|
||||||
|
|
@ -1,198 +1,146 @@
|
||||||
; Misc keywords
|
((source_file . (comment) @preproc)
|
||||||
[
|
|
||||||
"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
|
|
||||||
(ternary_expression
|
|
||||||
["?" ":"] @conditional.ternary)
|
|
||||||
|
|
||||||
; 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
|
|
||||||
|
|
||||||
; Keywords that are regular infix operators
|
|
||||||
[
|
|
||||||
"and" "or" "not" "xor"
|
|
||||||
"eq" "ne" "lt" "le" "ge" "gt" "cmp"
|
|
||||||
] @keyword.operator
|
|
||||||
|
|
||||||
; Variables
|
|
||||||
[
|
|
||||||
(scalar_variable)
|
|
||||||
(array_variable)
|
|
||||||
(hash_variable)
|
|
||||||
] @variable
|
|
||||||
|
|
||||||
; Special builtin variables
|
|
||||||
[
|
|
||||||
(special_scalar_variable)
|
|
||||||
(special_array_variable)
|
|
||||||
(special_hash_variable)
|
|
||||||
(special_literal)
|
|
||||||
(super)
|
|
||||||
] @variable.builtin
|
|
||||||
|
|
||||||
((scalar_variable) @variable.builtin
|
|
||||||
(#eq? @variable.builtin "$#ARGV"))
|
|
||||||
|
|
||||||
; Integer numbers
|
|
||||||
[
|
|
||||||
(integer)
|
|
||||||
(hexadecimal)
|
|
||||||
] @number
|
|
||||||
|
|
||||||
; Float numbers
|
|
||||||
[
|
|
||||||
(floating_point)
|
|
||||||
(scientific_notation)
|
|
||||||
] @float
|
|
||||||
|
|
||||||
; version sortof counts as a kind of multipart integer
|
|
||||||
(version) @constant
|
|
||||||
|
|
||||||
; Package names are types
|
|
||||||
(package_name) @type
|
|
||||||
|
|
||||||
; 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 @spell
|
|
||||||
|
|
||||||
((source_file . (comments) @preproc)
|
|
||||||
(#lua-match? @preproc "^#!/"))
|
(#lua-match? @preproc "^#!/"))
|
||||||
|
|
||||||
; POD should be handled specially with its own embedded subtype but for now
|
[ "use" "no" "require" ] @include
|
||||||
; we'll just have to do this.
|
|
||||||
(pod_statement) @text
|
|
||||||
|
|
||||||
(method_invocation
|
[ "if" "elsif" "unless" "else" ] @conditional
|
||||||
function_name: (identifier) @method.call)
|
|
||||||
(call_expression
|
|
||||||
function_name: (identifier) @function.call)
|
|
||||||
|
|
||||||
; Built-in functions
|
(conditional_expression [ "?" ":" ] @conditional.ternary)
|
||||||
((call_expression
|
|
||||||
function_name: (identifier) @function.builtin)
|
[ "while" "until" "for" "foreach" ] @repeat
|
||||||
(#any-of? @function.builtin
|
|
||||||
"print" "printf" "sprintf" "say"
|
"return" @keyword.return
|
||||||
"push" "pop" "shift" "unshift" "splice"
|
|
||||||
"exists" "delete" "keys" "values"
|
"sub" @keyword.function
|
||||||
"each"))
|
|
||||||
|
[ "map" "grep" ] @function.builtin
|
||||||
|
|
||||||
|
"package" @include
|
||||||
|
|
||||||
[
|
[
|
||||||
(map)
|
"do"
|
||||||
(grep)
|
"my" "our" "local"
|
||||||
(bless)
|
"last" "next" "redo" "goto"
|
||||||
] @function.builtin
|
"undef"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
;; ----------
|
(_ operator: _ @operator)
|
||||||
|
"\\" @operator
|
||||||
|
|
||||||
(use_constant_statement
|
(yadayada) @exception
|
||||||
constant: (identifier) @constant)
|
|
||||||
|
|
||||||
(named_block_statement
|
(phaser_statement phase: _ @keyword.phaser)
|
||||||
function_name: (identifier) @function)
|
|
||||||
|
|
||||||
(function_definition
|
|
||||||
name: (identifier) @function)
|
|
||||||
|
|
||||||
(function) @function
|
|
||||||
|
|
||||||
[
|
[
|
||||||
"(" ")"
|
"or" "and"
|
||||||
"[" "]"
|
"eq" "ne" "cmp" "lt" "le" "ge" "gt"
|
||||||
"{" "}"
|
"isa"
|
||||||
(standard_input_to_variable)
|
] @keyword.operator
|
||||||
] @punctuation.bracket
|
|
||||||
|
|
||||||
[ "`" "\"" ] @punctuation.special
|
(eof_marker) @preproc
|
||||||
|
(data_section) @comment
|
||||||
|
|
||||||
|
(pod) @text
|
||||||
|
|
||||||
[
|
[
|
||||||
"=~"
|
(number)
|
||||||
"!~"
|
(version)
|
||||||
"="
|
] @number
|
||||||
"=="
|
|
||||||
"+"
|
|
||||||
"-"
|
|
||||||
"."
|
|
||||||
"//"
|
|
||||||
"||"
|
|
||||||
"&&"
|
|
||||||
"<<"
|
|
||||||
(arrow_operator)
|
|
||||||
(hash_arrow_operator)
|
|
||||||
(array_dereference)
|
|
||||||
(hash_dereference)
|
|
||||||
(to_reference)
|
|
||||||
(type_glob)
|
|
||||||
(hash_access_variable)
|
|
||||||
] @operator
|
|
||||||
|
|
||||||
[
|
[
|
||||||
(regex_option)
|
(string_literal)
|
||||||
(regex_option_for_substitution)
|
(interpolated_string_literal)
|
||||||
(regex_option_for_transliteration)
|
(quoted_word_list)
|
||||||
] @parameter
|
(command_string)
|
||||||
|
(heredoc_content)
|
||||||
(type_glob
|
(replacement)
|
||||||
(identifier) @variable)
|
(transliteration_content)
|
||||||
|
|
||||||
[
|
|
||||||
(word_list_qw)
|
|
||||||
(command_qx_quoted)
|
|
||||||
(string_single_quoted)
|
|
||||||
(string_double_quoted)
|
|
||||||
(string_qq_quoted)
|
|
||||||
(bareword)
|
|
||||||
(transliteration_tr_or_y)
|
|
||||||
] @string
|
] @string
|
||||||
|
|
||||||
[
|
[
|
||||||
(heredoc_start_identifier)
|
(heredoc_token)
|
||||||
(heredoc_end_identifier)
|
(command_heredoc_token)
|
||||||
|
(heredoc_end)
|
||||||
] @label
|
] @label
|
||||||
|
|
||||||
(heredoc_body_statement) @text.literal
|
[(escape_sequence) (escaped_delimiter)] @string.escape
|
||||||
|
|
||||||
[
|
(_ modifiers: _ @character.special)
|
||||||
(pattern_matcher)
|
[
|
||||||
(regex_pattern_qr)
|
(quoted_regexp)
|
||||||
(patter_matcher_m)
|
(match_regexp)
|
||||||
(substitution_pattern_s)
|
(regexp_content)
|
||||||
] @string.regex
|
] @string.regex
|
||||||
|
|
||||||
(escape_sequence) @string.escape
|
(autoquoted_bareword _?) @string.special
|
||||||
|
|
||||||
[
|
(use_statement (package) @type)
|
||||||
","
|
(package_statement (package) @type)
|
||||||
(semi_colon)
|
(require_expression (bareword) @type)
|
||||||
(start_delimiter)
|
|
||||||
(end_delimiter)
|
|
||||||
(ellipsis_statement)
|
|
||||||
] @punctuation.delimiter
|
|
||||||
|
|
||||||
(function_attribute) @field
|
(subroutine_declaration_statement name: (bareword) @function)
|
||||||
|
(attribute_name) @attribute
|
||||||
|
(attribute_value) @string
|
||||||
|
|
||||||
(function_signature) @type
|
(label) @label
|
||||||
|
|
||||||
|
(statement_label label: _ @label)
|
||||||
|
|
||||||
|
(relational_expression operator: "isa" right: (bareword) @type)
|
||||||
|
|
||||||
|
(function_call_expression (function) @function.call)
|
||||||
|
(method_call_expression (method) @method.call)
|
||||||
|
(method_call_expression invocant: (bareword) @type)
|
||||||
|
|
||||||
|
(func0op_call_expression function: _ @function.builtin)
|
||||||
|
(func1op_call_expression function: _ @function.builtin)
|
||||||
|
|
||||||
|
([(function)(expression_statement (bareword))] @function.builtin
|
||||||
|
(#set! "priority" 101)
|
||||||
|
(#lua-match? @function.builtin
|
||||||
|
"^(accept|atan2|bind|binmode|bless|crypt|chmod|chown|connect|die|dbmopen|exec|fcntl|flock|getpriority|getprotobynumber|gethostbyaddr|getnetbyaddr|getservbyname|getservbyport|getsockopt|glob|index|ioctl|join|kill|link|listen|mkdir|msgctl|msgget|msgrcv|msgsend|opendir|print|printf|push|pack|pipe|return|rename|rindex|read|recv|reverse|say|select|seek|semctl|semget|semop|send|setpgrp|setpriority|seekdir|setsockopt|shmctl|shmread|shmwrite|shutdown|socket|socketpair|split|sprintf|splice|substr|system|symlink|syscall|sysopen|sysseek|sysread|syswrite|tie|truncate|unlink|unpack|utime|unshift|vec|warn|waitpid|formline|open|sort)$"
|
||||||
|
))
|
||||||
|
|
||||||
|
(function) @function
|
||||||
|
|
||||||
|
(ERROR) @error
|
||||||
|
|
||||||
|
(_
|
||||||
|
"{" @punctuation.special
|
||||||
|
(varname)
|
||||||
|
"}" @punctuation.special)
|
||||||
|
|
||||||
|
(varname
|
||||||
|
(block
|
||||||
|
"{" @punctuation.special
|
||||||
|
"}" @punctuation.special))
|
||||||
|
|
||||||
|
|
||||||
|
(
|
||||||
|
[(varname) (filehandle)] @variable.builtin
|
||||||
|
(#lua-match? @variable.builtin "^((ENV|ARGV|INC|ARGVOUT|SIG|STDIN|STDOUT|STDERR)|[_ab]|\\W|\\d+|\\^.*)$")
|
||||||
|
)
|
||||||
|
|
||||||
|
(scalar) @variable.scalar
|
||||||
|
(scalar_deref_expression [ "$" "*"] @variable.scalar)
|
||||||
|
[(array) (arraylen)] @variable.array
|
||||||
|
(array_deref_expression [ "@" "*"] @variable.array)
|
||||||
|
(hash) @variable.hash
|
||||||
|
(hash_deref_expression [ "%" "*"] @variable.hash)
|
||||||
|
|
||||||
|
(array_element_expression array:(_) @variable.array)
|
||||||
|
(slice_expression array:(_) @variable.array)
|
||||||
|
(keyval_expression array:(_) @variable.array)
|
||||||
|
|
||||||
|
(hash_element_expression hash:(_) @variable.hash)
|
||||||
|
(slice_expression hash:(_) @variable.hash)
|
||||||
|
(keyval_expression hash:(_) @variable.hash)
|
||||||
|
|
||||||
|
(comment) @comment
|
||||||
|
|
||||||
|
([ "=>" "," ";" "->" ] @punctuation.delimiter)
|
||||||
|
|
||||||
|
(
|
||||||
|
[ "[" "]" "{" "}" "(" ")" ] @punctuation.bracket
|
||||||
|
; priority hack so nvim + ts-cli behave the same
|
||||||
|
(#set! "priority" 90))
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,14 @@
|
||||||
((comments) @injection.content
|
; an injections.scm file for nvim-treesitter
|
||||||
|
((comment) @injection.content
|
||||||
(#set! injection.language "comment"))
|
(#set! injection.language "comment"))
|
||||||
|
|
||||||
|
((pod) @injection.content
|
||||||
|
(#set! injection.language "pod"))
|
||||||
|
|
||||||
|
((substitution_regexp
|
||||||
|
(replacement) @injection.content
|
||||||
|
(substitution_regexp_modifiers) @_modifiers)
|
||||||
|
; match if there's a single `e` in the modifiers list
|
||||||
|
(#lua-match? @_modifiers "e")
|
||||||
|
(#not-lua-match? @_modifiers "e.*e")
|
||||||
|
(#set! injection.language "perl"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue