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

Add AsyncMake and AsyncGrep #96

Closed
Konfekt opened this issue Apr 13, 2018 · 4 comments
Closed

Add AsyncMake and AsyncGrep #96

Konfekt opened this issue Apr 13, 2018 · 4 comments

Comments

@Konfekt
Copy link

Konfekt commented Apr 13, 2018

Calling make and grep are the most common use cases for AsyncRun. How about documenting the following commands

command! -bang -nargs=* -complete=file -bar AsyncMake  AsyncRun<bang> -program=make -auto=make <args>
command! -bang -nargs=+ -complete=file -bar AsyncGrep  AsyncRun<bang> -program=grep -auto=grep <args>

that make make and grep work asynchronously ?

Perhaps its following variants

command! -bang -nargs=* -complete=file -bar AMake  silent noautocmd AsyncMake<bang> <args> | silent redraw! | copen | wincmd p
command! -bang -nargs=+ -complete=file -bar AGrep  silent noautocmd AsyncGrep<bang> <args> | silent redraw! | copen | wincmd p

that pop up the quickfix window, are welcome extensions.

@Konfekt
Copy link
Author

Konfekt commented Apr 13, 2018

However, the above AsyncMake does not work if makeprg contains an expression like % because AsyncRun does not expand it. Instead, a workaround is

command! -bang -nargs=* -complete=file -bar AsyncMake  exe 'AsyncRun<bang> -auto=make ' . &makeprg . ' ' .<q-args>
command! -bang -nargs=+ -complete=file -bar AsyncGrep  exe 'AsyncRun<bang> -auto=grep ' . &grepprg . ' ' . <q-args>

@skywind3000
Copy link
Owner

skywind3000 commented Apr 16, 2018

Thanks for your idea, let vim itself parse the makeprg/grepprg arguments. I took the idea and updated AsyncRun to support % macros. to prevent breaking old command aliases , you can still use:

command! -bang -nargs=* -complete=file Make AsyncRun -program=make @ <args>

It now accepts not only % but also $* macros in both makeprg and grepprg.

@Konfekt
Copy link
Author

Konfekt commented Apr 16, 2018

Ok, thanks! Then how about adding

command! -bang -nargs=* -complete=file -bar AsyncMake  AsyncRun<bang> -program=make -auto=make @ <args>
command! -bang -nargs=* -complete=file -bar AsyncGrep  AsyncRun<bang> -program=grep -auto=grep @ <args>

to the wiki? Better yet, because a lot more visible, to a FAQ section in the documentation (and README.md ?!).

Maybe

command! -bang -nargs=* -complete=file -bar AMake  silent noautocmd AsyncMake<bang> <args> | silent redraw! | copen | wincmd p
command! -bang -nargs=+ -complete=file -bar AGrep  silent noautocmd AsyncGrep<bang> <args> | silent redraw! | copen | wincmd p

as well.

@skywind3000
Copy link
Owner

Thanks, later, I will update the documentation. Now I am looking into command range.

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

2 participants