Skip to content

Commit

Permalink
Merge pull request #2289 from bhcleek/lsp/functions-preview
Browse files Browse the repository at this point in the history
lsp: show function signature with return types in preview window
  • Loading branch information
bhcleek authored May 14, 2019
2 parents b71aa9c + 6166e73 commit 99dc8e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ function! s:completionHandler(next, msg) abort dict
let l:match = {'abbr': l:item.label, 'word': l:item.textEdit.newText, 'info': '', 'kind': go#lsp#completionitemkind#Vim(l:item.kind)}
if has_key(l:item, 'detail')
let l:match.info = l:item.detail
if go#lsp#completionitemkind#IsFunction(l:item.kind) || go#lsp#completionitemkind#IsMethod(l:item.kind)
let l:match.info = printf('func %s %s', l:item.label, l:item.detail)
endif
endif

if has_key(l:item, 'documentation')
Expand Down
18 changes: 17 additions & 1 deletion autoload/go/lsp/completionitemkind.vim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let s:Event = 23
let s:Operator = 24
let s:TypeParameter = 25

function! go#lsp#completionitemkind#Vim(kind)
function! go#lsp#completionitemkind#Vim(kind) abort
if a:kind == s:Method || a:kind == s:Function || a:kind == s:Constructor
return 'f'
elseif a:kind == s:Variable || a:kind == s:Constant
Expand All @@ -40,6 +40,22 @@ function! go#lsp#completionitemkind#Vim(kind)
endif
endfunction

function! go#lsp#completionitemkind#IsFunction(kind) abort
if a:kind == s:Function
return 1
endif

return 0
endfunction

function! go#lsp#completionitemkind#IsMethod(kind) abort
if a:kind == s:Method
return 1
endif

return 0
endfunction

" restore Vi compatibility settings
let &cpo = s:cpo_save
unlet s:cpo_save
Expand Down

0 comments on commit 99dc8e8

Please sign in to comment.