fix(zed): repair Python highlights query for Zed's bundled grammar#195
Merged
Conversation
The Python language failed to register in Zed — `failed to load language Python: Error loading highlights query` — which also blocks the basilisk LSP from attaching, so the extension did nothing for Python files. `languages/python/highlights.scm` contained three patterns written against a newer tree-sitter-python than Zed bundles: - `["except*"]` (PEP 654) — invalid node type; `except` is already covered by the keyword list, so the query is dropped. - `(type_parameter (identifier) @type)` (PEP 695 generics) — impossible pattern against Zed's grammar; dropped. - `(string (escape_sequence) ...)` — impossible pattern (escape sequences are not direct children of `string` in Zed's grammar); rewritten to the grammar-agnostic `(escape_sequence) @string.escape`. Verified against the running editor: Python now registers with zero query errors and the basilisk language server attaches (test discovery runs).
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.
TLDR
Fixes the Zed extension doing nothing for Python files: a broken tree-sitter highlights query was preventing the Python language from registering, which also blocked the basilisk LSP from attaching.
What Was Changed or Deleted?
basilisk-zed/languages/python/highlights.scmhad three patterns written against a newertree-sitter-pythonthan Zed bundles, so loading the query failed (failed to load language Python: Error loading highlights query) and the whole Python language — highlighting and language-server attachment — never came up:["except*"](PEP 654 exception groups) — invalid node type. Removed; theexceptkeyword is already highlighted via the keyword list.(type_parameter (identifier) @type)(PEP 695 generics) — impossible pattern against Zed's grammar. Removed.(string (escape_sequence) @string.escape)— impossible pattern (escape sequences aren't direct children ofstringin Zed's grammar). Rewritten to the grammar-agnostic(escape_sequence) @string.escape, preserving escape highlighting.Net: −7/+1 lines, one file.
How Do The Automated Tests Prove It Works?
Tree-sitter queries are compiled by the editor at runtime, not by any CI job, so this was verified against the running Zed editor: after the change,
Zed.logshows the Python language registering with zero query errors (previouslyQuery error … Invalid node type "except*"), and the basilisk language server attaches — test discovery runs and enumerates the workspace'spytesttests. Before the fix, no language server attached at all.Breaking Changes