preservim / vimux

easily interact with tmux from vim
MIT License
2.19k stars 159 forks source link

Run vim command after VimuxRunCommand. #162

Open metasansana opened 6 years ago

metasansana commented 6 years ago

Is this supported?

Say I want to run a lint vim plugin after I use VimRunCommand to build some files of BufWrite. I tried chaining them but vim does not wait for the shell command to complete before moving on to the next command in the chain.

Example:


autocmd BufWritePost,FileWritePost *.ts :execute 'VimuxRunCommand "make test"' | TsuGeterr
leostera commented 6 years ago

Hi @metasansana I don't think this is something that is currently supported since the plugin simply sends the commands over to tmux and doesn't really know when the commands have been finished.

You may want to look into writing an async job that will do this for you. See here for a quick intro: http://andrewvos.com/writing-async-jobs-in-vim-8

metasansana commented 6 years ago

Thanks @ostera I'll check it out.

alerque commented 3 years ago

This should be a really easy fix, I think vimscript has a simple way to make commands chainable.

alerque commented 3 years ago

Yes and no. Setting up the commands so that you can use them in a chain is easy. I just setup a PR for that and it will close this issue shortly. The flip side of the coin is that @ostera is right that the Vimux command will just do its thing and then move on. If you want to setup actions after certain shell results (either success or failure) you will need to chain them as part of the shell command you are launching. Passing some callback function to VIM from your other shell is kind of out of scope for this plugin. At that point you aren't interacting with Tmux so much as vim vs. your shell commands.

If there is anything we can do to facilitate an easier callback system I'd be happy to consider it, but given that the default usage is to leave the runner pane open I don't think there is a way to do this without hacking up a different set of commands that would no longer be async like Vimux is.

alerque commented 3 years ago

This caused a serious regression and I'm backing it out for now, see issue in #185 and reverting part of this feature in #186.