You can't make it. I don't use coc.nvim for a long time, but scanned the doc for a while and searched around.
First, coc has fetched diagnostics on the fly already by default. So it's the suitable option for your question.
Second, nvim supports lsp handlers with on_publish_diagnostics
where only the update_in_insert
option is related here.
update_in_insert: (default false) Update diagnostics in Insert mode (if false, diagnostics are updated on InsertLeave)
Third, a closed pr in nvim proposed the following option (and the currently adopted update_in_insert
option mentioned above)
show_diagnostic_autocmds = { 'InsertLeave', 'TextChanged' },
but it turned out the option can be replaced with a user's autocmd
-- shows on InsertLeave & TextChanged for all clients attached to current buffer, where virtual_text is false, but underline and signs default true
vim.cmd[[autocmd InsertLeave,TextChanged * lua vim.lsp.diagnostic.show_buffer_diagnostics(nil, nil, {virtual_text = false})]]
No, it's not possible. The last thing is that you actually can't do much, especially with how RA is designed:
rust-analyzer is a young tool and comes with a lot of limitations. The most significant one is that we are not at the moment using rustc
directly, so our capabilities for detecting errors are limited.
In particular, to show inline errors we are doing what Emacs has been doing for ages — running cargo check
after the file is saved. If auto-save is enabled in the editor, the result is actually quite nice for small projects.
For bigger projects though, I feel like cargo check
in background gets in the way. So for rust-analyzer
I have rust-analyzer.checkOnSave.enabled = false;
in the settings. Instead, I use the Run functionality to run check
/ test
and keyboard shortcuts to navigate between errors.
src: First Release