aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries
diff options
context:
space:
mode:
authorwoojiq2024-01-22 18:51:12 +0000
committerGitHub2024-01-22 18:51:12 +0000
commit52a43bcdfcc258a2871be468a3e31496dd2d80c8 (patch)
treef64129bdc20d6ca26f49a35eec85eb9e0935404d /runtime/queries
parentf5f08becef0c27f183a7772f6ec6f5442eca2bab (diff)
bash, make, css: highlight and indent queries improvement (#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.
Diffstat (limited to 'runtime/queries')
-rw-r--r--runtime/queries/bash/highlights.scm34
-rw-r--r--runtime/queries/css/indents.scm7
-rw-r--r--runtime/queries/make/indents.scm8
3 files changed, 39 insertions, 10 deletions
diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm
index 3f2df638..92d61e8b 100644
--- a/runtime/queries/bash/highlights.scm
+++ b/runtime/queries/bash/highlights.scm
@@ -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)
diff --git a/runtime/queries/css/indents.scm b/runtime/queries/css/indents.scm
new file mode 100644
index 00000000..1dfd977d
--- /dev/null
+++ b/runtime/queries/css/indents.scm
@@ -0,0 +1,7 @@
+[
+ (block)
+] @indent
+
+[
+ "}"
+] @outdent
diff --git a/runtime/queries/make/indents.scm b/runtime/queries/make/indents.scm
new file mode 100644
index 00000000..42b2c60e
--- /dev/null
+++ b/runtime/queries/make/indents.scm
@@ -0,0 +1,8 @@
+[
+ (define_directive)
+ (rule)
+] @indent
+
+[
+ "endef"
+] @outdent