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 /test/functional/plugin/lsp/diagnostic_spec.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 'test/functional/plugin/lsp/diagnostic_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp/diagnostic_spec.lua | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua index 7359ee4bce..e4fe1c1992 100644 --- a/test/functional/plugin/lsp/diagnostic_spec.lua +++ b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -205,8 +205,8 @@ describe('vim.lsp.diagnostic', function() make_warning("Warning 1", 2, 1, 2, 5), } - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_1_diags }, 1) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_2_diags }, 2) + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = server_1_diags }, {client_id=1}) + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = server_2_diags }, {client_id=2}) return { vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Error", 1), vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", 2), @@ -251,8 +251,8 @@ describe('vim.lsp.diagnostic', function() make_warning("Warning 1", 2, 1, 2, 5), } - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_1_diags }, 1) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_2_diags }, 2) + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = server_1_diags }, {client_id=1}) + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = server_2_diags }, {client_id=2}) vim.lsp.diagnostic.disable(diagnostic_bufnr, 1) @@ -290,8 +290,8 @@ describe('vim.lsp.diagnostic', function() make_warning("Warning 1", 2, 1, 2, 5), } - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_1_diags }, 1) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { uri = fake_uri, diagnostics = server_2_diags }, 2) + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = server_1_diags }, {client_id=1}) + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = server_2_diags }, {client_id=2}) return { vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Error", 1), vim.lsp.diagnostic.get_count(diagnostic_bufnr, "Warning", 2), @@ -467,14 +467,14 @@ describe('vim.lsp.diagnostic', function() it('should return all diagnostics when no severity is supplied', function() eq(2, exec_lua [[ - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = { make_error("Error 1", 1, 1, 1, 5), make_warning("Warning on Server 1", 1, 1, 2, 5), make_error("Error On Other Line", 2, 1, 1, 5), } - }, 1) + }, {client_id=1}) return #vim.lsp.diagnostic.get_line_diagnostics(diagnostic_bufnr, 1) ]]) @@ -482,7 +482,7 @@ describe('vim.lsp.diagnostic', function() it('should return only requested diagnostics when severity_limit is supplied', function() eq(2, exec_lua [[ - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = { make_error("Error 1", 1, 1, 1, 5), @@ -490,7 +490,7 @@ describe('vim.lsp.diagnostic', function() make_information("Ignored information", 1, 1, 2, 5), make_error("Error On Other Line", 2, 1, 1, 5), } - }, 1) + }, {client_id=1}) return #vim.lsp.diagnostic.get_line_diagnostics(diagnostic_bufnr, 1, { severity_limit = "Warning" }) ]]) @@ -502,12 +502,12 @@ describe('vim.lsp.diagnostic', function() exec_lua [[ vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = function() return true end, - })(nil, nil, { + })(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) ]] @@ -519,12 +519,12 @@ describe('vim.lsp.diagnostic', function() exec_lua [[ vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = function() return false end, - })(nil, nil, { + })(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) ]] @@ -541,12 +541,12 @@ describe('vim.lsp.diagnostic', function() exec_lua [[ vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { update_in_insert = false, - })(nil, nil, { + })(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) ]] @@ -583,12 +583,12 @@ describe('vim.lsp.diagnostic', function() return SetVirtualTextOriginal(...) end - PublishDiagnostics(nil, nil, { + PublishDiagnostics(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) ]] @@ -637,12 +637,12 @@ describe('vim.lsp.diagnostic', function() return SetVirtualTextOriginal(...) end - PublishDiagnostics(nil, nil, { + PublishDiagnostics(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) ]] @@ -679,12 +679,12 @@ describe('vim.lsp.diagnostic', function() exec_lua [[ vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { update_in_insert = true, - })(nil, nil, { + })(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) ]] @@ -709,12 +709,12 @@ describe('vim.lsp.diagnostic', function() }, }) - PublishDiagnostics(nil, nil, { + PublishDiagnostics(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) return vim.api.nvim_buf_get_extmarks( @@ -746,12 +746,12 @@ describe('vim.lsp.diagnostic', function() end, }) - PublishDiagnostics(nil, nil, { + PublishDiagnostics(nil, { uri = fake_uri, diagnostics = { make_error('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) return vim.api.nvim_buf_get_extmarks( @@ -779,12 +779,12 @@ describe('vim.lsp.diagnostic', function() }, }) - PublishDiagnostics(nil, nil, { + PublishDiagnostics(nil, { uri = fake_uri, diagnostics = { make_warning('Delayed Diagnostic', 4, 4, 4, 4), } - }, 1 + }, {client_id=1} ) return count_of_extmarks_for_client(diagnostic_bufnr, 1) @@ -870,10 +870,10 @@ describe('vim.lsp.diagnostic', function() } vim.api.nvim_win_set_buf(0, diagnostic_bufnr) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = diagnostics - }, 1 + }, {client_id=1} ) vim.lsp.diagnostic.set_signs(diagnostics, diagnostic_bufnr, 1) @@ -895,13 +895,13 @@ describe('vim.lsp.diagnostic', function() local loc_list = exec_lua [[ vim.api.nvim_win_set_buf(0, diagnostic_bufnr) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = { make_error('Farther Diagnostic', 4, 4, 4, 4), make_error('Lower Diagnostic', 1, 1, 1, 1), } - }, 1 + }, {client_id=1} ) vim.lsp.diagnostic.set_loclist() @@ -916,20 +916,20 @@ describe('vim.lsp.diagnostic', function() local loc_list = exec_lua [[ vim.api.nvim_win_set_buf(0, diagnostic_bufnr) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = { make_error('Lower Diagnostic', 1, 1, 1, 1), } - }, 1 + }, {client_id=1} ) - vim.lsp.diagnostic.on_publish_diagnostics(nil, nil, { + vim.lsp.diagnostic.on_publish_diagnostics(nil, { uri = fake_uri, diagnostics = { make_warning('Farther Diagnostic', 4, 4, 4, 4), } - }, 2 + }, {client_id=2} ) vim.lsp.diagnostic.set_loclist() |