SmiteshP / nvim-navbuddy

A simple popup display that provides breadcrumbs feature using LSP server
Apache License 2.0
770 stars 30 forks source link

treesitter fallback/combination? #26

Closed IndianBoy42 closed 1 year ago

IndianBoy42 commented 1 year ago

Firstly, Very cool plugin, thanks!

On the one hand, some lsps like lua_ls gives extremely detailed symbol information, down to local variables or loop variables, thus enabling extremely fine navigation. other lsps like rust_analyzer only give symbol information to the level of functions, classes, etc. Actually this affects navic breadcrumbs as well.

I'm not sure which lsp is correct, but regardless as a plugin it would be nice to fill in the blanks with treesitters scopes+locals information. I wonder if a smart way of knowing till what point lsp symbols can be used and when treesitter information should be used is possible.

SmiteshP commented 1 year ago

I know using treesitter for this task sounds very appealing and easy to use. But I have tried this when I wrote nvim-gps. There is now way to write generalized queries that work with all languages and thus we need to write custom queries for each language. This is very difficult to maintain for all the reasons I elaborated in this reddit post

IndianBoy42 commented 1 year ago

One difference this time is that instead of having to get the whole tree through treesitter, you really only need to retrieve the symbols inside of a function/struct. nvim-treesitter already has the concept of locals so you don't have to define your own queries, just filter the list of locals nodes down to what's contained within the range of the lsp 'symbol'

litoj commented 1 year ago

I think there is no need for extra queries. I am no expert on treesitter, in fact have never worked with it, but dropbar.nvim offers the choice between lsp or treesitter, which would still be better than not being able to use treesitter at all, all while needing no custom queries. Maybe the internals of dropbar could be used instead of navic as the navbuddy's backend?