Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Add the option to show diagnostics in the echo area #10

Open
subsonik opened this issue Apr 27, 2020 · 6 comments
Open

Add the option to show diagnostics in the echo area #10

subsonik opened this issue Apr 27, 2020 · 6 comments

Comments

@subsonik
Copy link

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.

@haorenW1025
Copy link
Collaborator

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:)

@subsonik
Copy link
Author

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?

@haorenW1025
Copy link
Collaborator

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>

@subsonik
Copy link
Author

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

@haorenW1025
Copy link
Collaborator

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.

@swarn
Copy link

swarn commented Oct 8, 2020

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>

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants