Skip to content

lsp symbol search show context #2695

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

Open
hesxenon opened this issue Sep 8, 2023 · 9 comments · May be fixed by #3447
Open

lsp symbol search show context #2695

hesxenon opened this issue Sep 8, 2023 · 9 comments · May be fixed by #3447
Labels
enhancement Enhancement to performance, inner workings or existent features

Comments

@hesxenon
Copy link

hesxenon commented Sep 8, 2023

Is your feature request related to a problem? Please describe.
When structuring code around modules instead of uniquely named functions it's common to have multiple functions with the same name. Not being able to tell what the enclosing scope of the symbol is makes it harder than necessary to navigate.

Describe the solution you'd like
The same as vscode or ionide: display the enclosing scope next to the suggested symbol. E.g. given a function add in a Post namespace the suggestion could look like add (Post) or something alike.

Describe alternatives you've considered
Checking how lsp servers send suggestions, but since vscode uses the same lsp server as my nvim instance that should not be where the problem is.

Additional context
I think ionide-vim already does this, but IIRC they don't offer a telescope integration 🤔

@hesxenon hesxenon added the enhancement Enhancement to performance, inner workings or existent features label Sep 8, 2023
@cristiansofronie
Copy link
Contributor

What picker do you refer to?

@hesxenon
Copy link
Author

hesxenon commented Sep 8, 2023

all builtin lsp symbol pickers, lsp_document_symbols, lsp_workspace_symbols and lsp_dynamic_workspace_symbols.

@cristiansofronie
Copy link
Contributor

It would be useful if you would give a screenshot of the thing you are talking about from ionide-vim.

@cristiansofronie
Copy link
Contributor

The textDocument/documentSymbol request has a return type of something that inherits from lsp.BaseSymbolInformation which has the fields:

---Provider options for a {@link DocumentHighlightRequest}.
---@class lsp.DocumentHighlightOptions

---A base for all symbol information.
---@class lsp.BaseSymbolInformation
---The name of this symbol.
---@field name string
---The kind of this symbol.
---@field kind lsp.SymbolKind
---Tags for this symbol.
---
---@since 3.16.0
---@field tags? lsp.SymbolTag[]
---The name of the symbol containing this symbol. This information is for
---user interface purposes (e.g. to render a qualifier in the user interface
---if necessary). It can't be used to re-infer a hierarchy for the document
---symbols.
---@field containerName? string

---Provider options for a {@link DocumentSymbolRequest}.
---@class lsp.DocumentSymbolOptions
---A human-readable string that is shown when multiple outlines trees
---are shown for the same document.
---
---@since 3.16.0
---@field label? string

So the container name could be used for what you need but you need to tell me how it is shown in ionide-vim to know how to format them.

@cristiansofronie
Copy link
Contributor

The requests in Ionide-vim seem to be fsharp specific. For example rather making a textDocument/documentSymbol request it does a fsharp/documentationSymbol request. Though I know almost nothing about LSP

@cristiansofronie
Copy link
Contributor

Those those pickers use a single function to make the display. That function is make_entry.gen_from_lsp_symbols. So this should be very doable.

@jamestrew
Copy link
Contributor

Is the previewer not adequate for seeing context?

@hesxenon
Copy link
Author

@jamestrew not unless you have found a way to display the "fully qualified path" inside the previewer? I mean, thinking about that it would be awesome to able to use nvim-navic in the previewer or an extended column...

For reference, vscode displays the containing symbol
image

@pidgeon777
Copy link

I think a Telescope results list like the following would be extremely cool:

#2740

@benjiwolff benjiwolff linked a pull request Apr 13, 2025 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to performance, inner workings or existent features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants