diff options
| author | Pham Huy Hoang <hoangtun0810@gmail.com> | 2024-01-06 15:05:50 +0900 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-01-19 16:58:37 +0100 |
| commit | 57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9 (patch) | |
| tree | 70bf645539882b88e6fa129cefd30986b89bbac3 /queries/perl | |
| parent | ci: add query lint job (diff) | |
| download | nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.gz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.bz2 nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.lz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.xz nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.tar.zst nvim-treesitter-57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9.zip | |
chore: query formatting
Diffstat (limited to 'queries/perl')
| -rw-r--r-- | queries/perl/folds.scm | 26 | ||||
| -rw-r--r-- | queries/perl/highlights.scm | 232 | ||||
| -rw-r--r-- | queries/perl/injections.scm | 8 |
3 files changed, 186 insertions, 80 deletions
diff --git a/queries/perl/folds.scm b/queries/perl/folds.scm index df23f6317..21950324d 100644 --- a/queries/perl/folds.scm +++ b/queries/perl/folds.scm @@ -1,19 +1,25 @@ (comment)+ @fold + (pod) @fold ; fold the block-typed package statements only -(package_statement (block)) @fold +(package_statement + (block)) @fold -[(subroutine_declaration_statement) - (conditional_statement) - (loop_statement) - (for_statement) - (cstyle_for_statement) - (block_statement) - (phaser_statement)] @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 +[ + (anonymous_array_expression) + (anonymous_hash_expression) +] @fold diff --git a/queries/perl/highlights.scm b/queries/perl/highlights.scm index 7a0c4e530..a6405c948 100644 --- a/queries/perl/highlights.scm +++ b/queries/perl/highlights.scm @@ -1,43 +1,84 @@ -((source_file . (comment) @keyword.directive) +((source_file + . + (comment) @keyword.directive) (#lua-match? @keyword.directive "^#!/")) -[ "use" "no" "require" ] @keyword.import +[ + "use" + "no" + "require" +] @keyword.import -[ "if" "elsif" "unless" "else" ] @keyword.conditional +[ + "if" + "elsif" + "unless" + "else" +] @keyword.conditional -(conditional_expression [ "?" ":" ] @keyword.conditional.ternary) +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) -[ "while" "until" "for" "foreach" ] @keyword.repeat +[ + "while" + "until" + "for" + "foreach" +] @keyword.repeat "return" @keyword.return "sub" @keyword.function -[ "map" "grep" "sort" ] @function.builtin +[ + "map" + "grep" + "sort" +] @function.builtin "package" @keyword.import [ "do" - "my" "our" "local" "state" - "last" "next" "redo" "goto" + "my" + "our" + "local" + "state" + "last" + "next" + "redo" + "goto" "undef" ] @keyword -(_ operator: _ @operator) +(_ + operator: _ @operator) + "\\" @operator (yadayada) @keyword.exception -(phaser_statement phase: _ @keyword.phaser) +(phaser_statement + phase: _ @keyword.phaser) [ - "or" "and" - "eq" "ne" "cmp" "lt" "le" "ge" "gt" + "or" + "and" + "eq" + "ne" + "cmp" + "lt" + "le" + "ge" + "gt" "isa" ] @keyword.operator (eof_marker) @keyword.directive + (data_section) @comment (pod) @none @@ -48,10 +89,10 @@ ] @number [ - (string_literal) - (interpolated_string_literal) - (quoted_word_list) - (command_string) + (string_literal) + (interpolated_string_literal) + (quoted_word_list) + (command_string) (heredoc_content) (replacement) (transliteration_content) @@ -63,54 +104,69 @@ (heredoc_end) ] @label -[(escape_sequence) (escaped_delimiter)] @string.escape +[ + (escape_sequence) + (escaped_delimiter) +] @string.escape -(_ modifiers: _ @character.special) -[ - (quoted_regexp) - (match_regexp) - (regexp_content) +(_ + modifiers: _ @character.special) + +[ + (quoted_regexp) + (match_regexp) + (regexp_content) ] @string.regexp (autoquoted_bareword) @string.special -(use_statement (package) @type) -(package_statement (package) @type) -(require_expression (bareword) @type) +(use_statement + (package) @type) + +(package_statement + (package) @type) + +(require_expression + (bareword) @type) + +(subroutine_declaration_statement + name: (bareword) @function) -(subroutine_declaration_statement name: (bareword) @function) (attribute_name) @attribute + (attribute_value) @string (label) @label -(statement_label label: _ @label) +(statement_label + label: _ @label) + +(relational_expression + operator: "isa" + right: (bareword) @type) + +(function_call_expression + (function) @function.call) -(relational_expression operator: "isa" right: (bareword) @type) +(method_call_expression + (method) @function.method.call) -(function_call_expression (function) @function.call) -(method_call_expression (method) @function.method.call) -(method_call_expression invocant: (bareword) @type) +(method_call_expression + invocant: (bareword) @type) -(func0op_call_expression function: _ @function.builtin) -(func1op_call_expression function: _ @function.builtin) +(func0op_call_expression + function: _ @function.builtin) + +(func1op_call_expression + function: _ @function.builtin) ; this was a regex for the CLI -([(function)(expression_statement (bareword))] @function.builtin - (#any-of? @function.builtin - "accept" "atan2" "bind" "binmode" "bless" "crypt" "chmod" "chown" "connect" - "die" "dbmopen" "exec" "fcntl" "flock" "formline" "getpriority" - "getprotobynumber" "gethostbyaddr" "getnetbyaddr" "getservbyname" - "getservbyport" "getsockopt" "glob" "index" "ioctl" "join" "kill" "link" - "listen" "mkdir" "msgctl" "msgget" "msgrcv" "msgsend" "open" "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" -)) +([ + (function) + (expression_statement + (bareword)) +] @function.builtin + (#any-of? @function.builtin "accept" "atan2" "bind" "binmode" "bless" "crypt" "chmod" "chown" "connect" "die" "dbmopen" "exec" "fcntl" "flock" "formline" "getpriority" "getprotobynumber" "gethostbyaddr" "getnetbyaddr" "getservbyname" "getservbyport" "getsockopt" "glob" "index" "ioctl" "join" "kill" "link" "listen" "mkdir" "msgctl" "msgget" "msgrcv" "msgsend" "open" "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")) (function) @function @@ -119,42 +175,86 @@ (varname) "}" @punctuation.special) -(varname +(varname (block - "{" @punctuation.special + "{" @punctuation.special "}" @punctuation.special)) - -([(varname) (filehandle)] @variable.builtin +([ + (varname) + (filehandle) +] @variable.builtin (#any-of? @variable.builtin "ENV" "ARGV" "INC" "ARGVOUT" "SIG" "STDIN" "STDOUT" "STDERR" "a" "b" "_")) + ((varname) @variable.builtin ; highlights all the reserved ^ vars like ${^THINGS} (#lua-match? @variable.builtin "%^")) + ((varname) @variable.builtin ; highlights punc vars and also numeric only like $11 (#lua-match? @variable.builtin "^%A+$")) - (scalar) @variable.scalar -(scalar_deref_expression [ "$" "*"] @variable.scalar) -[(array) (arraylen)] @variable.array -(array_deref_expression [ "@" "*"] @variable.array) + +(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_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) -(hash_element_expression hash:(_) @variable.hash) -(slice_expression hash:(_) @variable.hash) -(keyval_expression hash:(_) @variable.hash) +(keyval_expression + hash: (_) @variable.hash) (comment) @comment -([ "=>" "," ";" "->" ] @punctuation.delimiter) +([ + "=>" + "," + ";" + "->" +] @punctuation.delimiter) -( - [ "[" "]" "{" "}" "(" ")" ] @punctuation.bracket +([ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket ; priority hack so nvim + ts-cli behave the same (#set! "priority" 90)) diff --git a/queries/perl/injections.scm b/queries/perl/injections.scm index ba5e45f45..48e6363b9 100644 --- a/queries/perl/injections.scm +++ b/queries/perl/injections.scm @@ -1,14 +1,14 @@ ; 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")) + (#set! injection.language "pod")) ((substitution_regexp (replacement) @injection.content (substitution_regexp_modifiers) @_modifiers) - ; match if there's a single `e` in the modifiers list + ; 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")) |
