Skip to content

Commit

Permalink
handle lsp LogMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Mar 23, 2024
1 parent b9255db commit ed88000
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
1 change: 0 additions & 1 deletion autoload/clap/picker.vim
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function! clap#picker#update_preview(preview) abort

if has_key(a:preview, 'highlight_line')
let highlight_line = a:preview.highlight_line
echom string(highlight_line)
if has_key(highlight_line, 'column_range')
call g:clap.preview.add_highlight(highlight_line)
else
Expand Down
26 changes: 22 additions & 4 deletions crates/maple_core/src/stdio_server/plugin/lsp/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ impl LanguageServerMessageHandler {
}
}

fn handle_message(&self, show_message: bool, msg_type: lsp::MessageType, message: String) {
let msg_type = match msg_type {
lsp::MessageType::ERROR => "ERROR",
lsp::MessageType::WARNING => "WARN",
lsp::MessageType::INFO => "INFO",
lsp::MessageType::LOG => "LOG",
_ => return,
};
if show_message {
let _ = self
.vim
.echo_message(format!("[{}] [{msg_type}] {message}", self.server_name));
} else {
tracing::debug!("[{}] [{msg_type}] {message}", self.server_name);
}
}

fn handle_progress_message(
&mut self,
params: lsp::ProgressParams,
Expand Down Expand Up @@ -162,10 +179,11 @@ impl HandleLanguageServerMessage for LanguageServerMessageHandler {
}
}
}
LanguageServerNotification::ShowMessage(params) => {
let _ = self
.vim
.echo_message(format!("[{}] {}", self.server_name, params.message));
LanguageServerNotification::ShowMessage(lsp::ShowMessageParams { typ, message }) => {
self.handle_message(true, typ, message);
}
LanguageServerNotification::LogMessage(lsp::LogMessageParams { typ, message }) => {
self.handle_message(false, typ, message);
}
_ => {
tracing::debug!("TODO: handle language server notification: {notification:?}");
Expand Down

0 comments on commit ed88000

Please sign in to comment.