Skip to content

Commit a5990bf

Browse files
committed
fixup: Handle new lsp signature
1 parent 745ba61 commit a5990bf

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

lua/lsp-status/current_function.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ local scope_kinds = {
2222
}
2323

2424
-- Find current function context
25-
local function current_function_callback(_, _, result, _, _)
25+
local function current_function_callback(_, result)
2626
vim.b.lsp_current_function = ''
2727
if type(result) ~= 'table' then
2828
return
@@ -59,7 +59,7 @@ end
5959

6060
local function update_current_function()
6161
local params = { textDocument = lsp_util.make_text_document_params() }
62-
vim.lsp.buf_request(0, 'textDocument/documentSymbol', params, current_function_callback)
62+
vim.lsp.buf_request(0, 'textDocument/documentSymbol', params, util.mk_handler(current_function_callback))
6363
end
6464

6565
local M = {

lua/lsp-status/extensions/clangd.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ local function init(_messages, _) messages = _messages end
1010
local function ensure_init(id) util.ensure_init(messages, id, 'clangd') end
1111

1212
local handlers = {
13-
['textDocument/clangd.fileStatus'] = function(_, _, statusMessage, client_id)
13+
['textDocument/clangd.fileStatus'] = util.mk_handler(function(_, statusMessage, ctx)
14+
local client_id = ctx.client_id
15+
1416
ensure_init(client_id)
1517
messages[client_id].status = {uri = statusMessage.uri, content = statusMessage.state}
1618
redraw.redraw()
17-
end
19+
end)
1820
}
1921

2022
--- Return the handler {LSP Method: handler} table for `clangd`'s `fileStatus` extension

lua/lsp-status/messaging.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ local function unregister_client(id)
1111
clients[id] = nil
1212
end
1313

14-
local function progress_callback(_, _, msg, client_id)
14+
local function progress_callback(_, msg, ctx)
15+
local client_id = ctx.client_id
16+
1517
util.ensure_init(messages, client_id, client_id)
1618
local val = msg.value
1719
if val.kind then
@@ -94,7 +96,9 @@ local function get_messages()
9496
return new_messages
9597
end
9698

97-
local function register_progress() vim.lsp.handlers['$/progress'] = progress_callback end
99+
local function register_progress()
100+
vim.lsp.handlers['$/progress'] = util.mk_handler(progress_callback)
101+
end
98102

99103
-- Client registration for messages
100104
local function register_client(id, name)

lua/lsp-status/util.lua

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,30 @@ local function ensure_init(messages, id, name)
6363
end
6464
end
6565

66+
local function mk_handler(fn)
67+
return function(...)
68+
local config_or_client_id = select(4, ...)
69+
local is_new = type(config_or_client_id) ~= 'number'
70+
if is_new then
71+
fn(...)
72+
else
73+
local err = select(1, ...)
74+
local method = select(2, ...)
75+
local result = select(3, ...)
76+
local client_id = select(4, ...)
77+
local bufnr = select(5, ...)
78+
local config = select(6, ...)
79+
fn(err, result, { method = method, client_id = client_id, bufnr = bufnr }, config)
80+
end
81+
end
82+
end
83+
6684
local M = {
6785
extract_symbols = extract_symbols,
6886
in_range = in_range,
6987
filter = filter,
70-
ensure_init = ensure_init
88+
ensure_init = ensure_init,
89+
mk_handler = mk_handler,
7190
}
7291

7392
return M

0 commit comments

Comments
 (0)