aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/handlers.lua
diff options
context:
space:
mode:
authorMatthieu Coudron <teto@users.noreply.github.com>2020-12-20 21:59:25 +0100
committerGitHub <noreply@github.com>2020-12-20 21:59:25 +0100
commit1e5913483469528c7e8d1f927b28c0185eb94941 (patch)
tree9544669134d0e97aae394f43b787b2ccd3959a60 /runtime/lua/vim/lsp/handlers.lua
parentb1711e6f922598f00c4d2c879094afdbba44c187 (diff)
downloadrneovim-1e5913483469528c7e8d1f927b28c0185eb94941.tar.gz
rneovim-1e5913483469528c7e8d1f927b28c0185eb94941.tar.bz2
rneovim-1e5913483469528c7e8d1f927b28c0185eb94941.zip
lsp: add $/progress report (#13294)
Heavily inspired by https://github.com/nvim-lua/lsp-status.nvim. listen to the LspProgressUpdate event to update your statusline.
Diffstat (limited to 'runtime/lua/vim/lsp/handlers.lua')
-rw-r--r--runtime/lua/vim/lsp/handlers.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/runtime/lua/vim/lsp/handlers.lua b/runtime/lua/vim/lsp/handlers.lua
index e034923afb..f1dd9ef5a1 100644
--- a/runtime/lua/vim/lsp/handlers.lua
+++ b/runtime/lua/vim/lsp/handlers.lua
@@ -24,6 +24,47 @@ M['workspace/executeCommand'] = function(err, _)
end
end
+-- @msg of type ProgressParams
+-- Basically a token of type number/string
+local function progress_callback(_, _, params, client_id)
+ local client = vim.lsp.get_client_by_id(client_id)
+ if not client then
+ err_message("LSP[", client_id, "] client has shut down after sending the message")
+ end
+ local val = params.value -- unspecified yet
+ local token = params.token -- string or number
+
+
+ if val.kind then
+ if val.kind == 'begin' then
+ client.messages.progress[token] = {
+ title = val.title,
+ message = val.message,
+ percentage = val.percentage,
+ }
+ elseif val.kind == 'report' then
+ client.messages.progress[token] = {
+ message = val.message,
+ percentage = val.percentage,
+ }
+ elseif val.kind == 'end' then
+ if client.messages.progress[token] == nil then
+ err_message(
+ 'echom "[lsp-status] Received `end` message with no corresponding `begin` from "')
+ else
+ client.messages.progress[token].message = val.message
+ client.messages.progress[token].done = true
+ end
+ end
+ else
+ table.insert(client.messages, {content = val, show_once = true, shown = 0})
+ end
+
+ vim.api.nvim_command("doautocmd User LspProgressUpdate")
+end
+
+M['$/progress'] = progress_callback
+
--@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_codeAction
M['textDocument/codeAction'] = function(_, _, actions)
if actions == nil or vim.tbl_isempty(actions) then