Skip to content

fix(zed): repair Python highlights query for Zed's bundled grammar#195

Merged
abdushakoor12 merged 1 commit into
mainfrom
fix/zed-python-highlights
Jun 26, 2026
Merged

fix(zed): repair Python highlights query for Zed's bundled grammar#195
abdushakoor12 merged 1 commit into
mainfrom
fix/zed-python-highlights

Conversation

@abdushakoor12

Copy link
Copy Markdown
Collaborator

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.scm had three patterns written against a newer tree-sitter-python than 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; the except keyword 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 of string in 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.log shows the Python language registering with zero query errors (previously Query error … Invalid node type "except*"), and the basilisk language server attaches — test discovery runs and enumerates the workspace's pytest tests. Before the fix, no language server attached at all.

Breaking Changes

  • None

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).
@abdushakoor12 abdushakoor12 merged commit 884e3a3 into main Jun 26, 2026
22 checks passed
@abdushakoor12 abdushakoor12 deleted the fix/zed-python-highlights branch June 26, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant