From ea1020b525e9be7b3c1859a525db6e781934f22a Mon Sep 17 00:00:00 2001 From: Indelog Date: Mon, 8 Nov 2021 14:05:09 +0100 Subject: [PATCH] Add : Possibility to echo signature in cmdline --- autoload/handlers.vim | 25 ++++++++++++++++++++----- doc/lsp.txt | 4 +++- plugin/lsp.vim | 4 ++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 6db5dbd..e895a79 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -120,15 +120,30 @@ def s:processSignaturehelpReply(lspserver: dict, req: dict, reply: dic if sig->has_key('parameters') && result->has_key('activeParameter') var params_len = sig.parameters->len() if params_len > 0 && result.activeParameter < params_len - var label = sig.parameters[result.activeParameter].label + var label = '' + if sig.parameters[result.activeParameter]->has_key('documentation') + label = sig.parameters[result.activeParameter].documentation + else + label = sig.parameters[result.activeParameter].label + endif hllen = label->len() startcol = text->stridx(label) endif endif - var popupID = text->popup_atcursor({moved: 'any'}) - prop_type_add('signature', {bufnr: popupID->winbufnr(), highlight: 'LineNr'}) - if hllen > 0 - prop_add(1, startcol + 1, {bufnr: popupID->winbufnr(), length: hllen, type: 'signature'}) + if g:LSP_Echo_Signature + echon "\r\r" + echon '' + echon strpart(text, 0, startcol) + echoh LineNr + echon strpart(text, startcol, hllen) + echoh None + echon strpart(text, startcol + hllen) + else + var popupID = text->popup_atcursor({moved: 'any'}) + prop_type_add('signature', {bufnr: popupID->winbufnr(), highlight: 'LineNr'}) + if hllen > 0 + prop_add(1, startcol + 1, {bufnr: popupID->winbufnr(), length: hllen, type: 'signature'}) + endif endif enddef diff --git a/doc/lsp.txt b/doc/lsp.txt index 674bf2b..788b2a0 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -215,7 +215,9 @@ accepts a list of LSP servers with the above information. The popup is also automatically displayed in insert mode after entering a symbol name followed by a separator (e.g. a opening parenthesis). Unless if: > - let g:LSP_Show_Signature = v:false + let g:LSP_Show_Signature = v:false. If you set + g:LSP_Show_Signature = 1 the signature will be echoed + in cmdline rather displayed in a popup. < Default is true. diff --git a/plugin/lsp.vim b/plugin/lsp.vim index 572e201..512b57b 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -15,6 +15,10 @@ if !exists('g:LSP_Show_Signature') let g:LSP_Show_Signature = v:true endif +if !exists('g:LSP_Echo_Signature') + let g:LSP_Echo_Signature = v:false +endif + augroup LSPAutoCmds au! autocmd BufNewFile,BufReadPost * -- 2.48.1