Repository navigation
Fix unhighlighted keywords in Lua, Kotlin, Scala, SQL and Objective-C - #57
Draft
tomtommyyuan wants to merge 1 commit into
Draft
tomtommyyuan wants to merge 1 commit into
tomtommyyuan wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,whileandtrystayed 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_coloronly gave the keyword color to captures namedkeywordorkeyword.*. The highlight queries that arborium bundles for these five languages tag those keywords@conditional,@repeat,@exceptionand@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 thetext.*names in the Markdown query.Keywords that are now highlighted:
if/elseif/else/then,for,while,repeat/until, and thedo/endthat go with themif/else/when,for/do/while,try/catch/finallyif/then/else/match,for/while/do/yield,try/catch/throw,import/exportCASE/WHEN/THEN/ELSE@try/@catch/@finally/@throw,@importI 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
ready-to-specorready-to-implement.Testing
I added
legacy_keyword_captures_use_keyword_colorincrates/syntax_tree/src/queries/highlight_query_tests.rs. It highlights short Lua, Kotlin and Scala snippets with the bundled grammars and checks thatif,while,try,catchandimportget 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 passedcargo clippy -p syntax_tree --all-targets --tests -- -D warnings: clean./script/format: no changesI 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.
./script/runScreenshots / Videos
Lua, before (master):
Lua, after:
Kotlin, before (master):
Kotlin, after:
Agent Mode
CHANGELOG-BUG-FIX: Fixed some keywords (such as
if,for,whileandtry) not being syntax highlighted in Lua, Kotlin, Scala, SQL and Objective-C files.🤖 Generated with Claude Code