From db5f19471ec761576f81fb9e26d9db1f620f08f3 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Thu, 7 Jul 2022 19:50:31 +0100 Subject: [PATCH] feat(vim): add in the old run plugin This is for quickly running command in a terminal from within vim --- site-modules/core/files/vim/plugin/run.vim | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 site-modules/core/files/vim/plugin/run.vim diff --git a/site-modules/core/files/vim/plugin/run.vim b/site-modules/core/files/vim/plugin/run.vim new file mode 100644 index 0000000..f7f2b3b --- /dev/null +++ b/site-modules/core/files/vim/plugin/run.vim @@ -0,0 +1,29 @@ +" +" Runs a shell command in the neovim terminal. This will open up a buffered +" terminal in a split at the bottom +" +" a:command +" The command you want the run in the terminal +" +function! s:aa_run(command) + if strlen($TMUX) > 0 + if (&columns > 180) + let l:split = '-h' + else + let l:split = '-v' + endif + + execute 'silent !tmux split-window -p 50 ' . l:split . ' && tmux send-keys "' . a:command . ' && exit" C-m' + return + endif + + if has('nvim') + if (&columns > 180) + execute 'VTerm ' . a:command . ' && exit' + else + execute 'HTerm ' . a:command . ' && exit' + endif + endif +endfunction + +command! -nargs=* -complete=shellcmd Run call s:aa_run()