From efaf3588763d8960f5c4200108b15f706dde16dd Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Fri, 7 Mar 2025 00:01:13 +0100 Subject: [PATCH] lua: Update keyword operator highlighting (#26091) Resolves #26032 This PR changes the highlighting for `and`, `not` and `or` in Lua from `operator` to `keyword.operator`. [VS Code also highlights these as keyword operators](https://github.com/LuaLS/lua.tmbundle/blob/1483add845ebfb3e1e631fe372603e5fed2cdd42/Syntaxes/Lua.plist#L277-L279) and Zed does this for other languages as well, like [Python](https://github.com/zed-industries/zed/blob/813e207514f76ec3f8bc8bbb649deaafa304de9e/crates/languages/src/python/highlights.scm#L221-L229) or [Zig](https://github.com/zed-industries/zed/blob/813e207514f76ec3f8bc8bbb649deaafa304de9e/extensions/zig/languages/zig/highlights.scm#L145-L149). Additionally, in 813e207514f76ec3f8bc8bbb649deaafa304de9e I removed duplicate matches for existing keywords to improve readability and align them to how keywords are generally matched across languages (see [Rust](https://github.com/zed-industries/zed/blob/813e207514f76ec3f8bc8bbb649deaafa304de9e/crates/languages/src/rust/highlights.scm#L79-L119) and [Typescript](https://github.com/zed-industies/zed/blob/813e207514f76ec3f8bc8bbb649deaafa304de9e/crates/languages/src/typescript/highlights.scm#L210-L269) for example). Whilst contributing to the majority of the diff, this does not change any existing highlights. | Before | After | | --- | --- | | old | PR | Release Notes: - N/A --------- Co-authored-by: Peter Tripp --- extensions/lua/languages/lua/highlights.scm | 75 ++++----------------- 1 file changed, 12 insertions(+), 63 deletions(-) diff --git a/extensions/lua/languages/lua/highlights.scm b/extensions/lua/languages/lua/highlights.scm index 7b0b8364ea..f56b46338e 100644 --- a/extensions/lua/languages/lua/highlights.scm +++ b/extensions/lua/languages/lua/highlights.scm @@ -1,74 +1,23 @@ ;; Keywords -"return" @keyword - -[ - "goto" - "in" - "local" -] @keyword - -(break_statement) @keyword - -(do_statement [ "do" - "end" -] @keyword) - -(while_statement -[ - "while" - "do" - "end" -] @keyword) - -(repeat_statement -[ - "repeat" - "until" -] @keyword) - -(if_statement -[ - "if" - "elseif" "else" - "then" - "end" -] @keyword) - -(elseif_statement -[ "elseif" - "then" "end" -] @keyword) - -(else_statement -[ - "else" - "end" -] @keyword) - -(for_statement -[ "for" - "do" - "end" -] @keyword) - -(function_declaration -[ "function" - "end" -] @keyword) - -(function_definition -[ - "function" - "end" -] @keyword) + "goto" + "if" + "in" + "local" + "repeat" + "return" + "then" + "until" + "while" + (break_statement) +] @keyword ;; Operators @@ -76,7 +25,7 @@ "and" "not" "or" -] @operator +] @keyword.operator [ "+"