-
Notifications
You must be signed in to change notification settings - Fork 7
feat: goto definition #42
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
feat: goto definition #42
Conversation
Hey @juliamertz very interesting idea, nice! 😄 I've been thinking along the same lines as you but haven't had time to explore this yet. I'm absolutely open to adding something like this. Looks great so far! A few things:
It would be great if you were able to add an adapter (or fix the Go adapter) which would take advantage of this properly (so we know the implementation actually works as intended). |
Using goto definition on a package import opens a list of all files in that package (at least with gopls). This behavior is similar to running Screen.Recording.2025-02-28.at.13.07.40.movI could add the adapter I made for Nix, but it depends on an external cli tool I wrote, which is still somewhat cumbersome to build, so I didn't feel it was ready to include yet. |
@juliamertz ahh, I see now. On my end, if neo-tree is loaded, I get it to show the directory 👍 However, hmm, I wonder. Maybe it would be more useful (or in addition to this) to be able to do a "go to ref" instead, which would take you to the picker. Something like this (the ![]()
No worries. You can keep it for yourself for as long as you like. 😄 I think, however, I want the Go adapter to use your added functionality but as ergonomically as possible (meaning maybe "goto refs" is more usable). But I don't have the bandwidth to look into this until later next week or so. |
Ah right I think I misunderstood, that seems a lot better! |
I managed to cobble together something that kind of works, but it's all a bit hacky and it only works on a good day. I can push my changes if you want to take a shot at it when you have the time 😄 |
@juliamertz sure, push and I can have a look 😄 |
@juliamertz hey, this looks super nice, but I'd like to take a stab at making this a bit more robust if it's ok with you? |
Please have a look at what I did in my latest commit. It's not perfect, but (on my machine) the picker is more reliably showing for the But maybe more importantly for you (for your adapter):
Can you still do what you want but with this interface? |
Let me know if there's anything from the Go adapter you would like to reuse. I could expose it from some sort of utils module, or similar. demo.mov |
Hm, I just noticed that when using fzf-lua, the If switching to the snacks or telescope picker, it just works... hm, weird. |
Nice! these changes have made it way more reliable for me too, with some minor changes my adapter works again. Only thing i can think of that might be useful to expose is something like I tested it with fzf-lua btw and it works just fine for me 🤔 |
Good catch, yes, this should be configurable similar to how you can choose between
Is it possible that you have any fzf-lua opts registered elsewhere, or in your own adapter? |
@juliamertz I changed things around a bit and now the I also simplified the code and I'm no longer using a hidden buffer. The drawback is you see the momentary "dummy buffer" before the LSP has attached. On my end the fzf-lua picker now works as expected, and like the other pickers. I was thinking about fzf-lua's |
Creating the window before the callback works well for me, this should help keep it a bit more uniform across adapters. At the time I just chose an arbitrary keybind, since Weirdly with the latest commit, fzf-lua isn't working as expected for me anymore, and I am now seeing the exact behavior you described. I don't have any special options set i just call |
I agree, it's fine. Let's start out like this. I don't use fzf-lua either and let's have someone else pick up this ball 😄
Strange, oh well, it works here on my end. I'll just merge this in now, and we can always iterate. Many thanks for your contribution on this! |
No problem, thank you for your time and help! :) |
Hey, I've been working on an adapter for the Nix language, but since much of it is undocumented I often find myself looking up the source code. Having a keymap to jump to it's definition would make this plugin perfect for me.
I've added the possibility for adapters to provide a path and the position in the file to jump to, though there are still some caveats:
<C-s>
instead ofgd
get_definition
is also an option in this case)This might be out of scope for this plugin, so just let me know if you'd be interested in including this, thanks :)