mirror of
https://github.com/neovim/neovim
synced 2025-07-17 17:51:48 +00:00
fix(lsp): rename LspProgress data.result => data.params #28632
Rename the field `result` to `params` in the `data` table for `LspProgress` autocmds. This aligns with LspNotify. The previous name was chosen because the initial handler implementation mistakenly had a parameter name `result` instead of `params` for the `$/progress` LSP "notification" handler. However, `params` would be a more appropriate name that is more consistent with the underlying LSP type (`ProgressParams`). See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress
This commit is contained in:
@ -544,14 +544,14 @@ LspNotify *LspNotify*
|
|||||||
LspProgress *LspProgress*
|
LspProgress *LspProgress*
|
||||||
Upon receipt of a progress notification from the server. Notifications can
|
Upon receipt of a progress notification from the server. Notifications can
|
||||||
be polled from a `progress` ring buffer of a |vim.lsp.Client| or use
|
be polled from a `progress` ring buffer of a |vim.lsp.Client| or use
|
||||||
|vim.lsp.status()| to get an aggregate message
|
|vim.lsp.status()| to get an aggregate message.
|
||||||
|
|
||||||
If the server sends a "work done progress", the `pattern` is set to `kind`
|
If the server sends a "work done progress", the `pattern` is set to `kind`
|
||||||
(one of `begin`, `report` or `end`).
|
(one of `begin`, `report` or `end`).
|
||||||
|
|
||||||
When used from Lua, the event contains a `data` table with `client_id` and
|
When used from Lua, the event contains a `data` table with `client_id` and
|
||||||
`result` properties. `result` will contain the request params sent by the
|
`params` properties. `params` will contain the request params sent by the
|
||||||
server.
|
server (see `lsp.ProgressParams`).
|
||||||
|
|
||||||
Example: >vim
|
Example: >vim
|
||||||
autocmd LspProgress * redrawstatus
|
autocmd LspProgress * redrawstatus
|
||||||
|
@ -178,6 +178,8 @@ cycle (Nvim HEAD, the "master" branch).
|
|||||||
|
|
||||||
• Renamed vim.snippet.exit() to vim.snippet.stop().
|
• Renamed vim.snippet.exit() to vim.snippet.stop().
|
||||||
|
|
||||||
|
• Changed |event-data| table for |LspProgress|: renamed `result` to `params`.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
NEW FEATURES *news-features*
|
NEW FEATURES *news-features*
|
||||||
|
|
||||||
|
@ -22,16 +22,16 @@ M[ms.workspace_executeCommand] = function(_, _, _, _)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress
|
--- @see # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#progress
|
||||||
---@param result lsp.ProgressParams
|
---@param params lsp.ProgressParams
|
||||||
---@param ctx lsp.HandlerContext
|
---@param ctx lsp.HandlerContext
|
||||||
M[ms.dollar_progress] = function(_, result, ctx)
|
M[ms.dollar_progress] = function(_, params, ctx)
|
||||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
if not client then
|
if not client then
|
||||||
err_message('LSP[id=', tostring(ctx.client_id), '] client has shut down during progress update')
|
err_message('LSP[id=', tostring(ctx.client_id), '] client has shut down during progress update')
|
||||||
return vim.NIL
|
return vim.NIL
|
||||||
end
|
end
|
||||||
local kind = nil
|
local kind = nil
|
||||||
local value = result.value
|
local value = params.value
|
||||||
|
|
||||||
if type(value) == 'table' then
|
if type(value) == 'table' then
|
||||||
kind = value.kind
|
kind = value.kind
|
||||||
@ -39,21 +39,21 @@ M[ms.dollar_progress] = function(_, result, ctx)
|
|||||||
-- So that consumers always have it available, even if they consume a
|
-- So that consumers always have it available, even if they consume a
|
||||||
-- subset of the full sequence
|
-- subset of the full sequence
|
||||||
if kind == 'begin' then
|
if kind == 'begin' then
|
||||||
client.progress.pending[result.token] = value.title
|
client.progress.pending[params.token] = value.title
|
||||||
else
|
else
|
||||||
value.title = client.progress.pending[result.token]
|
value.title = client.progress.pending[params.token]
|
||||||
if kind == 'end' then
|
if kind == 'end' then
|
||||||
client.progress.pending[result.token] = nil
|
client.progress.pending[params.token] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
client.progress:push(result)
|
client.progress:push(params)
|
||||||
|
|
||||||
api.nvim_exec_autocmds('LspProgress', {
|
api.nvim_exec_autocmds('LspProgress', {
|
||||||
pattern = kind,
|
pattern = kind,
|
||||||
modeline = false,
|
modeline = false,
|
||||||
data = { client_id = ctx.client_id, result = result },
|
data = { client_id = ctx.client_id, params = params },
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user