nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
621 stars 41 forks source link

Show current position as breadcrumbs #66

Closed Hubro closed 2 years ago

Hubro commented 2 years ago

One thing I really miss from VSCode is seeing where I'm at in a document as a "breadcrumbs" path, like:

namespace Foo -> class Bar -> function test

Is that something that could be integrated into this plugin?

Perhaps like:

require"lsp-status".breadcrumbs()

It should probably be configurable with separator and which symbol types to include in the path:

require"lsp-status".breadcrumbs{
    separator = "->",
    symbols = {"Package", "Module", "Namespace", "Class", "Method", "Function"},
}
wbthomason commented 2 years ago

I'm not sure if this is quite what you want/as configurable as you want, but does the existing current enclosing function feature approximate breadcrumbs? https://github.com/nvim-lua/lsp-status.nvim/blob/master/doc/lsp-status.txt#L104

Hubro commented 2 years ago

It would approximate it well in cases where you're not editing a nested function or structure :smile:

However what I'm hoping for is something like the breadcrumbs path in VSCode:

image

I've found a good alternative based on tree-sitter here: https://github.com/SmiteshP/nvim-gps

But it requires Tree-sitter support for the language, and it needs a custom query file written for each language.

If it was possible to build breadcrumbs from information from an LSP, that would be a great alternative for languages that have a language server, but don't yet have a tree-sitter grammar. I'm increasingly getting the sense that LSP doesn't provide enough information to do this, though.

wbthomason commented 2 years ago

Yeah, I'm afraid that might be out of scope for this plugin (though I'd be open to reviewing/guiding a PR). I'm not sure that we can easily get more location information than we already display. I will note that "current function" should really be renamed "current scope" - we select a broader set of symbols than just functions (https://github.com/nvim-lua/lsp-status.nvim/blob/master/lua/lsp-status/current_function.lua#L13).

FelipeLema commented 2 years ago

It would approximate it well in cases where you're not editing a nested function or structure 😄

However what I'm hoping for is something like the breadcrumbs path in VSCode:

...

I've found a good alternative based on tree-sitter here: https://github.com/SmiteshP/nvim-gps

But it requires Tree-sitter support for the language, and it needs a custom query file written for each language.

If it was possible to build breadcrumbs from information from an LSP, that would be a great alternative for languages that have a language server, but don't yet have a tree-sitter grammar. I'm increasingly getting the sense that LSP doesn't provide enough information to do this, though.

followed this recommendation to https://github.com/SmiteshP/nvim-navic (and it delivers <3 )