skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.86k stars 111 forks source link

Missing expansions for makeprg and grepprg #35

Open raggi opened 7 years ago

raggi commented 7 years ago

Summary: I have some makeprg's that use vim % expansions. I want both :make and :AsyncRun to work consistently. As such I want to continue to use the % style macros. I would like for asyncrun.vim to support makeprg and grepprg that contain % expansions.

When I use :AsyncRun -program=make, I expect the same output as :make, but instead I get, for example package not found %:h. This is because asyncrun#run does not expand % macros.

I have found a partial solution to the same general problem in https://github.com/timbertson/vim-background-make/commit/404905fdf87d00ef05ce72e106cf485d1ed23f3f

I have also locally applied a less complete patch as follows, which covers only my use case (no escaped expansions in my makeprgs), that could also be used as a possible approach: https://gist.github.com/raggi/3bcbb18183be138f3b24718891921d9b

An example of a makeprg I would like to work:

setlocal makeprg=go\ build\ ./%:h;echo\ package\ %:h;echo;go\ test\ ./%:h

And the corresponding errorformat, demonstrating usage:

setlocal errorformat=
      \%E%f:%l::%tarning:\ %m,
      \%E%f:%l:%c:%tarning:\ %m,
      \%E%f:%l::%trror:\ %m,
      \%E%f:%l:%c:%trror:\ %m,
      \%E%f:%l:\ %m,
      \%Dpackage\ %f,
      \%E---\ FAIL:\ %m,
      \%C%f:%l:\ %m

If you would like me to prepare a patch, let me know what your preferred approach will be, and I will add this to my TODO list.

Thanks!

skywind3000 commented 7 years ago

Your patch is incorrect, "%" will be expanded automatically by vim in the command line when you press ENTER and before passing to your User Command.

It will be expanded twice in your patch (firstly by vim, secondly by StringReplace).

It must be implemented very carefully by parsing "%" in &makeprg directly.

raggi commented 7 years ago

I demonstrated otherwise. I wouldn't have been here if it worked! :-)

On Feb 13, 2017 12:22 AM, "Linwei" notifications@github.com wrote:

Your patch is incorrect, "%" will be expanded automatically by vim in the command line when you press ENTER and before passing to your User Command.

It will be expanded twice in your patch (firstly by vim, secondly by StringReplace).

It must be implemented very carefully by parsing "%" in &makeprg directly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/skywind3000/asyncrun.vim/issues/35#issuecomment-279321365, or mute the thread https://github.com/notifications/unsubscribe-auth/AAABXCayAQawKjWSQtYPSktA6xFk00W2ks5rcBLbgaJpZM4L-r2r .

Konfekt commented 6 years ago

See also https://github.com/skywind3000/asyncrun.vim/issues/96

skywind3000 commented 6 years ago

Thank @Konfekt , I took his idea and fixed this issue:

see here.

https://github.com/skywind3000/asyncrun.vim/issues/96