Skip to content

Instantly share code, notes, and snippets.

@flipjs
Forked from ddresselhaus/.vimrc
Created February 18, 2018 08:15
Show Gist options
  • Save flipjs/fcba1d9fe18cb41587be0de41c58a9a2 to your computer and use it in GitHub Desktop.
Save flipjs/fcba1d9fe18cb41587be0de41c58a9a2 to your computer and use it in GitHub Desktop.
run your tests in a separate tmux pane!
" when triggering this command, vim will grab your path and line location and pass it along
map <Leader>el :call RemoteSendCommand(TestLineCommand(expand("%:p"), line(".")))<CR>
" because I'm mostly writing Elixir and making heavy use of the REPL while writing my tests,
" I made a specifc command to user with Mix, the Elixir task utility
" But I'm sure you could get this to work with vim-test or something like that
function! TestLineCommand(path, line_number)
let cmd = join(["mix test --only", " line:", a:line_number, " ", a:path], "")
return cmd
endfunction
" Here, -t 6 specifies the pane you're sending the keys to
function! RemoteSendCommand(cmd)
execute "! tmux send-keys -t 6 \"" . a:cmd . "\" C-m"
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment