[SOLVED] What is the correct/recommended way to run a shell command in NeoVim in the background?

Hi,

As mentioned in the title, how do I run a shell command in NeoVim in the background/silently, without affecting my current buffer or opening up new buffers?

The reason I’m asking this is I’m currently set up Common Lisp dev environment and I need to run this in the background (to connect to SWANK server):

! xterm -e sbcl --load /usr/share/common-lisp/source/slime/start-swank.lisp &

but looks like it does nothing.

I tried to manually run this in NeoVim by :! xterm -e sbcl --load /usr/share/common-lisp/source/slime/start-swank.lisp & but nothing happened. No further output either.

I know that there are a few ways to run a command in the background and there’s even a plugin for that, but what is the recommended way, ideally without installing another plugin? Please help, thanks!

I’ve been looking into this briefly for my own future needs and it seems the job functions should be able to do this.

https://neovim.io/doc/user/job_control.html

1 Like

not a solution, but just a note
if ur already using some popular plugins, you might have plenary installed as a dependency, which has a handy Job interface in lua.

Thanks for the link! It was helpful. I changed the command and started using jobstart:

let g:slimv_swank_cmd = "call jobstart('xterm -e & sbcl --load ${pkgs.vimPlugins.slimv}/slime/start-swank.lisp')"

and it’s working correctly now. Thanks a lot!

1 Like