Skip to content

feat: new command to goto hover (like goto definition) #12208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Dec 6, 2024

So, you can use Space + k to hover documentation which opens a popup.

However, sometimes it's really useful to be able to search inside this popup. Or go into it, move around, copy some text, etc. Some hover-docs can be quite long.

This PR adds a new command called goto_hover, which dumps the "documentation on hover" into a new scratch buffer (replacing the current buffer, similar to goto_definition), where you can use your usual Helix motions. this is how it looks like (after I created a new split):

image

I bound goto_hover to Space + K, whereas hover was Space + k.

Closes #12206
Closes #8134
Closes #9455

@Axlefublr
Copy link
Contributor

trying this feature out in my fork and loving it!

except, I'd rather it be a horizontal split. I could also see an argument for ::Replace, too
is it too unreasonable to ask for this to be configurable via a settable option?
I don't think helix decides on a split type anywhere else; maybe having a global "split-direction" option that other things may potentially use in the future is a good idea

@nik-rev
Copy link
Contributor Author

nik-rev commented Dec 31, 2024

trying this feature out in my fork and loving it!

except, I'd rather it be a horizontal split. I could also see an argument for ::Replace, too is it too unreasonable to ask for this to be configurable via a settable option? I don't think helix decides on a split type anywhere else; maybe having a global "split-direction" option that other things may potentially use in the future is a good idea

Adding configuration for this small thing is easily going to be rejected by the maintainers. Other adjustments would also be increasing complexity and could delay this PR from being merged

@Axlefublr
Copy link
Contributor

fair enough. let's get this merged first
good luck!

@TornaxO7
Copy link
Contributor

TornaxO7 commented Dec 31, 2024

trying this feature out in my fork and loving it!

except, I'd rather it be a horizontal split. I could also see an argument for ::Replace, too is it too unreasonable to ask for this to be configurable via a settable option? I don't think helix decides on a split type anywhere else; maybe having a global "split-direction" option that other things may potentially use in the future is a good idea

What you can also do, at least, if you are working with one pane, is transposing your layout with <C-w><C-t>.

@Axlefublr
Copy link
Contributor

@TornaxO7 yep thank you! I am aware
for now I changed it to horizontal in source in my fork; it's just a defaults preference

@nik-rev
Copy link
Contributor Author

nik-rev commented Jan 27, 2025

I just fixed it with merge conflicts since #10122 added support for hover with multiple language servers.

This is how it looks like with multiple language servers:

image

@cotneit
Copy link
Contributor

cotneit commented Apr 10, 2025

@nik-rev What do you think about making this work in-place instead of opening a new split? Similar to goto_definition when it has to jump to a different file. This way if user has a preference between in-place/vsplit/hsplit they can just do a custom keybind:

[keys.normal.g]
H = ["vsplit", "goto_definition"]

Inspired by https://matklad.github.io/2024/10/08/two-tips.html, immediately thought of this PR while reading it :)

@nik-rev
Copy link
Contributor Author

nik-rev commented Apr 10, 2025

@nik-rev What do you think about making this work in-place instead of opening a new split? Similar to goto_definition when it has to jump to a different file. This way if user has a preference between in-place/vsplit/hsplit they can just do a custom keybind:

[keys.normal.g]
H = ["vsplit", "goto_definition"]

Inspired by https://matklad.github.io/2024/10/08/two-tips.html, immediately thought of this PR while reading it :)

That is definitely better!

feels more natural, especially since it is very similar to other commands like "goto reference", but its "goto hover"

@nik-rev nik-rev changed the title feat: new command to open hover documentation in a new buffer instead of a popup feat: new command to goto hover (like goto definition) Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-command Area: Commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entering the Popup Documentation Window (to select text etc.)
5 participants