From a4cf5aa29ebd9d64c64fa228fc818bb6b9bcd114 Mon Sep 17 00:00:00 2001 From: liam Date: Thu, 14 May 2026 12:17:52 -0400 Subject: [PATCH] Highlight bash conditionals and arithmetic operators (#56484) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves https://github.com/zed-industries/zed/issues/56478 This diff fixes Bash syntax highlighting for conditional and arithmetic expressions. The Bash parser already recognizes tokens like `[[`, `]]`, `((`, `))`, `$((`, `!=`, and `||`, but Zed’s Bash highlight query was not capturing several of them. With this change, the Bash highlight query styles those operators and delimiters consistently with existing shell operators, brackets, and special punctuation. | Before | After | | --- | --- | | ayu-old | ayu-new | Release Notes: - Fixed bash syntax highlighting for conditional expressions, arithmetic expressions, and related operators. --- crates/grammars/src/bash/highlights.scm | 49 +++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/crates/grammars/src/bash/highlights.scm b/crates/grammars/src/bash/highlights.scm index bc1c3b7ec1..c67b34e92c 100644 --- a/crates/grammars/src/bash/highlights.scm +++ b/crates/grammars/src/bash/highlights.scm @@ -72,6 +72,7 @@ [ "$" "&&" + "||" ">" "<<" ">>" @@ -86,8 +87,36 @@ "%%" "#" "##" + "+=" + "-=" + "*=" + "/=" + "%=" + "**=" + "<<=" + ">>=" + "&=" + "^=" + "|=" "=" + "=~" "==" + "!=" + "-o" + "-a" + "^" + "&" + "<=" + ">=" + "+" + "-" + "*" + "**" + "!" + "++" + "--" + "~" + "?" ] @operator (test_operator) @keyword.operator @@ -103,6 +132,18 @@ "]" ] @punctuation.bracket +(test_command + [ + "[[" + "]]" + ] @punctuation.bracket) + +(compound_statement + [ + "((" + "))" + ] @punctuation.bracket) + (simple_expansion "$" @punctuation.special) @@ -114,6 +155,14 @@ "$(" @punctuation.special ")" @punctuation.special) +(arithmetic_expansion + [ + "$((" + "$[" + "))" + "]" + ] @punctuation.special) + ((command (_) @constant) (#match? @constant "^-"))