Skip to content

Commit d0a0303

Browse files
authored
Improve Bash syntax highlighting (#25324)
Release Notes: - Improved Bash syntax highlighting | Zed 0.174.6 | With this PR | | --- | --- | | ![Image](https://github.com/user-attachments/assets/ecff952a-c10c-447a-8a99-ebd4ac6d6936) | ![Image](https://github.com/user-attachments/assets/37568a83-f32c-4d4c-bd9a-3ebbe9aa40ae) | - `string`: `string` - `variable`: `property` -> `variable` - `number`: `number` - `regex`: `string.regex` - `>&`, `>&-`, `:`, `//`, `/`, `%`, `%%`, `#`, `##`, `=`, `==`: `operator` - `-lt`, `-le`, `-gt`, `-ge`, `-eq`, `-ne`, `-z`, `-n`: `keyword.operator` - `;`: `punctuation.delimiter` - `(`, `)`, `{`, `}`, `[`, `]`: `punctuation.bracket` - `$`, `${ }`, `$( )`: `punctuation.special`, as defined in other languages ```bash variable=I\ like\ Zed function my_function() { echo "Hello world, ${variable//regex/string}" > file } if [ $(uid) -lt 600 ]; then my_function; cat file | grep hello >&3 fi ```
1 parent a4ade37 commit d0a0303

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

crates/languages/src/bash/highlights.scm

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
(heredoc_body)
55
(heredoc_start)
66
(ansi_c_string)
7+
(word)
78
] @string
89

9-
(command_name) @function
10-
11-
(variable_name) @property
10+
(variable_name) @variable
1211

1312
[
1413
"case"
@@ -35,24 +34,67 @@
3534
(comment) @comment
3635

3736
(function_definition name: (word) @function)
37+
(command_name (word) @function)
38+
39+
[
40+
(file_descriptor)
41+
(number)
42+
] @number
3843

39-
(file_descriptor) @number
44+
(regex) @string.regex
4045

4146
[
4247
(command_substitution)
4348
(process_substitution)
4449
(expansion)
45-
]@embedded
50+
] @embedded
51+
4652

4753
[
4854
"$"
4955
"&&"
5056
">"
5157
">>"
58+
">&"
59+
">&-"
5260
"<"
5361
"|"
62+
":"
63+
"//"
64+
"/"
65+
"%"
66+
"%%"
67+
"#"
68+
"##"
69+
"="
70+
"=="
5471
] @operator
5572

73+
(test_operator) @keyword.operator
74+
75+
[
76+
";"
77+
] @punctuation.delimiter
78+
79+
[
80+
"("
81+
")"
82+
"{"
83+
"}"
84+
"["
85+
"]"
86+
] @punctuation.bracket
87+
88+
(simple_expansion
89+
"$" @punctuation.special)
90+
(expansion
91+
"${" @punctuation.special
92+
"}" @punctuation.special) @embedded
93+
94+
(command_substitution
95+
"$(" @punctuation.special
96+
")" @punctuation.special)
97+
5698
(
5799
(command (_) @constant)
58100
(#match? @constant "^-")

0 commit comments

Comments
 (0)