diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2020-04-25 15:46:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 15:46:58 +0200 |
commit | ef0398fe88e6cc74f33fb20519997774168d7832 (patch) | |
tree | 08dcf126deda4aefeb7fbd016517532896e6973f /test | |
parent | 78d58eaf61b361ed9b2849ecc1afc99897c01058 (diff) | |
download | rneovim-ef0398fe88e6cc74f33fb20519997774168d7832.tar.gz rneovim-ef0398fe88e6cc74f33fb20519997774168d7832.tar.bz2 rneovim-ef0398fe88e6cc74f33fb20519997774168d7832.zip |
LSP: Expose diagnostics grouped by bufnr (#11932)
Expose `vim.lsp.buf.diagnostics_by_buf`
This makes it easier to customize the diagnostics behavior. For example
to defer the update they can override the
`textDocument/publishDiagnostics` callback to only call
`buf_diagnostics_save_positions` and then defer the other actions to a
autocmd event.
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index b21e344acd..a57443f909 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -845,4 +845,20 @@ 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) end) |