mg979 / tasks.vim

Async jobs and tasks
15 stars 2 forks source link

Wrapper and Autosave #1

Open Konfekt opened 3 years ago

Konfekt commented 3 years ago

Thank you for this great plug-in that seems to have gone mostly unnoticed till now. I am particularly glad that it offers (window-)local make (and grep) commands.

As it was inspired by asyncrun some of it useful options could be transferred, how about

mg979 commented 3 years ago
  1. autosave is actually default, except for grep commands. So Async and Make update current buffer. I didn't want grep commands to save the buffers because sometimes I don't want that. I don't want g: options, maybe I'll make an option for the global tasks.ini file. Personally I have mappings like:

    nnoremap gr<space> :LGrep<space>

if you use mappings too, you can just prepend an :update<cr>. I'd like to avoid an option just for grep commands.

  1. how would that work? which commands would you run that way? what's the gain for a command run for vim?
mg979 commented 3 years ago

If you really want all grep commands to autosave, you can also rewrite the commands:

command! -nargs=1 -bang Grep      call async#qfix(<q-args>, {'nojump': <bang>0, 'grep': 1, 'nosave': 0})
command! -nargs=1 -bang LGrep     call async#qfix(<q-args>, {'nojump': <bang>0, 'grep': 1, 'nosave': 0, 'locl': 1})
command! -nargs=1 -bang GrepAdd   call async#qfix(<q-args>, {'nojump': <bang>0, 'grep': 1, 'nosave': 0, 'append': 1})
command! -nargs=1 -bang LGrepAdd  call async#qfix(<q-args>, {'nojump': <bang>0, 'grep': 1, 'nosave': 0, 'locl': 1, 'append': 1})
Konfekt commented 3 years ago

autosave is actually default, except for grep commands.

Thank you, that suits me as well; I did not know.

how would that work?

Just by prepending the string g:asyncrun_wrapper given as a global option to the command to be run; for example, a grep command could be run under ionice.

mg979 commented 2 years ago

Just by prepending the string g:asyncrun_wrapper given as a global option to the command to be run; for example, a grep command could be run under ionice.

https://github.com/skywind3000/asyncrun.vim/blob/9f8e50033cb724d8856907a5fbf4685eb3efda24/plugin/asyncrun.vim#L1683-L1687

From what I can see in the code, this wrapper just prepends a string to the command. It does no escaping or anything special. So basically it's not worth an option, you can just change the command itself.

Konfekt commented 2 years ago

It is just more convenient to have it automatically prepended instead of having to change all definitions of &makeprg including the (built-in) compiler files.

mg979 commented 2 years ago

I see. I'll add it as an option to the global/local tasks configuration file, I don't want a global variable because it could be set from anywhere and then all commands could be wrapped without even knowing.