Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 379a935

Browse files
committed
fixup: Handle new nvim lsp signature
1 parent a1f12b8 commit 379a935

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

lua/lsp_extensions/util.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
local M = {}
2+
3+
function M.mk_handler(fn)
4+
return function(...)
5+
local config_or_client_id = select(4, ...)
6+
local is_new = type(config_or_client_id) ~= 'number'
7+
if is_new then
8+
fn(...)
9+
else
10+
local err = select(1, ...)
11+
local method = select(2, ...)
12+
local result = select(3, ...)
13+
local client_id = select(4, ...)
14+
local bufnr = select(5, ...)
15+
local config = select(6, ...)
16+
fn(err, result, { method = method, client_id = client_id, bufnr = bufnr }, config)
17+
end
18+
end
19+
end
20+
21+
return M

lua/lsp_extensions/workspace/diagnostic.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local util = require('lsp_extensions.util')
2+
13
local protocol = vim.lsp.protocol
24
local if_nil = vim.F.if_nil
35

@@ -41,12 +43,13 @@ local M = {}
4143
-- { client: stuff }
4244
M.diagnostic_cache = _LspExtensionsWorkspaceCache
4345

44-
M.handler = function(err, method, result, client_id, bufnr, config)
45-
vim.lsp.diagnostic.on_publish_diagnostics(err, method, result, client_id, bufnr, config)
46+
M.handler = util.mk_handler(function(err, result, ctx, config)
47+
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
4648

4749
if not result then return end
50+
local client_id = ctx.client_id
4851

49-
bufnr = bufnr or vim.uri_to_bufnr(result.uri)
52+
local bufnr = ctx.bufnr or vim.uri_to_bufnr(result.uri)
5053

5154
if not M.diagnostic_cache[client_id] then
5255
M.diagnostic_cache[client_id] = {}
@@ -64,7 +67,7 @@ M.handler = function(err, method, result, client_id, bufnr, config)
6467
diagnostics = diagnostics,
6568
counts = counts,
6669
}
67-
end
70+
end)
6871

6972
M.get_count = function(bufnr, severity)
7073
if bufnr == 0 or not bufnr then

0 commit comments

Comments
 (0)