Skip to content

Commit

Permalink
lua: Update keyword operator highlighting (#26091)
Browse files Browse the repository at this point in the history
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 813e207 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 | 
| --- | --- |
| <img width="309" alt="old"
src="https://github.com/user-attachments/assets/7790817e-4a0d-442b-b176-9a84bcc6f3c4"
/> | <img width="309" alt="PR"
src="https://github.com/user-attachments/assets/34a57962-938a-4465-9406-288f5c456aa3"
/> |


Release Notes:

- N/A

---------

Co-authored-by: Peter Tripp <[email protected]>
  • Loading branch information
MrSubidubi and notpeter authored Mar 6, 2025
1 parent 06a226d commit efaf358
Showing 1 changed file with 12 additions and 63 deletions.
75 changes: 12 additions & 63 deletions extensions/lua/languages/lua/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,82 +1,31 @@
;; 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

[
"and"
"not"
"or"
] @operator
] @keyword.operator

[
"+"
Expand Down

0 comments on commit efaf358

Please sign in to comment.