ojroques / nvim-lspfuzzy

A Neovim plugin to make the LSP client use FZF
BSD 2-Clause "Simplified" License
316 stars 11 forks source link

Improving document symbols #12

Closed Seich closed 3 years ago

Seich commented 3 years ago

First of all, thanks for the great plugin!

I am trying to improve the document symbol window, right now it depends on showing the entire file path to move to the correct position so when my editor is small-ish it stops being useful:

image

Is there a way to get around that limitation? Changing the modifier eventually ends up breaking and opening new buffers with names which makes sense but hasn't gotten me any closer. :p:t for example looks great but falls into these (which to be fair the read me mentions)

image

Any suggestions?

ojroques commented 3 years ago

Yes I'm aware of this problem, I'd also prefer to have only the head part of the path as it can get quite annoying with long paths. As far as I know, in FZF the function that builds the list and the action handler are independent, that's why the full path need to be in the list so that it can jump into it in the handler. But maybe I can find a workaround.

ojroques commented 3 years ago

Well it's easier to do than I thought. I simply saved the full path of a FZF entry in a global variable that the jump handler has access to. Update the plugin and your issue should be resolved now.

ojroques commented 3 years ago

I'm reopening this as I realized that using an incomplete modifier breaks the preview though.

ojroques commented 3 years ago

I've looked into it and the executable preview.sh that FZF uses to display the preview assumes that an entry has a valid path (relative or absolute) as first element. So I cannot remove the path from the FZF entries unfortunately.

I could potentially call myself preview.sh with the correct file path but that would add a lot of complexity to the code: FZF takes care of sanitizing the entries according to the user OS before calling preview.sh here and I'd like to keep the plugin simple.

But I've added the --keep-right option so that if the line is too long, the line is displayed starting from the end. I hope that this fix is ok for you.

Seich commented 3 years ago

Hey @ojroques it works great! Thanks for taking a look so quickly! I have the preview disabled so your first fix is actually a better fit for me and I'll stay on it for the time being.

--keep-right is certainly the correct fix for most cases nonetheless. Do you think it'd be worth it for it to be a setting? I understand if that goes against your objectives for the plugin though! Thanks again!

ojroques commented 3 years ago

Great!

I've already added --keep-right as a default setting in the latest commit, I think this is the behavior that people expect for long entries. Note that I have reverted the first fix in the latest commit to keep the preview working.