aboutsummaryrefslogtreecommitdiffstats
path: root/queries/bash
diff options
context:
space:
mode:
authorPham Huy Hoang <hoangtun0810@gmail.com>2024-01-06 15:05:50 +0900
committerChristian Clason <c.clason@uni-graz.at>2024-01-19 16:58:37 +0100
commit57a8acf0c4ed5e7f6dda83c3f9b073f8a99a70f9 (patch)
tree70bf645539882b88e6fa129cefd30986b89bbac3 /queries/bash
parentci: add query lint job (diff)
downloadnvim-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/bash')
-rw-r--r--queries/bash/highlights.scm196
-rw-r--r--queries/bash/injections.scm47
-rw-r--r--queries/bash/locals.scm3
3 files changed, 149 insertions, 97 deletions
diff --git a/queries/bash/highlights.scm b/queries/bash/highlights.scm
index 5820680ef..21346ded8 100644
--- a/queries/bash/highlights.scm
+++ b/queries/bash/highlights.scm
@@ -1,84 +1,89 @@
[
- "(" ")"
- "{" "}"
- "[" "]"
- "[[" "]]"
- "((" "))"
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+ "[["
+ "]]"
+ "(("
+ "))"
] @punctuation.bracket
[
- ";"
- ";;"
- ";&"
- ";;&"
- "&"
+ ";"
+ ";;"
+ ";&"
+ ";;&"
+ "&"
] @punctuation.delimiter
[
- ">"
- ">>"
- "<"
- "<<"
- "&&"
- "|"
- "|&"
- "||"
- "="
- "+="
- "=~"
- "=="
- "!="
-
- "&>"
- "&>>"
- "<&"
- ">&"
- ">|"
- "<&-"
- ">&-"
-
- "<<-"
- "<<<"
-
- ".."
+ ">"
+ ">>"
+ "<"
+ "<<"
+ "&&"
+ "|"
+ "|&"
+ "||"
+ "="
+ "+="
+ "=~"
+ "=="
+ "!="
+ "&>"
+ "&>>"
+ "<&"
+ ">&"
+ ">|"
+ "<&-"
+ ">&-"
+ "<<-"
+ "<<<"
+ ".."
] @operator
; Do *not* spell check strings since they typically have some sort of
; interpolation in them, or, are typically used for things like filenames, URLs,
; flags and file content.
[
- (string)
- (raw_string)
- (ansi_c_string)
- (heredoc_body)
+ (string)
+ (raw_string)
+ (ansi_c_string)
+ (heredoc_body)
] @string
[
- (heredoc_start)
- (heredoc_end)
+ (heredoc_start)
+ (heredoc_end)
] @label
-(variable_assignment (word) @string)
-(command argument: "$" @string) ; bare dollar
+(variable_assignment
+ (word) @string)
+
+(command
+ argument: "$" @string) ; bare dollar
[
- "if"
- "then"
- "else"
- "elif"
- "fi"
- "case"
- "in"
- "esac"
+ "if"
+ "then"
+ "else"
+ "elif"
+ "fi"
+ "case"
+ "in"
+ "esac"
] @keyword.conditional
[
- "for"
- "do"
- "done"
- "select"
- "until"
- "while"
+ "for"
+ "do"
+ "done"
+ "select"
+ "until"
+ "while"
] @keyword.repeat
[
@@ -97,36 +102,54 @@
; trap -l
((word) @constant.builtin
- (#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
+ (#match? @constant.builtin "^SIG(HUP|INT|QUIT|ILL|TRAP|ABRT|BUS|FPE|KILL|USR[12]|SEGV|PIPE|ALRM|TERM|STKFLT|CHLD|CONT|STOP|TSTP|TT(IN|OU)|URG|XCPU|XFSZ|VTALRM|PROF|WINCH|IO|PWR|SYS|RTMIN([+]([1-9]|1[0-5]))?|RTMAX(-([1-9]|1[0-4]))?)$"))
((word) @boolean
- (#any-of? @boolean "true" "false"))
+ (#any-of? @boolean "true" "false"))
(comment) @comment @spell
(test_operator) @operator
-(command_substitution "$(" @punctuation.bracket)
-(process_substitution "<(" @punctuation.bracket)
+(command_substitution
+ "$(" @punctuation.bracket)
+
+(process_substitution
+ "<(" @punctuation.bracket)
(arithmetic_expansion
- [ "$((" "((" ] @punctuation.special
+ [
+ "$(("
+ "(("
+ ] @punctuation.special
"))" @punctuation.special)
-(arithmetic_expansion "," @punctuation.delimiter)
+(arithmetic_expansion
+ "," @punctuation.delimiter)
+
+(ternary_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
+
+(binary_expression
+ operator: _ @operator)
-(ternary_expression [ "?" ":" ] @keyword.conditional.ternary)
+(unary_expression
+ operator: _ @operator)
-(binary_expression operator: _ @operator)
-(unary_expression operator: _ @operator)
-(postfix_expression operator: _ @operator)
+(postfix_expression
+ operator: _ @operator)
(function_definition
name: (word) @function)
-(command_name (word) @function.call)
+(command_name
+ (word) @function.call)
-((command_name (word) @function.builtin)
+((command_name
+ (word) @function.builtin)
; format-ignore
(#any-of? @function.builtin
"alias" "bg" "bind" "break" "builtin" "caller" "cd"
@@ -140,14 +163,17 @@
"ulimit" "umask" "unalias" "wait"))
(command
- argument: [
- (word) @variable.parameter
- (concatenation (word) @variable.parameter)
- ])
+ argument:
+ [
+ (word) @variable.parameter
+ (concatenation
+ (word) @variable.parameter)
+ ])
(number) @number
+
((word) @number
- (#lua-match? @number "^[0-9]+$"))
+ (#lua-match? @number "^[0-9]+$"))
(file_redirect
destination: (word) @variable.parameter)
@@ -156,24 +182,30 @@
(simple_expansion
"$" @punctuation.special) @none
+
(expansion
"${" @punctuation.special
"}" @punctuation.special) @none
-(expansion operator: _ @punctuation.special)
-(expansion "@" . operator: _ @character.special)
+(expansion
+ operator: _ @punctuation.special)
+
+(expansion
+ "@"
+ .
+ operator: _ @character.special)
((expansion
(subscript
index: (word) @character.special))
- (#any-of? @character.special "@" "*"))
+ (#any-of? @character.special "@" "*"))
"``" @punctuation.special
(variable_name) @variable
((variable_name) @constant
- (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
+ (#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
(case_item
value: (word) @variable.parameter)
@@ -183,5 +215,7 @@
(extglob_pattern)
] @string.regexp
-((program . (comment) @keyword.directive)
- (#lua-match? @keyword.directive "^#!/"))
+((program
+ .
+ (comment) @keyword.directive)
+ (#lua-match? @keyword.directive "^#!/"))
diff --git a/queries/bash/injections.scm b/queries/bash/injections.scm
index 516df3b3d..83bb6359e 100644
--- a/queries/bash/injections.scm
+++ b/queries/bash/injections.scm
@@ -1,35 +1,52 @@
-((comment) @injection.content
- (#set! injection.language "comment"))
+((comment) @injection.content
+ (#set! injection.language "comment"))
((regex) @injection.content
- (#set! injection.language "regex"))
+ (#set! injection.language "regex"))
((heredoc_redirect
(heredoc_body) @injection.content
(heredoc_end) @injection.language)
- (#downcase! @injection.language))
+ (#downcase! @injection.language))
; printf 'format'
((command
name: (command_name) @_command
- . argument: [(string) (raw_string)] @injection.content)
- (#eq? @_command "printf")
- (#set! injection.language "printf"))
+ .
+ argument:
+ [
+ (string)
+ (raw_string)
+ ] @injection.content)
+ (#eq? @_command "printf")
+ (#set! injection.language "printf"))
; printf -v var 'format'
((command
name: (command_name) @_command
argument: (word) @_arg
- . (_) . argument: [(string) (raw_string)] @injection.content)
- (#eq? @_command "printf")
- (#eq? @_arg "-v")
- (#set! injection.language "printf"))
+ .
+ (_)
+ .
+ argument:
+ [
+ (string)
+ (raw_string)
+ ] @injection.content)
+ (#eq? @_command "printf")
+ (#eq? @_arg "-v")
+ (#set! injection.language "printf"))
; printf -- 'format'
((command
name: (command_name) @_command
argument: (word) @_arg
- . argument: [(string) (raw_string)] @injection.content)
- (#eq? @_command "printf")
- (#eq? @_arg "--")
- (#set! injection.language "printf"))
+ .
+ argument:
+ [
+ (string)
+ (raw_string)
+ ] @injection.content)
+ (#eq? @_command "printf")
+ (#eq? @_arg "--")
+ (#set! injection.language "printf"))
diff --git a/queries/bash/locals.scm b/queries/bash/locals.scm
index 2b9cfec70..347f51fa2 100644
--- a/queries/bash/locals.scm
+++ b/queries/bash/locals.scm
@@ -2,7 +2,7 @@
(function_definition) @local.scope
; Definitions
-(variable_assignment
+(variable_assignment
name: (variable_name) @local.definition.var)
(function_definition
@@ -10,4 +10,5 @@
; References
(variable_name) @local.reference
+
(word) @local.reference