aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp/diagnostic_spec.lua
diff options
context:
space:
mode:
authorMathias Fussenegger <f.mathias@zignar.net>2021-06-06 12:55:41 +0200
committerMathias Fussenegger <f.mathias@zignar.net>2021-06-07 18:24:32 +0200
commitf03a4d616b2eb22064719a654892cb45d584fe03 (patch)
treefc79e7838810cdc625281afb0aa42f29d85b9bc9 /test/functional/plugin/lsp/diagnostic_spec.lua
parentf2906a4669a2eef6d7bf86a29648793d63c98949 (diff)
downloadrneovim-f03a4d616b2eb22064719a654892cb45d584fe03.tar.gz
rneovim-f03a4d616b2eb22064719a654892cb45d584fe03.tar.bz2
rneovim-f03a4d616b2eb22064719a654892cb45d584fe03.zip
feat(lsp): Split out a `diagnostics_to_items` function from set_loclist
Makes it easier to re-use the logic to populate the quickfix list instead of the location list.
Diffstat (limited to 'test/functional/plugin/lsp/diagnostic_spec.lua')
-rw-r--r--test/functional/plugin/lsp/diagnostic_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua
index 8c91c4ab2c..962028e7e1 100644
--- a/test/functional/plugin/lsp/diagnostic_spec.lua
+++ b/test/functional/plugin/lsp/diagnostic_spec.lua
@@ -86,6 +86,39 @@ describe('vim.lsp.diagnostic', function()
eq(2, #result[1])
eq('Diagnostic #1', result[1][1].message)
end)
+ it('Can convert diagnostic to quickfix items format', function()
+ local bufnr = exec_lua([[
+ local fake_uri = ...
+ return vim.uri_to_bufnr(fake_uri)
+ ]], fake_uri)
+ local result = exec_lua([[
+ local bufnr = ...
+ vim.lsp.diagnostic.save(
+ {
+ make_error('Diagnostic #1', 1, 1, 1, 1),
+ make_error('Diagnostic #2', 2, 1, 2, 1),
+ }, bufnr, 1
+ )
+ return vim.lsp.util.diagnostics_to_items(vim.lsp.diagnostic.get_all())
+ ]], bufnr)
+ local expected = {
+ {
+ bufnr = bufnr,
+ col = 2,
+ lnum = 2,
+ text = 'Diagnostic #1',
+ type = 'E'
+ },
+ {
+ bufnr = bufnr,
+ col = 2,
+ lnum = 3,
+ text = 'Diagnostic #2',
+ type = 'E'
+ },
+ }
+ eq(expected, result)
+ end)
it('should be able to save and count a single client error', function()
eq(1, exec_lua [[
vim.lsp.diagnostic.save(