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/doc/lsp.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'runtime/doc') diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt index c750a65c10..7daab4d6f1 100644 --- a/runtime/doc/lsp.txt +++ b/runtime/doc/lsp.txt @@ -1487,6 +1487,22 @@ on_publish_diagnostics({_}, {_}, {params}, {client_id}, {_}, {config}) • Sort diagnostics (and thus signs and virtual text) +redraw({bufnr}, {client_id}) *vim.lsp.diagnostic.redraw()* + Redraw diagnostics for the given buffer and client + + This calls the "textDocument/publishDiagnostics" handler + manually using the cached diagnostics already received from + the server. This can be useful for redrawing diagnostics after + making changes in diagnostics configuration. + |lsp-handler-configuration| + + Parameters: ~ + {bufnr} (optional, number): Buffer handle, defaults + to current + {client_id} (optional, number): Redraw diagnostics for + the given client. The default is to redraw + diagnostics for all attached clients. + reset({client_id}, {buffer_client_map}) *vim.lsp.diagnostic.reset()* Clear diagnotics and diagnostic cache -- cgit