rmagatti / goto-preview

A small Neovim plugin for previewing definitions using floating windows.
Apache License 2.0
779 stars 27 forks source link

feat: Add option for whether to nest floating windows or not #69

Closed jrwrigh closed 2 years ago

jrwrigh commented 2 years ago

I've added a boolean option nest_floating to chose whether to allow for multiple nested floating windows to be opened. true is the current default behavior and false changes it. If false and the current window is floating, then it will reuse the current floating window, otherwise it'll open up a floating window like normal.

Use Case: I work with C quite a bit and when I initially use goto-definition, I get the function signature in a header file. 99.9% of the time, I don't care about that, so I have to use goto-definition again to get to the actual function definition. I'd like the option of not having two floating windows cluttering up the screen when I don't want to. Conversely, I would like a floating window if I've taken a preview window and moved it into a "real" window.

Code Note:

rmagatti commented 2 years ago

Thanks for the PR!

This is a good addition, I'll review it more closely in the weekend. I'd also like to ask for your use-case, couldn't you use goto-implementation from the lsp instead of goto-definition to go directly to the implementation of the function?

Not sure what's supported for C these days, but thought I'd mention it still 😊

jrwrigh commented 2 years ago

I'd also like to ask for your use-case, couldn't you use goto-implementation from the lsp instead of goto-definition to go directly to the implementation of the function?

Not sure what's supported for C these days, but thought I'd mention it still blush

I have (and just now) tried to do goto-implementation, but that doesn't seem to work for clangd. Looking at this issue, it appears that it's limited to C++ class-type overrides and such. Might suggest that they add a feature in to go to the actual function definition rather just the function signature.

rmagatti commented 2 years ago

Awesome, I'll test it out before merging but looks good to me so far

rmagatti commented 2 years ago

Just tested, works well. Merging!