diff options
author | TJ DeVries <devries.timothyj@gmail.com> | 2021-01-12 12:58:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-12 12:58:50 -0500 |
commit | 9f3b2a757b866cf117efecf3ca1a2233e77217d8 (patch) | |
tree | 63ea815c6b04014a5518c5aa231ab8331e5cf755 /test/functional/plugin/lsp/diagnostic_spec.lua | |
parent | e0a4399adc4472b9b02a26c7f93b056c4725a6b9 (diff) | |
download | rneovim-9f3b2a757b866cf117efecf3ca1a2233e77217d8.tar.gz rneovim-9f3b2a757b866cf117efecf3ca1a2233e77217d8.tar.bz2 rneovim-9f3b2a757b866cf117efecf3ca1a2233e77217d8.zip |
lsp: Add severity_limit for other diagnostics features (#13528)
* lsp: Add severity_limit for other diagnostics
* docs and tests
* fix: lint
* Add to other types
* fix: lint
Diffstat (limited to 'test/functional/plugin/lsp/diagnostic_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp/diagnostic_spec.lua | 100 |
1 files changed, 65 insertions, 35 deletions
diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua index 3a676359ab..4705a76465 100644 --- a/test/functional/plugin/lsp/diagnostic_spec.lua +++ b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -12,41 +12,41 @@ describe('vim.lsp.diagnostic', function() clear() exec_lua [[ - require('vim.lsp') - - make_range = function(x1, y1, x2, y2) - return { start = { line = x1, character = y1 }, ['end'] = { line = x2, character = y2 } } - end - - make_error = function(msg, x1, y1, x2, y2) - return { - range = make_range(x1, y1, x2, y2), - message = msg, - severity = 1, - } - end - - make_warning = function(msg, x1, y1, x2, y2) - return { - range = make_range(x1, y1, x2, y2), - message = msg, - severity = 2, - } - end - - make_information = function(msg, x1, y1, x2, y2) - return { - range = make_range(x1, y1, x2, y2), - message = msg, - severity = 3, - } - end - - count_of_extmarks_for_client = function(bufnr, client_id) - return #vim.api.nvim_buf_get_extmarks( - bufnr, vim.lsp.diagnostic._get_diagnostic_namespace(client_id), 0, -1, {} - ) - end + require('vim.lsp') + + make_range = function(x1, y1, x2, y2) + return { start = { line = x1, character = y1 }, ['end'] = { line = x2, character = y2 } } + end + + make_error = function(msg, x1, y1, x2, y2) + return { + range = make_range(x1, y1, x2, y2), + message = msg, + severity = 1, + } + end + + make_warning = function(msg, x1, y1, x2, y2) + return { + range = make_range(x1, y1, x2, y2), + message = msg, + severity = 2, + } + end + + make_information = function(msg, x1, y1, x2, y2) + return { + range = make_range(x1, y1, x2, y2), + message = msg, + severity = 3, + } + end + + count_of_extmarks_for_client = function(bufnr, client_id) + return #vim.api.nvim_buf_get_extmarks( + bufnr, vim.lsp.diagnostic._get_diagnostic_namespace(client_id), 0, -1, {} + ) + end ]] fake_uri = "file://fake/uri" @@ -640,6 +640,36 @@ describe('vim.lsp.diagnostic', function() eq(expected_spacing, #spacing) end) + + it('allows filtering via severity limit', function() + local get_extmark_count_with_severity = function(severity_limit) + return exec_lua([[ + PublishDiagnostics = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + underline = false, + virtual_text = { + severity_limit = ... + }, + }) + + PublishDiagnostics(nil, nil, { + uri = fake_uri, + diagnostics = { + make_warning('Delayed Diagnostic', 4, 4, 4, 4), + } + }, 1 + ) + + return count_of_extmarks_for_client(diagnostic_bufnr, 1) + ]], severity_limit) + end + + -- No messages with Error or higher + eq(0, get_extmark_count_with_severity("Error")) + + -- But now we don't filter it + eq(1, get_extmark_count_with_severity("Warning")) + eq(1, get_extmark_count_with_severity("Hint")) + end) end) describe('lsp.util.show_line_diagnostics', function() |