diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-08-28 00:12:30 -0400 |
---|---|---|
committer | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-09-05 10:04:30 -0700 |
commit | df17d7844ed7dedcb80f9405f7078a046a12524a (patch) | |
tree | aa1cd7c325aefe6ad6d48a95316df08fcaf25a11 /runtime/lua/vim/lsp/diagnostic.lua | |
parent | 5d633546bf5990d03e4b4dc1df213f88316115e6 (diff) | |
download | rneovim-df17d7844ed7dedcb80f9405f7078a046a12524a.tar.gz rneovim-df17d7844ed7dedcb80f9405f7078a046a12524a.tar.bz2 rneovim-df17d7844ed7dedcb80f9405f7078a046a12524a.zip |
feat(lsp)!: change handler signature
Previously, the handler signature was:
function(err, method, params, client_id, bufnr, config)
In order to better support external plugins that wish to extend the
protocol, there is other information which would be advantageous to
forward to the client, such as the original params of the request that
generated the callback.
In order to do this, we would need to break symmetry of the handlers, to
add an additional "params" as the 7th argument.
Instead, this PR changes the signature of the handlers to:
function(err, result, ctx, config)
where ctx (the context) includes params, client_id, and bufnr. This also leaves
flexibility for future use-cases.
BREAKING_CHANGE: changes the signature of the built-in client handlers, requiring
updating handler calls
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r-- | runtime/lua/vim/lsp/diagnostic.lua | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua index 45aeb17465..11bfa41097 100644 --- a/runtime/lua/vim/lsp/diagnostic.lua +++ b/runtime/lua/vim/lsp/diagnostic.lua @@ -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 -- }}} -- Diagnostic User Functions {{{ |