diff options
| author | ObserverOfTime <chronobserver@disroot.org> | 2023-08-23 13:02:30 +0300 |
|---|---|---|
| committer | ObserverOfTime <chronobserver@disroot.org> | 2023-08-24 12:11:16 +0300 |
| commit | 1ff7985a74ac42142e55e561dcbff0e881b157f2 (patch) | |
| tree | ae67a2cc7e4050ce17d4a8cc15a02d93d13e8a2c | |
| parent | Update parsers: bash, dart, heex, java, wing (diff) | |
| download | nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.tar nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.tar.gz nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.tar.bz2 nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.tar.lz nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.tar.xz nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.tar.zst nvim-treesitter-1ff7985a74ac42142e55e561dcbff0e881b157f2.zip | |
feat(bash): improve highlights
| -rw-r--r-- | lockfile.json | 2 | ||||
| -rw-r--r-- | queries/bash/highlights.scm | 82 | ||||
| -rw-r--r-- | tests/query/highlights/bash/double-parens.sh | 4 |
3 files changed, 50 insertions, 38 deletions
diff --git a/lockfile.json b/lockfile.json index 823744da2..d6be40756 100644 --- a/lockfile.json +++ b/lockfile.json @@ -15,7 +15,7 @@ "revision": "244426241376b08d9531616290d657106ec8f7ff" }, "bash": { - "revision": "42ab5ca0e6bb7130c397c7ca10440fd5cfc2d564" + "revision": "aaae047b927bcbd04ddbb07b32b555831c482c1a" }, "bass": { "revision": "27f110dfe79620993f5493ffa0d0f2fe12d250ed" diff --git a/queries/bash/highlights.scm b/queries/bash/highlights.scm index 063c2b920..dbe6f6883 100644 --- a/queries/bash/highlights.scm +++ b/queries/bash/highlights.scm @@ -1,36 +1,21 @@ -(simple_expansion) @none -(expansion - "${" @punctuation.special - "}" @punctuation.special) @none [ - "(" - ")" - "((" - "))" - "{" - "}" - "[" - "]" - "[[" - "]]" - ] @punctuation.bracket + "(" ")" + "{" "}" + "[" "]" + "[[" "]]" +] @punctuation.bracket [ ";" ";;" - (heredoc_start) - ] @punctuation.delimiter - -[ - "$" -] @punctuation.special + "&" +] @punctuation.delimiter [ ">" ">>" "<" "<<" - "&" "&&" "|" "||" @@ -38,7 +23,7 @@ "=~" "==" "!=" - ] @operator +] @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, @@ -48,8 +33,14 @@ (raw_string) (ansi_c_string) (heredoc_body) + (simple_heredoc_body) ] @string +[ + (heredoc_start) + (heredoc_end) +] @label + (variable_assignment (word) @string) [ @@ -61,7 +52,7 @@ "case" "in" "esac" - ] @conditional +] @conditional [ "for" @@ -70,7 +61,7 @@ "select" "until" "while" - ] @repeat +] @repeat [ "declare" @@ -78,7 +69,7 @@ "local" "readonly" "unset" - ] @keyword +] @keyword "function" @keyword.function @@ -89,17 +80,26 @@ (#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) @string -(command_substitution - [ "$(" ")" ] @punctuation.bracket) +(test_operator) @operator + +(command_substitution "$(" @punctuation.bracket) +(process_substitution "<(" @punctuation.bracket) + +(arithmetic_expansion + [ "$((" "((" ] @punctuation.special + "))" @punctuation.special) + +(arithmetic_expansion "," @punctuation.delimiter) -(process_substitution - [ "<(" ")" ] @punctuation.bracket) +(ternary_expression [ "?" ":" ] @conditional.ternary) +(binary_expression operator: _ @operator) +(unary_expression operator: _ @operator) +(postfix_expression operator: _ @operator) (function_definition name: (word) @function) @@ -124,15 +124,27 @@ (concatenation (word) @parameter) ]) +(number) @number ((word) @number - (#lua-match? @number "^[0-9]+$")) + (#lua-match? @number "^[0-9]+$")) (file_redirect descriptor: (file_descriptor) @operator destination: (word) @parameter) +(simple_expansion + "$" @punctuation.special) @none (expansion - [ "${" "}" ] @punctuation.bracket) + "${" @punctuation.special + "}" @punctuation.special) @none + +(expansion operator: _ @punctuation.special) +(expansion "@" . operator: _ @character.special) + +((expansion + (subscript + index: (word) @character.special)) + (#any-of? @character.special "@" "*")) (variable_name) @variable @@ -145,4 +157,4 @@ (regex) @string.regex ((program . (comment) @preproc) - (#lua-match? @preproc "^#!/")) + (#lua-match? @preproc "^#!/")) diff --git a/tests/query/highlights/bash/double-parens.sh b/tests/query/highlights/bash/double-parens.sh index 7ba35873e..1f7aee4e4 100644 --- a/tests/query/highlights/bash/double-parens.sh +++ b/tests/query/highlights/bash/double-parens.sh @@ -1,6 +1,6 @@ if (( $(tree-sitter parse test/Petalisp/**/*.lisp -q | wc -l) > 2 )); then -# ^ punctuation.bracket -# ^ punctuation.bracket +# ^ punctuation.special +# ^ punctuation.special # ^ punctuation.bracket exit 1 fi |
