Nvim-lspconfig: Default display of diagnostics is disruptive

Created on 22 Apr 2020  路  5Comments  路  Source: neovim/nvim-lspconfig

  • nvim --version:
位 nvim --version
NVIM v0.5.0-dev
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: 
Compiled by nixbld

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/0ksh7zkgn9463c3wgpcz0axy192hz1ga-neovim-unwrapped-0.4.3/share/nvim
"

Run :checkhealth for more info
  • nvim-lsp version(commit hash): don't know, installed today with vim-plug
  • :checkhealth result: everything seems ok except for missing python/ruby/node/perl
  • What language server: rust-analyzer
  • Operating system/version: NixOS 20.03
  • Terminal name/version: kitty 0.16.0
  • $TERM: xterm-kitty

How to reproduce the problem from neovim startup

  • install nvim-lsp in basic configuration
位 cat ~/.config/nvim/init.vim 
call plug#begin('~/.local/share/plugged')
Plug 'neovim/nvim-lsp'
call plug#end()
lua <<EOF
require'nvim_lsp'.rust_analyzer.setup{}
EOF
  • install rust-analyzer

  • open hello-world rust project and start typing

Actual behaviour

Transient syntax errors shift the whole character grid and in general feel very disruptive

https://asciinema.org/a/gwwim5tVtoORsg5cekqdCYXn8

Expected behaviour

Language servers provide immediate feedback about syntax errors, so it is important that this feedback is not distracting from writing the code. The perfect solution would be a red squiggly. My undestanding is that this is impossible to do in a terminal, but:

  • something like underlining or just using a different color should be possible
  • the character grid is shifted even when using gui (gnvim, nvim-qt)

It might be useful to see what emacs does in default (modulo color theme) configuration:

https://asciinema.org/a/Hgcp8Zlzk1wtgFeUYCqOxCAoN

It just colors the erroneous code in red. With this color scheme it is probably too subtle, but at least the editing itself is not interrupted.

Also, I must say otherwise the out-of-the-box experience of nvim-lsp feels better: the server is started automatically, and the delay between edits and error pop-ups is much smaller!

bug

Most helpful comment

either you can assign a fixed width to your signcolumn or you can choose to disable mark creation in lsp. https://github.com/haorenW1025/diagnostic-nvim is helpful to tweak this. Maybe the default should be changed to be less disruptive.

All 5 comments

I also like how IntelliJ does this: it uses red squigly for the text span, and than it displays the actual syntax error message in the modline.

either you can assign a fixed width to your signcolumn or you can choose to disable mark creation in lsp. https://github.com/haorenW1025/diagnostic-nvim is helpful to tweak this. Maybe the default should be changed to be less disruptive.

Indeed, set signcolum=yes fixes the most problematic issue for me, thanks. Is there perhaps a similar easy config to move virtual text (?) of error message to an area not directly adjacent to the editor code?

And yes my +1 vote to make the default behavior more useful.

I don't like virtualtext either (on small screen I can't read the message). You can disable it with the aforementioned plugin. I use popups instead.

I don't like virtualtext either (on small screen I can't read the message). You can disable it with the aforementioned plugin. I use popups instead.

Is it possible to make the popup always appear instead of only on jump?

See also https://github.com/haorenW1025/diagnostic-nvim/issues/29

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahmedelgabri picture ahmedelgabri  路  4Comments

K1DV5 picture K1DV5  路  10Comments

justinmk picture justinmk  路  7Comments

cideM picture cideM  路  6Comments

jacksonludwig picture jacksonludwig  路  3Comments