diff options
author | Hirokazu Hata <h.hata.ai.t@gmail.com> | 2020-03-02 22:27:30 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-02 14:27:30 +0100 |
commit | fbc4c4fd36bef6f10f75af675985167d5fab4699 (patch) | |
tree | 25c11029e62af90f787c6fb42cc5bae9c3e11967 /runtime/lua/vim/lsp/callbacks.lua | |
parent | d22fd58629c6aa93d808d74a7e6dee79e3246ae0 (diff) | |
download | rneovim-fbc4c4fd36bef6f10f75af675985167d5fab4699.tar.gz rneovim-fbc4c4fd36bef6f10f75af675985167d5fab4699.tar.bz2 rneovim-fbc4c4fd36bef6f10f75af675985167d5fab4699.zip |
lsp: make showMessage and logMessage callbacks different (#11942)
According to the LSP specification, showMessage is what is displayed and logMessage is what is stored.
Since these are different things, I devide the callback into those that match.
Diffstat (limited to 'runtime/lua/vim/lsp/callbacks.lua')
-rw-r--r-- | runtime/lua/vim/lsp/callbacks.lua | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/runtime/lua/vim/lsp/callbacks.lua b/runtime/lua/vim/lsp/callbacks.lua index 63b5c4d493..644c12f98c 100644 --- a/runtime/lua/vim/lsp/callbacks.lua +++ b/runtime/lua/vim/lsp/callbacks.lua @@ -209,7 +209,27 @@ M['textDocument/documentHighlight'] = function(_, _, result, _) util.buf_highlight_references(bufnr, result) end -local function log_message(_, _, result, client_id) +M['window/logMessage'] = function(_, _, result, client_id) + local message_type = result.type + local message = result.message + local client = vim.lsp.get_client_by_id(client_id) + local client_name = client and client.name or string.format("id=%d", client_id) + if not client then + err_message("LSP[", client_name, "] client has shut down after sending the message") + end + if message_type == protocol.MessageType.Error then + log.error(message) + elseif message_type == protocol.MessageType.Warning then + log.warn(message) + elseif message_type == protocol.MessageType.Info then + log.info(message) + else + log.debug(message) + end + return result +end + +M['window/showMessage'] = function(_, _, result, client_id) local message_type = result.type local message = result.message local client = vim.lsp.get_client_by_id(client_id) @@ -226,9 +246,6 @@ local function log_message(_, _, result, client_id) return result end -M['window/showMessage'] = log_message -M['window/logMessage'] = log_message - -- Add boilerplate error validation and logging for all of these. for k, fn in pairs(M) do M[k] = function(err, method, params, client_id) |