Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions autoload/LanguageClient.vim
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ function! s:getInput(prompt, default) abort
return l:input
endfunction

function! s:inputlist(...) abort
call inputsave()
let l:selection = inputlist(a:000)
call inputrestore()
return l:selection
endfunction

function! s:FZF(source, sink) abort
if !get(g:, 'loaded_fzf')
call s:Echoerr('FZF not loaded!')
Expand Down
25 changes: 25 additions & 0 deletions src/language_server_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,31 @@ impl LanguageClient {
Ok(())
}

pub fn window_showMessageRequest(&self, params: &Value) -> Fallible<Value> {
info!("Begin {}", lsp::request::ShowMessageRequest::METHOD);
let msg_params: ShowMessageRequestParams = params.clone().to_lsp()?;
let msg_actions = msg_params.actions.unwrap_or_default();
let actions: Vec<Value> = msg_actions
.into_iter()
.enumerate()
.map(|(i, item)| Value::String(format!("{}) {}", i + 1, item.title)))
.collect();
let mut options: Vec<Value> = Vec::with_capacity(actions.len() + 1);
options.push(Value::String(msg_params.message));
options.extend(actions);

let mut v = Value::Null;
let result: Option<i64> = self.vim()?.rpcclient.call("s:inputlist", options)?;
if let Some(answer) = result {
let raw_actions: Vec<Value> = try_get("actions", &params)?.unwrap_or_default();
if let Some(action) = raw_actions.get((answer - 1) as usize) {
v = action.clone();
}
}
info!("End {}", lsp::request::ShowMessageRequest::METHOD);
Ok(v)
}

pub fn client_registerCapability(&self, languageId: &str, params: &Value) -> Fallible<Value> {
info!("Begin {}", lsp::request::RegisterCapability::METHOD);
let params: RegistrationParams = params.clone().to_lsp()?;
Expand Down
1 change: 1 addition & 0 deletions src/rpchandler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl LanguageClient {
lsp::request::DocumentSymbolRequest::METHOD => {
self.textDocument_documentSymbol(&params)
}
lsp::request::ShowMessageRequest::METHOD => self.window_showMessageRequest(&params),
lsp::request::WorkspaceSymbol::METHOD => self.workspace_symbol(&params),
lsp::request::CodeActionRequest::METHOD => self.textDocument_codeAction(&params),
lsp::request::Completion::METHOD => self.textDocument_completion(&params),
Expand Down