Skip to content

Extract SymbolIndex to project crate for Tree-sitter based symbol search - #45719

Closed
portseif wants to merge 2 commits into
zed-industries:mainfrom
portseif:symbol-index-extraction
Closed

Extract SymbolIndex to project crate for Tree-sitter based symbol search#45719
portseif wants to merge 2 commits into
zed-industries:mainfrom
portseif:symbol-index-extraction

Conversation

@portseif

Copy link
Copy Markdown

Summary

Extracts the symbol indexing functionality from Search Everywhere into a reusable symbol_index module in the project crate. This enables Tree-sitter based symbol search for languages that don't have LSP support.

Key changes:

  • New symbol_index.rs module in crates/project/
  • SymbolIndex struct with cached symbols per project
  • Incremental updates via buffer and worktree subscriptions
  • search() function for fuzzy matching symbols
  • Indexes outline items from Tree-sitter (works without LSP)

This is a foundational piece that can be used by Search Everywhere and potentially other features that need project-wide symbol access.

Test plan

  • Build passes (./script/clippy -p project)
  • Manual testing with Search Everywhere using the new API

This adds a new `symbol_index` module to the project crate that provides
symbol search functionality using Tree-sitter outline extraction. This
allows symbol search to work for languages without LSP support.

Features:
- Global symbol cache keyed by project entity ID
- Background indexing with progress tracking
- Incremental updates via buffer reparsing and worktree events
- Fuzzy search over indexed symbols

This is a foundation for integrating Tree-sitter symbols with
Project::symbols to provide fallback when LSP is unavailable.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Dec 26, 2025
@maxbrunsfeld

Copy link
Copy Markdown
Collaborator

I am open to this change. My requirements:

  • Biggest question - To merge this, it will need to already be exposed as an end-user-facing feature somehow. I think the "Search Everywhere" thing does not exist yet. @portseif How do you envision this working, given that we often have LSP-based symbol search? Would we only index the files that are not covered by an LSP? Or do we index all files, and show both sets of symbols, de-duped somehow?
  • I'd like this to live in a separate crate, not project. I know a lot of stuff lives in project, but we want to move stuff out, as project is so central on the crate graph.
  • This will need to handle files changing on disk (e.g. I run git pull, lots of symbols change), not just open buffers being edited.
  • Efficiency of updates is going to be important. When the project is huge (e.g. chromium, linux), how do we efficiently update the index when one file changes? Currently, it seems like rebuild_all_symbols would be very slow.
  • This will need good tests. The tests need to exercise files updating, editing buffers etc.

@maxbrunsfeld maxbrunsfeld left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left my changes in the comment above.

@maxbrunsfeld

Copy link
Copy Markdown
Collaborator

I'm going to close this out for now. Feel free to open a new PR if you want to keep working toward addressing the feedback. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants