Skip to content

Commit 13d8462

Browse files
author
Junfeng Li
committed
Fix and expose signatureHelp.
Close #274.
1 parent dab664f commit 13d8462

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

plugin/LanguageClient.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,24 @@ function! LanguageClient#complete(findstart, base) abort
589589
endif
590590
endfunction
591591

592+
function! LanguageClient_textDocument_signatureHelp(...) abort
593+
if &buftype !=# '' || &filetype ==# ''
594+
return
595+
endif
596+
597+
let l:params = {
598+
\ 'buftype': &buftype,
599+
\ 'languageId': &filetype,
600+
\ 'filename': s:Expand('%:p'),
601+
\ 'line': line('.') - 1,
602+
\ 'character': col('.') - 1,
603+
\ 'handle': v:true,
604+
\ }
605+
call extend(l:params, a:0 >= 1 ? a:1 : {})
606+
let callback = a:0 >= 2 ? a:2 : v:null
607+
return LanguageClient#Call('textDocument/signatureHelp', l:params, l:callback)
608+
endfunction
609+
592610
function! LanguageClient_workspace_applyEdit(...) abort
593611
if &buftype !=# '' || &filetype ==# ''
594612
return

src/languageclient.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,12 +2249,16 @@ impl ILanguageClient for Arc<Mutex<State>> {
22492249
.label
22502250
.split(&active_parameter.label)
22512251
.collect();
2252-
for chunk in chunks {
2253-
cmd += &format!(" | echon {}", chunk);
2252+
if chunks.len() == 2 {
2253+
let begin = chunks.get(0).cloned().unwrap_or_default();
2254+
let end = chunks.get(1).cloned().unwrap_or_default();
22542255
cmd += &format!(
2255-
" | echohl Bold | echon {} | echohl None",
2256-
active_parameter.label
2256+
" | echon '{}' | echohl WarningMsg | echon '{}' | echohl None | echon '{}'",
2257+
begin, active_parameter.label, end
22572258
);
2259+
} else {
2260+
// Active parameter is not part of signature.
2261+
cmd += &format!(" | echo '{}'", active_signature.label);
22582262
}
22592263
self.command(&cmd)?;
22602264
} else {

0 commit comments

Comments
 (0)