Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output is not matched by errorformat, which is defined by :compiler command #16

Closed
ladrift opened this issue Oct 26, 2016 · 14 comments
Closed

Comments

@ladrift
Copy link

ladrift commented Oct 26, 2016

I am using rust-lang/rust.vim plugin which defines a cargo compiler with its errorformat.
After I typed :compiler cargo, I run :AsyncRun cargo build. Its output in quickfix list is not matched correctly.
But, by typing :make, the output in quickfix list is matched correctly.

@skywind3000
Copy link
Owner

could you please provide an instruction to reproduce ?

@ladrift
Copy link
Author

ladrift commented Oct 27, 2016

  1. Install rust by instructions on rust-lang.org
  2. Install rust-lang/rust.vim plugin.
  3. cargo new hello_world --bin && cd hello_world (this command creates a new cargo project).
  4. Open a src/main.rs file in vim, delete some lines to make it compiler error.
  5. Type :compiler cargo and :make build and :copen, the output will be matched correctly.
  6. Reopen this file, type :compiler cargo and :AsyncRun cargo build and :copen. The output will be matched incorrectly.

My vim version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 19 2016 08:21:01)
MacOS X (unix) version
Included patches: 1-45
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             -ebcdic          +listcmds        +persistent_undo +textobjects
+arabic          +emacs_tags      +localmap        +postscript      +timers
+autocmd         +eval            -lua             +printer         +title
-balloon_eval    +ex_extra        +menu            +profile         -toolbar
-browse          +extra_search    +mksession       +python          +user_commands
++builtin_terms  +farsi           +modify_fname    -python3         +vertsplit
+byte_offset     +file_in_path    +mouse           +quickfix        +virtualedit
+channel         +find_in_path    -mouseshape      +reltime         +visual
+cindent         +float           +mouse_dec       +rightleft       +visualextra
-clientserver    +folding         -mouse_gpm       +ruby            +viminfo
+clipboard       -footer          -mouse_jsbterm   +scrollbind      +vreplace
+cmdline_compl   +fork()          +mouse_netterm   +signs           +wildignore
+cmdline_hist    -gettext         +mouse_sgr       +smartindent     +wildmenu
+cmdline_info    -hangul_input    -mouse_sysmouse  +startuptime     +windows
+comments        +iconv           +mouse_urxvt     +statusline      +writebackup
+conceal         +insert_expand   +mouse_xterm     -sun_workshop    -X11
+cryptv          +job             +multi_byte      +syntax          -xfontset
+cscope          +jumplist        +multi_lang      +tag_binary      -xim
+cursorbind      +keymap          -mzscheme        +tag_old_static  -xpm
+cursorshape     +lambda          +netbeans_intg   -tag_any_white   -xsmp
+dialog_con      +langmap         +num64           -tcl             -xterm_clipboard+diff            +libcall         +packages        +termguicolors   -xterm_save
+digraphs        +linebreak       +path_extra      +terminfo        
-dnd             +lispindent      +perl            +termresponse    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.0_1/lib/perl5/5.24.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.3.0 -lobjc -L/usr/local/Cellar/ruby/2.3.1_2/lib    

@skywind3000
Copy link
Owner

ok, I will have a look at it asap

@ladrift
Copy link
Author

ladrift commented Oct 27, 2016

Here are GIF record of re-producing this issue.
async_issue

@skywind3000
Copy link
Owner

skywind3000 commented Oct 27, 2016

asyncrun uses caddexpr to populate the quickfix list. caddexpr only works with global value of errorformat, but rust-lang/rust.vim set the local value of errorformat instead of global value.

why doesn't caddexpr use local errorformat value ?
see here

currently, there is nothing I can do to fix the behavior of caddexpr , but you can change your global errorformat settings after :compiler cargo by:

:set &g:errorformat = &l:errorformat

@ladrift
Copy link
Author

ladrift commented Oct 27, 2016

It seems that tpope/vim-dispatch can handle it correctly.
Its compiler switching feature can detect compiler command and use its setting to populate the quickfix list.
We can inspect its source code to find solution for this situation.
Maybe we can turn this issue into a feature request.

@skywind3000
Copy link
Owner

skywind3000 commented Oct 27, 2016

because vim-dispatch doesn't fill quickfix in realtime, it will collect all the output and use :make to display it all together after background job finished.

So you can't read information in realtime with vim-dispatch (only in a tmux split instead).
I have already inspected the source of vim-dispatch.

It simply use a :make which means you can't read any thing in quickfix until the entire command is finished.

:make will use local value of errorformat.

@skywind3000
Copy link
Owner

skywind3000 commented Oct 27, 2016

OK, I updated a new version, in the latest version of asyncrun, you can use:

let g:asyncrun_local = 1

this will tell asyncrun to use local errorformat rather than the global value by temporarily
modifing &g:errorformat and restoring it after :caddexpr.

The reason to make it an option but not the default behaviour is that:
I am afraid :caddexpr will change to use the local errorformat some day.
(because it had been using the local value).

would you please try out the latest version and give me some feedback ?

@skywind3000
Copy link
Owner

skywind3000 commented Oct 27, 2016

Fortunately, cargo supports output json format :

Add --message-format flag
and Rustc’s json output format

And then we can write a output filter to translate the cargo output to editor friendly format.

How to pass options from cargo build to rustc ? it seems I can use --error-format=json in rustc.
but when I use cargo build, I can't figure out how to pass this option to rustc .

@skywind3000
Copy link
Owner

skywind3000 commented Oct 27, 2016

figured it out: set the environment variable named "RUSTFLAGS" to "--error-format=json" then
cargo can output json

@tracyone
Copy link

虽然不太懂,但我也意识到这是个问题,本来cw只是列出错误的,但现在和copen一样。

@skywind3000
Copy link
Owner

嗯,是的,rustc的输出对编辑器不是特别友好。

@skywind3000
Copy link
Owner

那先关闭了吧。

@ladrift
Copy link
Author

ladrift commented Oct 28, 2016

It works. Thanks for your quick response.

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

No branches or pull requests

3 participants