-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
[WIP] cmd/govim: experiment with call hierarchy support #1015
base: main
Are you sure you want to change the base?
Conversation
Thanks very much for investigating this. I'll take a look as soon as I can. |
9de8150
to
eb83839
Compare
This looks fantastic. Some drive-by comments (please bear in mind that I have not looked at the code):
Have you messaged in the |
Thanks for taking a look! And the code is still hack-ish so it is a good think you didn't waste time on it yet, this was more if the concept holds.
I haven't looked into mouse integration much in vim at all, I'll take a look. I don't think it should be any issues adding that.
The tree view looks much like the screenshots from VSCode that was included in the CL that added support in gopls, CL 247699: https://i.imgur.com/tHzx8yn.png & https://i.imgur.com/gjshuaj.png. Would be nice with other suggestions, I'll add something about this to the description.
I fully agree. The reason to why the filename is there is that it is bundled with the package identifier:
Probably worth raising an issue to
Thanks. It has been very helpful for debugging and as I already know how it works it is a nice subtle aid in general.
I recall the response from gopls not being consistent so I added an alphabetic sort, execution order is probably more intuitive for "Outgoing calls". Any suggestions for how to sort "Incoming calls" would be appreciated. I have no strong opinions at all, I guess the good thing about alphabetic is that it is consistent for both in/out. |
The perfect way of evaluating an idea to my mind!
Great. For some reason I suspect I would use the mouse in this instance - I don't know why, especially because I'm generally 100% keyboard in Vim.
Great. It honestly seems to work really well as it is... but I'm all for making it even better.
Agreed.
I thought about this a bit more. It's quite a tricky one - because I'm sure my brain will expect to see things in execution order, but given there could be multiple calls to a given function/method for an |
This is an experiment for how Call Hierarchy UX could be implemented. Don't mind the ugly code, it is a quick hack to just to try out different things.
It introduces a new command,
:GOVIMCallHierarchy
that must be called with one argument. The argument must be eitherin
,out
orgoto
.Calling
:GOVIMCallHierarchy out
with the cursor on a function will bring up all outgoing calls from that function. The same way goes for:GOVIMCallHierarchy in
, but for incoming calls to that function.The list of calls is populated in a newly created buffer named
govim-callhierarchy
that acts as a tree. Each line is a call and lines prefixed with+
can be further expanded by calling the same:GOVIMCallHierarchy
again.The tree view looks much like the screenshots from VSCode from the CL that added support in gopls, CL 247699: https://i.imgur.com/tHzx8yn.png & https://i.imgur.com/gjshuaj.png. I did put some effort into how the UX should look like and ended up with this. Any ideas of improvements are very welcome!
You can also call the "other"
:GOVIMCallHierarchy
command on one of the lines in the call hierarchy buffer, e.g. if it was opened with to show all outgoing requests you can call:GOVIMCallHierarchy in
to set the current entry as a new root for incoming calls.:GOVIMCallHierarchy goto
will only have an effect when called from the call hierarchy buffer, and it jumps to the definition of the current entry.Highlighting has been added mostly for debugging, but could be used if they add anything.