Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for querying workspace symbols and filtering by kind #941

Closed
lanza opened this issue Mar 7, 2020 · 9 comments
Closed

Add support for querying workspace symbols and filtering by kind #941

lanza opened this issue Mar 7, 2020 · 9 comments
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities workspace symbols

Comments

@lanza
Copy link

lanza commented Mar 7, 2020

It would be nice to be able to filter WorkspaceSymbols by kind instead of just by query string. Most LSPs implement the query as some sort of search over the symbol name. If you are specifically looking for an class type, for example, WorkspaceSymbols provides mostly noise.

interface WorkspaceSymbolParams extends WorkDoneProgressParams, PartialResultParams {
	/**
	 * A query string to filter symbols by. Clients may send an empty
	 * string here to request all symbols.
	 */
	query: string;
        kind: string;
}
@dbaeumer
Copy link
Member

dbaeumer commented Mar 9, 2020

I like this. @jrieken have you heard about such a request in the light of the VS Code API?

@dbaeumer dbaeumer added this to the On Deck milestone Mar 9, 2020
@dbaeumer dbaeumer added the feature-request Request for new features or functionality label Mar 9, 2020
@jrieken
Copy link
Member

jrieken commented Mar 9, 2020

No, nothing like this has been requested in VSCode and for us it would be more of a UX challenge of how to entering such a filter

@lanza
Copy link
Author

lanza commented Mar 12, 2020

Thinking about this some more, I think a general key, value list of options would be reasonable to pass in general.

interface WorkspaceSymbolParams extends WorkDoneProgressParams, PartialResultParams {
	/**
	 * A query string to filter symbols by. Clients may send an empty
	 * string here to request all symbols.
	 */
	query: string;
        options: json; (sorry I don't know TypeScript)
}

kind, maxCount, folders, rootSymbol are examples that could potentially be desired.

  • kind to search for a specific symbol kind (coc.nvim has this)
  • maxCount to put a maximum on the number of symbols returned. (ccls uses this)
  • folders to define a list of folders to restrict symbol search from (ccls uses this)
  • rootSymbol no implementors AFAIK but this could be useful for searching for symbols "owned" by some other symbol via inheritance, member variables, member functions, subtypes, etc.

I'm sure there are more ideas. But a general purpose symbol querying mechanism seems useful for the LSP.

@dbaeumer dbaeumer added discussion help wanted Issues identified as good community contribution opportunities labels Mar 12, 2020
@matklad
Copy link
Contributor

matklad commented Apr 18, 2020

Yes please, this is one of the things I miss most coming from IntelliJ. I've hacked this on for rust-analyzer using # and * magic symbols in the query string to select the type, but that understandably got broken with the latest release of VS Code, which now allows several filters itself.

IntelliJ uses the following filters, which seems reasonable:

  • Types / all symbols (most of the times you are looking for a Type, and there are fewer types than symbols)
  • Your code / dependencies (most of the time you look for symbol in your code, but peeking into, eg, stdlib is occasionally useful)
  • Production code / test code (again, usually you don't want tests, but sometimes you do)

UI-wise, I'd expect a set of checkboxes with alt-mnemonics below the widget for common filters, plus maybe some free-way advanced query syntax, for cases like "I want to find all public functions with name starting with set_ in descendatns of ActiveRecord class".

@jrieken
Copy link
Member

jrieken commented Apr 20, 2020

fyi @bpasero - we recently talked about this

@heartacker
Copy link

heartacker commented Aug 18, 2020

Yes please, this is one of the things I miss most coming from IntelliJ. I've hacked this on for rust-analyzer using # and * magic symbols in the query string to select the type, but that understandably got broken with the latest release of VS Code, which now allows several filters itself.

IntelliJ uses the following filters, which seems reasonable:

  • Types / all symbols (most of the times you are looking for a Type, and there are fewer types than symbols)
  • Your code / dependencies (most of the time you look for symbol in your code, but peeking into, eg, stdlib is occasionally useful)
  • Production code / test code (again, usually you don't want tests, but sometimes you do)

UI-wise, I'd expect a set of checkboxes with alt-mnemonics below the widget for common filters, plus maybe some free-way advanced query syntax, for cases like "I want to find all public functions with name starting with set_ in descendatns of ActiveRecord class".

are your talking about something like VS. that's great if adopted by vscode
image

@KamasamaK
Copy link
Contributor

@lanza This seemed like a good request. Why close this?

@matu3ba
Copy link

matu3ba commented Dec 29, 2021

@KamasamaK

Searching+Filtering for all symbols can take a significant and unexpected amount of time, if the language is not strongly typed.
Timeouts for queries would fill the gap, but would be possibly very hard to generalize over implementations,
so likely lsp doesnt want to deal with churn of lsp timeouts due to type resolving or generics stuff.

@matklad
Copy link
Contributor

matklad commented Dec 29, 2021

Not really: filtering is typically based on syntactic type (is this syntactically a function, a class, etc). Language typing rules or lack thereof are orthogonal to the discussed feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities workspace symbols
Projects
None yet
Development

No branches or pull requests

7 participants