diagnostic-nvim icon indicating copy to clipboard operation
diagnostic-nvim copied to clipboard

Add the option to show diagnostics in the echo area

Open subsonik opened this issue 5 years ago • 6 comments

Hi,

Great work with this plugin, your plugins have quickyl become an essential part of my setup! :)

Would it be possible to add the ability to show diagnostics in the echo area, ala https://github.com/Shougo/echodoc.vim ?

I find popups annoying because they obstruct my code and get in the way, and virtual text is also quite jarring and looks silly when chatty languages like Rust attempt to show errors that are 50-70 characters long and they end up going off screen. Especially when I have splits open, the error messages can be quite useless because they show nothing of use before getting cut off.

The echo area seems like the ideal place to show diagnostics to me, and I'm surprised more plugins don't use it.

Thanks.

subsonik avatar Apr 27 '20 21:04 subsonik

Hmm I'll try to see if it's possible, but having will having 50-70 lines in echo area help? Just curious though. Also I'm working on some custom preview in completion-nvim inspired by ncm, will this be a better place to show diagnostics? Let me know what you think:)

haorenW1025 avatar Apr 28 '20 02:04 haorenW1025

Do you mean the let g:float_preview#docked = 1 preview shown in your link? I personally think that's a little distracting, but of course it's highly subjective. :)

Maybe if implementing diagnostic messages in the echo area is too much work, would it instead be possible to show a popup window when hovering the cursors over the offending text, instead of having to use the NextDiagnostic and PrevDiagnostic commands?

I can open a new issue and close this one if you like?

subsonik avatar Apr 28 '20 19:04 subsonik

Actually implement it in echo area is definitely possible, but that could lead to various issues. For one example, if the echo area exceed one line it would requires you to press enter to continue editing, which will also be distracting. My suggestion is disable the auto popup by

let g:diagnostic_auto_popup_while_jump = 1

and trigger the line diagnostic with a mapping instead.

nnoremap <leader>d <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>

haorenW1025 avatar Apr 29 '20 01:04 haorenW1025

My suggestion is disable the auto popup by

let g:diagnostic_auto_popup_while_jump = 1

and trigger the line diagnostic with a mapping instead.

nnoremap <leader>d <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>

Thanks for the suggestion, but running lua vim.lsp.util.show_line_diagnostics() while diagnostic-nvim is enabled doesn't seem to have any effect. If I disable diagnostic-nvim, then I get a popup as expected. Here is my current config:

let g:diagnostic_auto_popup_while_jump = 1
" let g:diagnostic_enable_virtual_text = 0
" let g:diagnostic_insert_delay = 0
" let g:diagnostic_level = 'Information'
" let g:space_before_virtual_text = 2

subsonik avatar Apr 29 '20 03:04 subsonik

Oh my fault, first of all you should use let g:diagnostic_auto_popup_while_jump = 0 to disable auto popup instead. Secondly since I overwrite the callback function and store the information locally, you should use

nnoremap <leader>d <cmd>lua require'diagnostic.util'.show_line_diagnostics()<CR>

I should put this in README though.

haorenW1025 avatar Apr 29 '20 03:04 haorenW1025

For those like me who found this issue by searching, I believe that last comment is out of date. However, the mapping mentioned earlier works:

nnoremap <leader>d <cmd>lua vim.lsp.util.show_line_diagnostics()<CR>

swarn avatar Oct 08 '20 14:10 swarn