Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I show multi-line Rust error messages in vim?

I use Syntastic and the error messages in vim usually only have one line, I find this information to be insufficient.

Is there a compiler flag so the first line of the error is more meaningful, or so that I can see multiline errors in the quickfix window? I'm having to constantly go and cargo build the errors somewhere, which should be just a "put mouse in cursor" away, usually the error fits the space (I have a wide monitor).

I'm using macOS.

like image 500
Felipe Valdes Avatar asked Feb 01 '18 06:02

Felipe Valdes


2 Answers

quickfix windows (actually, loclist windows in the case of syntastic) don't support multiline error messages. This is a limitation of Vim.

What you can do is convince the checker to merge multiline error messages to single lines before parsing them. Syntastic provides hooks for doing that, but cargo is not a standard syntastic checker. So perhaps contact the authors of said checker and post a feature request.

like image 70
lcd047 Avatar answered Oct 12 '22 22:10

lcd047


you need correctly setting the Syntastic and rust bundle in vim. see example in my vimrc(use Vundle):

" vimrc
Plugin 'vim-syntastic/syntastic'
Plugin 'rust-lang/rust.vim'
Plugin 'racer-rust/vim-racer'
Plugin 'timonv/vim-cargo'

" Syntastic
let g:syntastic_error_symbol = 'EE'
let g:syntastic_style_error_symbol = 'E>'
let g:syntastic_warning_symbol = 'WW'
let g:syntastic_style_warning_symbol = 'W>'

let g:syntastic_auto_loc_list = 1
let g:syntastic_rust_checkers = ['cargo']
like image 28
xds2000 Avatar answered Oct 12 '22 23:10

xds2000