refactor(common): consolidate treesitter extension-to-language mapping - #6225
Merged
Conversation
zeph_common::treesitter::lang_for_ext had zero call sites outside its own
definition, while zeph-index::languages::detect_language and
zeph-tools::search_code::lang_info_for_path each hand-rolled their own
independent extension-to-language mapping that had already drifted apart.
Extend lang_for_ext to the full 9-extension set both crates need (bash/sh/zsh,
toml, json/jsonc, md/markdown, in addition to the existing 5) and route both
consumers through it, including Lang::grammar() which was a byte-for-byte
duplicate of the same mapping keyed by enum variant instead of extension.
Remove the now-unused direct tree-sitter-{bash,json,md,toml-ng} dependencies
from zeph-index and zeph-tools; they flow through zeph-common's treesitter
feature instead.
Closes #5971
bug-ops
enabled auto-merge (squash)
July 13, 2026 16:56
bug-ops
force-pushed
the
fix/5971-treesitter-lang-dedup
branch
from
July 13, 2026 16:56
dc203ef to
c899a17
Compare
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.
Summary
zeph_common::treesitter::lang_for_exthad zero call sites outside its own definition, whilezeph-index::languages::detect_languageandzeph-tools::search_code::lang_info_for_patheach hand-rolled their own independent extension-to-language mapping — the two had already drifted apart from each other and from the "shared" helper.lang_for_extto the full 9-extension set both crates need (addedbash/sh/zsh,toml,json/jsonc,md/markdownto the existing 5) and routed both consumers through it as the single source of truth.zeph-index::languages::Lang::grammar()tolang_for_ext— it was a byte-for-byte duplicate of the same mapping keyed by enum variant instead of extension (same duplication shape, same file; signed off by critic and tester as a legitimate, minimal extension of the fix rather than scope creep).tree-sitter-{bash,json,md,toml-ng}dependencies fromzeph-indexandzeph-tools; they now flow throughzeph-common'streesitterfeature.No behavior change — extension coverage is identical to before (verified by direct old-vs-new diff read, not just re-running the existing suite), symbol-query pairing (
RUST_SYM_Qetc.) inzeph-toolsis untouched and stays separate from the extension→grammar mapping.Closes #5971
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(13452 passed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"gitleaks protect --stagedlang_for_ext,detect_language,Lang::grammar(), andlang_info_for_path