From 579e55d7d45867d8e9a9738fa0c9d04abeab93e2 Mon Sep 17 00:00:00 2001 From: woojiq Date: Sun, 21 Jan 2024 10:39:13 +0200 Subject: [PATCH] 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". --- runtime/queries/bash/highlights.scm | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/runtime/queries/bash/highlights.scm b/runtime/queries/bash/highlights.scm index 3f2df63867d6..92d61e8b83e0 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)