Skip to content

Commit

Permalink
highlights(bash): rework keywords section
Browse files Browse the repository at this point in the history
* Use more specified scope when possible for keywords like @keyword.repeat.
* Add more keywords like "local" or "unsetenv".

Limitation:
* Bash doesn't allow you to have a local variable outside of a function, so maybe we need to have better queries to not highlight the local in this case.
* If we name a function with a keyword (such as unset or local), it will use the highlight scope "keyword" instead of "function".
  • Loading branch information
woojiq committed Jan 21, 2024
1 parent 17dd102 commit 579e55d
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions runtime/queries/bash/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,37 @@
(variable_name) @variable.other.member

[
"if"
"then"
"else"
"elif"
"fi"
"case"
"in"
"esac"
] @keyword.control.conditional

[
"for"
"do"
"done"
"elif"
"else"
"esac"
"select"
"until"
"while"
] @keyword.control.repeat

[
"declare"
"typeset"
"export"
"fi"
"for"
"function"
"if"
"in"
"readonly"
"local"
"unset"
"while"
"then"
"unsetenv"
] @keyword

"function" @keyword.function

(comment) @comment

(function_definition name: (word) @function)
Expand Down

0 comments on commit 579e55d

Please sign in to comment.