A simple script runner plugin with a pompous name.
Runs the current buffers code or tests in a separate terminal window.
Supports both vim >= version 8.2 and neovim.
In your vimrc file;
Plug 'superDross/run-with-me.vim'
Execute :RunCode
to run your current windows code in a terminal.
You can also parse commandline arguments, for example if your script accepts a --file
argument you can execute the following :RunCode --file test.txt
.
Alternatively, you can map the command to a key. Place the below snippet into your vimrc to map the command to Leader 9:
nmap <leader>9 :RunCode<CR>
" run in vertical terminal window instead
nmap <leader>9 :RunCodeVert<CR>
Execute :RunToCursor
to run your current windows code from the start of the file to the line in which the cursor is sitting upon in a terminal.
You can also parse commandline arguments, for example if your script accepts a --file
argument you can execute the following :RunToCursor --file test.txt
.
Alternatively, you can map the command to a key. Place the below snippet into your vimrc to map the command to Leader 9:
nmap <leader>9 :RunToCursor<CR>
" run in vertical terminal window instead
nmap <leader>9 :RunToCursorVert<CR>
Execute :RunSelectedCode
to run code selected in visual mode.
You can also parse commandline arguments, for example if your script accepts a --file
argument you can execute the following :RunSelectedCode --file test.txt
.
Alternatively, you can map the command to a key. Place the below snippet into your vimrc to map the command to Leader 9:
nmap <leader>9 :RunSelectedCode<CR>
" run in vertical terminal window instead
nmap <leader>9 :RunSelectedCodeVert<CR>
Execute :RunTests
to run your testing command in the current directory.
Testing command to run will be dependant upon the current windows filetype. Setting g:default_testing_cmd
will run the same testing command regardless of filetype.
Mappings can be set like so:
nmap <leader>1 :RunTests<CR>
" run in vertical terminal window instead
nmap <leader>1 :RunTestsVert<CR>
Warning
The following test commands only work with Python tests.
Execute :RunModuleTests
to run only the tests in the current file.
Mappings can be set like so:
nmap <leader>1 :RunModuleTest<CR>
" run in vertical terminal window instead
nmap <leader>1 :RunModuleTestVert<CR>
Execute :RunNearestTest
to run only the test nearest above the cursor.
Mappings can be set like so:
nmap <leader>1 :RunNearestTest<CR>
" run in vertical terminal window instead
nmap <leader>1 :RunNearestTestVert<CR>
Change row size of the horizontal terminal output:
let g:runner_rowsize = 15
Overwrite base commands for a give language e.g. use python3.9 for all python script executions:
let g:runner_cmds['python'] = 'python3.9'
Overwrite base testing command for a given language e.g. use nosetests instead of pytest for python:
let g:testing_cmds['python'] = 'nosetests'
The below config will run the given test command regardless of filetype:
let g:default_testing_cmd = 'make test'