Skip to content

Commit

Permalink
bash, make, css: highlight and indent queries improvement (helix-edit…
Browse files Browse the repository at this point in the history
…or#9393)

* highlights(bash): rework keywords section

* 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".

* indents(css, make): add basic queries

* Despite the fact that queries look simple, they improve indentation in some edge cases that helix couldn't handle correctly by default.
  • Loading branch information
woojiq authored and mtoohey31 committed Jun 2, 2024
1 parent 2dee631 commit 0e1cd6a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
4 changes: 2 additions & 2 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| cpon || || |
| cpp |||| `clangd` |
| crystal ||| | `crystalline` |
| css || | | `vscode-css-language-server` |
| css || | | `vscode-css-language-server` |
| cue || | | `cuelsp` |
| d |||| `serve-d` |
| dart || || `dart` |
Expand Down Expand Up @@ -97,7 +97,7 @@
| log || | | |
| lpf || | | |
| lua |||| `lua-language-server` |
| make || | | |
| make || | | |
| markdoc || | | `markdoc-ls` |
| markdown || | | `marksman` |
| markdown.inline || | | |
Expand Down
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
7 changes: 7 additions & 0 deletions runtime/queries/css/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
(block)
] @indent

[
"}"
] @outdent
8 changes: 8 additions & 0 deletions runtime/queries/make/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
(define_directive)
(rule)
] @indent

[
"endef"
] @outdent

0 comments on commit 0e1cd6a

Please sign in to comment.