From 3521bf7672d2a33e60e2656043374a1584a0285b Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Thu, 29 Jul 2021 10:02:17 -0600 Subject: feat(lsp): implement vim.lsp.diagnostic.redraw() (#15203) Add a new function to redraw diagnostics from the current diagnostic cache, without receiving a "publishDiagnostics" message from the server. This is already being done in two places in the Lua stdlib, so this function unifies that functionality in addition to providing it to third party plugins. An example use case for this could be a command or key-binding for toggling diagnostics virtual text. The virtual text configuration option can be toggled using `vim.lsp.with` followed by `vim.lsp.diagnostic.redraw()` to immediately redraw the diagnostics with the updated setting. --- runtime/lua/vim/lsp.lua | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'runtime/lua/vim/lsp.lua') diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index f5aefc8260..87ecc3eeea 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -453,15 +453,7 @@ local function text_document_did_open_handler(bufnr, client) -- Next chance we get, we should re-do the diagnostics vim.schedule(function() - vim.lsp.handlers["textDocument/publishDiagnostics"]( - nil, - "textDocument/publishDiagnostics", - { - diagnostics = vim.lsp.diagnostic.get(bufnr, client.id), - uri = vim.uri_from_bufnr(bufnr), - }, - client.id - ) + vim.lsp.diagnostic.redraw(bufnr, client.id) end) end -- cgit