microsoft / microsoft/language-server-protocol

Proposal: Allow servers to customize the matching behavior of workspace symbols

Open
#2,091 4 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request workspace symbols
Dominant language
TypeScript
Stars
13k
Forks
1k
Avg merge
6d 1h
Merged PRs (30d)
10

Description

A server may want to have a its own grammar for a workspace symbols request. For example, rust-analyzer supports * and # modifiers (meaning search in dependencies and search non-types, respectively), and I want to extend it to support fully-qualified searches, aka. foo::bar::Baz that will search Baz in bar module in foo.

Such search does not currently work in VSCode (but does in other clients), because VSCode self-filters the responses if they don't fully contain the query. That is solvable; I implemented a fix for that in VSCode. The problem is that even with this fix, VSCode (and probably other clients too) score and highlight results based on the query, which leads to non-ideal result, like searching for string::string brings the obvious full-match std::string::String (displayed to VSCode as String) be shown way after StringTooLongError, because the latter also match, in addition to the full String, "tng" from the second string, so it has a higher score. Plus the tng are highlighted, which looks very strange.

I propose we allow servers to redefine the query, that is, send the client the part they should match against. In particular, extend the protocol with the following properties:

interface WorkspaceSymbolClientCapabilities {
    /**
     * Support for a response of type `WorkspaceSymbols`.
     */
    objectResponse: boolean;

    // ...
}

/**
 * The response of a Workspace Symbols Request.
 */
interface WorkspaceSymbols {
    /**
     * The query to match and score against. Usually this is part of or the full `WorkspaceSymbolParams.query`.
     */
    query: string;

    /**
     * The list of symbols.
     */
    symbols: SymbolInformation[] | WorkspaceSymbol[];
}

And define the type of a response to a Workspace Symbols Request to be WorkspaceSymbols | SymbolInformation[] | WorkspaceSymbol[] | null.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the WorkspaceSymbolClientCapabilities and Workspace Symbols Request definitions in the protocol, then trace the current response types for workspace symbol requests. Compare the proposed WorkspaceSymbols shape with the existing SymbolInformation[] and WorkspaceSymbol[] alternatives. Done means the protocol clearly represents the optional query used for client matching while preserving the existing response forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.