Skip to content

superDross/run-with-me.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Run With Me

A simple script runner plugin with a pompous name.

Runs the current buffers code or tests in a separate terminal window.

Installation

Supports both vim >= version 8.2 and neovim.

In your vimrc file;

Plug 'superDross/run-with-me.vim'

Usage

Script Execution

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>

runcode

Execute to Cursor

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>

Visual Execution

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>

runselectedcode

Tests Execution

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>

runtests

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>

runmoduletests

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>

runnearesttest

Configuration

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'

About

Runs current buffer code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published