Merge pull request #15504 from mjlbach/feat/change-handler-signature

feat(lsp)!: change handler signature
This commit is contained in:
Michael Lingelbach
2021-09-05 10:27:52 -07:00
committed by GitHub
11 changed files with 261 additions and 248 deletions

View File

@@ -1020,15 +1020,16 @@ end
--- - Update diagnostics in InsertMode or wait until InsertLeave
--- - severity_sort: (default=false)
--- - Sort diagnostics (and thus signs and virtual text)
function M.on_publish_diagnostics(_, _, params, client_id, _, config)
local uri = params.uri
function M.on_publish_diagnostics(_, result, ctx, config)
local client_id = ctx.client_id
local uri = result.uri
local bufnr = vim.uri_to_bufnr(uri)
if not bufnr then
return
end
local diagnostics = params.diagnostics
local diagnostics = result.diagnostics
if config and if_nil(config.severity_sort, false) then
table.sort(diagnostics, function(a, b) return a.severity > b.severity end)
@@ -1204,15 +1205,17 @@ function M.redraw(bufnr, client_id)
-- the user may have set with vim.lsp.with.
vim.lsp.handlers["textDocument/publishDiagnostics"](
nil,
"textDocument/publishDiagnostics",
{
uri = vim.uri_from_bufnr(bufnr),
diagnostics = M.get(bufnr, client_id),
},
client_id,
bufnr
)
end
{
method = "textDocument/publishDiagnostics",
client_id = client_id,
bufnr = bufnr,
}
)
end
---@private