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.84k stars 109 forks source link

Can this plugin run code in docker container and get the result in quickfix list? #273

Open meicale opened 1 year ago

meicale commented 1 year ago

It is a cool plugin and I like it. I use docker container as the development environment as well, which is easy to share and manage. How can I run the code in this docker container and can consume put the result in the quick-fix list as well. Maybe, I can be done by substitute the command to command with prefix “docker exec [args]". Where can I change the command actually run by this plugin? The other thing is how to get the result generated in docker container can copy it back to the host and set it in quick-fix list. Thank you in advance!

skywind3000 commented 1 year ago

What you need is the command modifier: https://github.com/skywind3000/asyncrun.vim#command-modifier

you can define a new modifier in a standalone script in ~/.vim/autoload/asyncrun/program or any sub-directory named autoload/asyncrun/program inside a runtime-path.

here is an example: https://github.com/skywind3000/asyncrun.vim/blob/master/autoload/asyncrun/program/shebang.vim

this script allows you use:

:AsyncRun -program=shebang  ls -la

the command ls -la will be processed and replaced by shebang.vim before execution.

meicale commented 1 year ago

I don't think it is that straightforward. I use a compiler to deal with my python traceback and I have to use the same file directory between host and container. Can this be solved to provide something like path_mapping in neovim dap debugger remote? We can sed the result and replace with the right file path of the trace back result. I think it is quite common and helpful if we can support running code in docker easily. Path mapping and helper function can be one of the solutions to this. I know little about the vim script and can this done using lua? How should we put the result in the quickfix list using neovim api or lua function?