nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.07k stars 815 forks source link

lsp symbol search show context #2695

Open hesxenon opened 11 months ago

hesxenon commented 11 months ago

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 :thinking:

cristiansofronie commented 11 months ago

What picker do you refer to?

hesxenon commented 11 months ago

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

cristiansofronie commented 11 months ago

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

cristiansofronie commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

Is the previewer not adequate for seeing context?

hesxenon commented 11 months ago

@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 commented 9 months ago

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

https://github.com/nvim-telescope/telescope.nvim/issues/2740