Skip to content

Fix unhighlighted keywords in Lua, Kotlin, Scala, SQL and Objective-C - #57

Draft
tomtommyyuan wants to merge 1 commit into
warpdotdev:masterfrom
tomtommyyuan:highlight-control-flow-keywords
Draft

tomtommyyuan wants to merge 1 commit into
warpdotdev:masterfrom
tomtommyyuan:highlight-control-flow-keywords

Conversation

@tomtommyyuan

@tomtommyyuan tomtommyyuan commented Nov 11, 2026 •

Copy link
Copy Markdown

Description

I will open the matching issue and link it here before marking this ready for review.

In the code editor, keywords such as if, for, while and try stayed in the default text color in Lua, Kotlin, Scala, SQL and Objective-C files, while other keywords in the same file (local, fun, return) were colored.

convert_capture_name_to_color only gave the keyword color to captures named keyword or keyword.*. The highlight queries that arborium bundles for these five languages tag those keywords @conditional, @repeat, @exception and @include, so they got no color. This change maps those four names to the keyword color. Commit dfabfa5 (Markdown highlighting) extended the same function in the same way for the text.* names in the Markdown query.

Keywords that are now highlighted:

  • Lua: if / elseif / else / then, for, while, repeat / until, and the do / end that go with them
  • Kotlin: if / else / when, for / do / while, try / catch / finally
  • Scala: if / then / else / match, for / while / do / yield, try / catch / throw, import / export
  • SQL: CASE / WHEN / THEN / ELSE
  • Objective-C: @try / @catch / @finally / @throw, @import

I compared the highlights with and without the change on a sample in each of the five languages. The only differences are the keywords above going from no color to the keyword color; nothing that was already colored changes. No other bundled grammar uses these four names.

Updating arborium would not fix this, because 2.18.2 (the latest release) still uses these names. The same grammars also use legacy names for method calls (@method) and float literals (@float). I left those out to keep this change to keywords.

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

I added legacy_keyword_captures_use_keyword_color in crates/syntax_tree/src/queries/highlight_query_tests.rs. It highlights short Lua, Kotlin and Scala snippets with the bundled grammars and checks that if, while, try, catch and import get the keyword color. It fails on master (assertion `left == right` failed: `if` should be highlighted as a keyword in lua) and passes with this change.

  • cargo nextest run -p syntax_tree: 8 passed
  • cargo clippy -p syntax_tree --all-targets --tests -- -D warnings: clean
  • ./script/format: no changes

I did not run the full workspace test suite.

For the screenshots I opened each file from the project explorer through the integration test runner with a real display, once on master (aba413f) and once with this change. The temporary test I used for that is not part of this PR.

  • I have manually tested my changes locally with ./script/run

Screenshots / Videos

Lua, before (master):

sample.lua on master: if, then, elseif, else, for, while, repeat, until, do and end are not highlighted

Lua, after:

sample.lua with this change: every keyword is highlighted

Kotlin, before (master):

sample.kt on master: if, else, for, while, try, catch, finally and when are not highlighted

Kotlin, after:

sample.kt with this change: those keywords are highlighted

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: Fixed some keywords (such as if, for, while and try) not being syntax highlighted in Lua, Kotlin, Scala, SQL and Objective-C files.

🤖 Generated with Claude Code

The highlight queries bundled for these languages tag keywords such as
`if`, `for`, `while` and `try` with the legacy capture names
`conditional`, `repeat`, `exception` and `include`, which were not mapped
to a color. Map them to the keyword color.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant