aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp_spec.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-11-12 22:21:34 -0500
committerGitHub <noreply@github.com>2020-11-12 22:21:34 -0500
commitf75be5e9d510d5369c572cf98e78d9480df3b0bb (patch)
treee25baab19bcb47ca0d2edcf0baa18b71cfd03f9e /test/functional/plugin/lsp_spec.lua
parent4ae31c46f75aef7d7a80dd2a8d269c168806a1bd (diff)
downloadrneovim-f75be5e9d510d5369c572cf98e78d9480df3b0bb.tar.gz
rneovim-f75be5e9d510d5369c572cf98e78d9480df3b0bb.tar.bz2
rneovim-f75be5e9d510d5369c572cf98e78d9480df3b0bb.zip
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes: - Deprecated all `vim.lsp.util.{*diagnostics*}()` functions. - Instead, all functions must be found in vim.lsp.diagnostic - For now, they issue a warning ONCE per neovim session. In a "little while" we will remove them completely. - `vim.lsp.callbacks` has moved to `vim.lsp.handlers`. - For a "little while" we will just redirect `vim.lsp.callbacks` to `vim.lsp.handlers`. However, we will remove this at some point, so it is recommended that you change all of your references to `callbacks` into `handlers`. - This also means that for functions like |vim.lsp.start_client()| and similar, keyword style arguments have moved from "callbacks" to "handlers". Once again, these are currently being forward, but will cease to be forwarded in a "little while". - Changed the highlight groups for LspDiagnostic highlight as they were inconsistently named. - For more information, see |lsp-highlight-diagnostics| - Changed the sign group names as well, to be consistent with |lsp-highlight-diagnostics| General Enhancements: - Rewrote much of the getting started help document for lsp. It also provides a much nicer configuration strategy, so as to not recommend globally overwriting builtin neovim mappings. LSP Enhancements: - Introduced the concept of |lsp-handlers| which will allow much better customization for users without having to copy & paste entire files / functions / etc. Diagnostic Enhancements: - "goto next diagnostic" |vim.lsp.diagnostic.goto_next()| - "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()| - For each of the gotos, auto open diagnostics is available as a configuration option - Configurable diagnostic handling: - See |vim.lsp.diagnostic.on_publish_diagnostics()| - Delay display until after insert mode - Configure signs - Configure virtual text - Configure underline - Set the location list with the buffers diagnostics. - See |vim.lsp.diagnostic.set_loclist()| - Better performance for getting counts and line diagnostics - They are now cached on save, to enhance lookups. - Particularly useful for checking in statusline, etc. - Actual testing :) - See ./test/functional/plugin/lsp/diagnostic_spec.lua - Added `guisp` for underline highlighting NOTE: "a little while" means enough time to feel like most plugins and plugin authors have had a chance to refactor their code to use the updated calls. Then we will remove them completely. There is no need to keep them, because we don't have any released version of neovim that exposes these APIs. I'm trying to be nice to people following HEAD :) Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r--test/functional/plugin/lsp_spec.lua95
1 files changed, 29 insertions, 66 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 00093f71d4..5b048f57e9 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -323,7 +323,7 @@ describe('LSP', function()
test_name = "capabilities_for_client_supports_method";
on_setup = function()
exec_lua([=[
- vim.lsp.callbacks['textDocument/hover'] = function(err, method)
+ vim.lsp.handlers['textDocument/hover'] = function(err, method)
vim.lsp._last_lsp_callback = { err = err; method = method }
end
vim.lsp._unsupported_method = function(method)
@@ -847,25 +847,28 @@ describe('LSP', function()
end
it('highlight groups', function()
- eq({'LspDiagnosticsError',
- 'LspDiagnosticsErrorFloating',
- 'LspDiagnosticsErrorSign',
- 'LspDiagnosticsHint',
- 'LspDiagnosticsHintFloating',
- 'LspDiagnosticsHintSign',
- 'LspDiagnosticsInformation',
- 'LspDiagnosticsInformationFloating',
- 'LspDiagnosticsInformationSign',
- 'LspDiagnosticsUnderline',
- 'LspDiagnosticsUnderlineError',
- 'LspDiagnosticsUnderlineHint',
- 'LspDiagnosticsUnderlineInformation',
- 'LspDiagnosticsUnderlineWarning',
- 'LspDiagnosticsWarning',
- 'LspDiagnosticsWarningFloating',
- 'LspDiagnosticsWarningSign',
- },
- exec_lua([[require'vim.lsp'; return vim.fn.getcompletion('Lsp', 'highlight')]]))
+ eq({
+ 'LspDiagnosticsDefaultError',
+ 'LspDiagnosticsDefaultHint',
+ 'LspDiagnosticsDefaultInformation',
+ 'LspDiagnosticsDefaultWarning',
+ 'LspDiagnosticsFloatingError',
+ 'LspDiagnosticsFloatingHint',
+ 'LspDiagnosticsFloatingInformation',
+ 'LspDiagnosticsFloatingWarning',
+ 'LspDiagnosticsSignError',
+ 'LspDiagnosticsSignHint',
+ 'LspDiagnosticsSignInformation',
+ 'LspDiagnosticsSignWarning',
+ 'LspDiagnosticsUnderlineError',
+ 'LspDiagnosticsUnderlineHint',
+ 'LspDiagnosticsUnderlineInformation',
+ 'LspDiagnosticsUnderlineWarning',
+ 'LspDiagnosticsVirtualTextError',
+ 'LspDiagnosticsVirtualTextHint',
+ 'LspDiagnosticsVirtualTextInformation',
+ 'LspDiagnosticsVirtualTextWarning',
+ }, exec_lua([[require'vim.lsp'; return vim.fn.getcompletion('Lsp', 'highlight')]]))
end)
describe('apply_text_edits', function()
@@ -1037,7 +1040,7 @@ describe('LSP', function()
label = nil;
edit = {};
}
- return vim.lsp.callbacks['workspace/applyEdit'](nil, nil, apply_edit)
+ return vim.lsp.handlers['workspace/applyEdit'](nil, nil, apply_edit)
]])
end)
end)
@@ -1084,47 +1087,7 @@ describe('LSP', function()
eq({}, exec_lua([[return vim.lsp.util.text_document_completion_list_to_complete_items(...)]], {}, prefix))
end)
end)
- describe('buf_diagnostics_save_positions', function()
- it('stores the diagnostics in diagnostics_by_buf', function ()
- local diagnostics = {
- { range = {}; message = "diag1" },
- { range = {}; message = "diag2" },
- }
- exec_lua([[
- vim.lsp.util.buf_diagnostics_save_positions(...)]], 0, diagnostics)
- eq(1, exec_lua [[ return #vim.lsp.util.diagnostics_by_buf ]])
- eq(diagnostics, exec_lua [[
- for _, diagnostics in pairs(vim.lsp.util.diagnostics_by_buf) do
- return diagnostics
- end
- ]])
- end)
- end)
- describe('lsp.util.show_line_diagnostics', function()
- it('creates floating window and returns popup bufnr and winnr if current line contains diagnostics', function()
- eq(3, exec_lua [[
- local buffer = vim.api.nvim_create_buf(false, true)
- vim.api.nvim_buf_set_lines(buffer, 0, -1, false, {
- "testing";
- "123";
- })
- local diagnostics = {
- {
- range = {
- start = { line = 0; character = 1; };
- ["end"] = { line = 0; character = 3; };
- };
- severity = vim.lsp.protocol.DiagnosticSeverity.Error;
- message = "Syntax error";
- },
- }
- vim.api.nvim_win_set_buf(0, buffer)
- vim.lsp.util.buf_diagnostics_save_positions(vim.fn.bufnr(buffer), diagnostics)
- local popup_bufnr, winnr = vim.lsp.util.show_line_diagnostics()
- return popup_bufnr
- ]])
- end)
- end)
+
describe('lsp.util.locations_to_items', function()
it('Convert Location[] to items', function()
local expected = {
@@ -1556,7 +1519,7 @@ describe('LSP', function()
describe('vim.lsp.buf.outgoing_calls', function()
it('does nothing for an empty response', function()
local qflist_count = exec_lua([=[
- require'vim.lsp.callbacks'['callHierarchy/outgoingCalls']()
+ require'vim.lsp.handlers'['callHierarchy/outgoingCalls']()
return #vim.fn.getqflist()
]=])
eq(0, qflist_count)
@@ -1602,7 +1565,7 @@ describe('LSP', function()
uri = "file:///src/main.rs"
}
} }
- local callback = require'vim.lsp.callbacks'['callHierarchy/outgoingCalls']
+ local callback = require'vim.lsp.handlers'['callHierarchy/outgoingCalls']
callback(nil, nil, rust_analyzer_response)
return vim.fn.getqflist()
]=])
@@ -1627,7 +1590,7 @@ describe('LSP', function()
describe('vim.lsp.buf.incoming_calls', function()
it('does nothing for an empty response', function()
local qflist_count = exec_lua([=[
- require'vim.lsp.callbacks'['callHierarchy/incomingCalls']()
+ require'vim.lsp.handlers'['callHierarchy/incomingCalls']()
return #vim.fn.getqflist()
]=])
eq(0, qflist_count)
@@ -1674,7 +1637,7 @@ describe('LSP', function()
} }
} }
- local callback = require'vim.lsp.callbacks'['callHierarchy/incomingCalls']
+ local callback = require'vim.lsp.handlers'['callHierarchy/incomingCalls']
callback(nil, nil, rust_analyzer_response)
return vim.fn.getqflist()
]=])