aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp/diagnostic_spec.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-06-07 09:43:43 -0700
committerGitHub <noreply@github.com>2021-06-07 09:43:43 -0700
commit93f15db5d61800a2029aa20684be31c96ebcca5b (patch)
treefc79e7838810cdc625281afb0aa42f29d85b9bc9 /test/functional/plugin/lsp/diagnostic_spec.lua
parentf2906a4669a2eef6d7bf86a29648793d63c98949 (diff)
parentf03a4d616b2eb22064719a654892cb45d584fe03 (diff)
downloadrneovim-93f15db5d61800a2029aa20684be31c96ebcca5b.tar.gz
rneovim-93f15db5d61800a2029aa20684be31c96ebcca5b.tar.bz2
rneovim-93f15db5d61800a2029aa20684be31c96ebcca5b.zip
Merge pull request #14736 from mfussenegger/lsp-diagnostic-get-qfitems
feat(lsp): Split out a "get qf items" func from set_loclist
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(