-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for gopls 'implements' functionality #2741
Conversation
Add support to use the textDocument/implementation gopls feature. Add g:go_implements_mode so that users can choose between gopls and guru.
In addition to the default Implements feature, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing! This looks great.
I think that CL for reverse implements is really what's needed, because that's what :GoImplements
means now.
I'm a little reluctant to overload :GoImplements
to do what this PR does, but as a practical matter it probably makes sense. I'm going to give it some more thought before merging, though.
Please ignore all my comments on the PR; they're really for me to reference after merging to do some small cleanup.
LGTM
autoload/go/list.vim
Outdated
@@ -151,6 +151,7 @@ let s:default_list_type_commands = { | |||
\ "GoTest": "quickfix", | |||
\ "GoVet": "quickfix", | |||
\ "GoReferrers": "quickfix", | |||
\ "GoImplements": "quickfix", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default for GoImplements
should be locationlist
, because the information that it the list will contain is relative to a single buffer.
autoload/go/lsp.vim
Outdated
" a dictionary that manages state (statuslines, sets the winid, etc.). handler | ||
" should take three arguments: an exit_code, a JSON object encoded to a string | ||
" that mimics guru's ouput for `what`, and third mode parameter that only | ||
" exists for compatibility with the guru implementation of SameIDs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit): SameIDS
-> implements
There's no need for you to change this; I'm just leaving a note for myself to fix this after merging.
autoload/go/lsp.vim
Outdated
|
||
let l:state = s:newHandlerState('implements') | ||
|
||
let l:state.handleResult = funcref('s:referencesHandler', [function(a:handler, [], l:state)], l:state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just another note for myself to do later: s:referencesHandler
should be refactored to call another function. This should call a new function s:implementsHandler
, which calls that common function.
autoload/go/lsp.vim
Outdated
endfunction | ||
|
||
function! s:implementsErrorHandler(next, error) abort dict | ||
call call(a:next, [-1, [a:error], '']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1
is ok, but 1
may be more consistent with other exit codes.
autoload/go/implements.vim
Outdated
|
||
let errformat = ",%f:%l:%c:\ %m" | ||
let l:listtype = go#list#Type("GoImplements") | ||
call go#list#ParseFormat(l:listtype, errformat, a:output, '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last argument should be a:title
.
@woodstok do you mind if I push to your branch before merging? |
@bhcleek Feel free |
This has merged to gopls master. |
Thanks for checking in. I'm planning to make the changes, I've just been very busy lately |
@woodstok given how this works now, I think it might also be a good replacement for |
I am not sure if they map to the same functionality. And I can't seem to get my go guru to work properly in my projects, so can't verify either. |
Guru works in GOPATH mode. For |
Thank you for your patience @woodstok . Now that I have a few bugs off my plate, I'm going to focus on getting this merged. I'll be pushing to your branch soon as we previously discussed. |
* use the location list by default for :GoImplements, because it operates only on a single file (though the results may be for multiple files). * use the location list by default for :GoReferrers, because it operates only on a single file (though the results may be for multiple files). * make sure the location list for :GoImplements has title. * use separate handlers for go#lsp#Implements and go#lsp#Referrers. * rename s:referencesHandler in lsp.vim to s:handleLocations and call it from s:handleReferences and s:handleImplements. * Adjust documentation for go#lsp#Implementation to refer to guru implements instead of guru what. * Document the default for g:go_implements_mode and g:go_referrers_mode.
Thank you again for the contribution 🙇 |
Thank you for the merge. I was away from my laptop for quite a while. |
Add support to use the textDocument/implementation gopls feature.
Add g:go_implements_mode so that users can choose between gopls and
guru.