Changed naming convention; added testing functions
This commit is contained in:
parent
dce98ac8a1
commit
21ee3db169
@ -43,7 +43,7 @@ augroup end
|
||||
|
||||
|
||||
" -- Format Override Layers ------------------------------ {{{
|
||||
source $VIM_DIR/rd_formatting.vim
|
||||
source $VIM_DIR/rentdynamics.vim
|
||||
" }}}
|
||||
|
||||
|
||||
|
@ -6,7 +6,8 @@ if isdirectory(expand("$HOME/.vim/bundle/Vundle.vim"))
|
||||
source $VIM_DIR/vundle.vim
|
||||
endif
|
||||
|
||||
source $VIM_DIR/global_sets.vim
|
||||
source $VIM_DIR/options.vim
|
||||
source $VIM_DIR/testing.vim
|
||||
source $VIM_DIR/formatting.vim
|
||||
source $VIM_DIR/abbreviations.vim
|
||||
source $VIM_DIR/navigation.vim
|
||||
@ -42,8 +43,8 @@ augroup personal_bindings
|
||||
nnoremap - :m +1 <CR>
|
||||
nnoremap _ :m -2 <CR>
|
||||
|
||||
" \t for rerun last 'test' command:
|
||||
nnoremap <Leader>t q:?test<CR><CR>
|
||||
" \t for rerun last 'vimtest' command:
|
||||
nnoremap <Leader>t q:?vimtest<CR><CR>
|
||||
|
||||
" \b for git blame
|
||||
nnoremap <Leader>b :set termwinsize=15*0<BAR>:execute "terminal git blame -L " .eval(line(".")-5) . ",+10 %"<BAR>:set termwinsize&<CR>
|
||||
|
86
vim/testing.vim
Normal file
86
vim/testing.vim
Normal file
@ -0,0 +1,86 @@
|
||||
|
||||
let tmuxTestSessionName = "test"
|
||||
let defaultTmuxPaneId = g:tmuxTestSessionName . ":0.0"
|
||||
|
||||
function InitializeTmuxTestSession()
|
||||
silent execute '!tmux new -ds ' . g:tmuxTestSessionName . ' -c $HOME >/dev/null 2>&1'
|
||||
endfunction
|
||||
|
||||
|
||||
" ===================================================================
|
||||
" === test formats ==================================================
|
||||
" ===================================================================
|
||||
|
||||
function TmuxTest(shellCommand, paneId = g:defaultTmuxPaneId)
|
||||
if a:paneId == g:defaultTmuxPaneId
|
||||
call InitializeTmuxTestSession()
|
||||
endif
|
||||
|
||||
call system("tmux send-keys -t " . a:paneId . " '" . a:shellCommand . "' Enter")
|
||||
endfunction
|
||||
|
||||
function SplitPaneTest(shellCommand, verticalSplit = 0)
|
||||
if a:verticalSplit
|
||||
execute "vertical terminal " . a:shellCommand
|
||||
else
|
||||
execute "terminal " . a:shellCommand
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function ShellEscapedTest(shellCommand)
|
||||
execute "!" . a:shellCommand
|
||||
endfunction
|
||||
|
||||
|
||||
" ===================================================================
|
||||
" === python-django =================================================
|
||||
" ===================================================================
|
||||
|
||||
function DjangoTmuxTest(paneId = g:defaultTmuxPaneId)
|
||||
let l:command = "cd " . getcwd() . "; " . GetDjangoTestCommand()
|
||||
call TmuxTest(l:command, a:paneId)
|
||||
endfunction
|
||||
|
||||
function DjangoSplitTest(verticalSplit = 0)
|
||||
let l:command = GetDjangoTestCommand()
|
||||
call SplitPaneTest(l:command, a:verticalSplit)
|
||||
endfunction
|
||||
|
||||
function DjangoTest()
|
||||
let l:command = GetDjangoTestCommand()
|
||||
call ShellEscapedTest(l:command)
|
||||
endfunction
|
||||
|
||||
|
||||
function GetDjangoTestCommand()
|
||||
return GetDjangoManagePy() . " test --keepdb"
|
||||
endfunction
|
||||
|
||||
function GetDjangoManagePy()
|
||||
return substitute(expand(getcwd()), "/code/.*", "/code/manage.py", "")
|
||||
endfunction
|
||||
|
||||
|
||||
" ===================================================================
|
||||
" === npm ===========================================================
|
||||
" ===================================================================
|
||||
|
||||
function NpmTmuxTest(paneId = g:defaultTmuxPaneId)
|
||||
let l:command = "cd " . getcwd() . "; " . GetNpmTestCommand()
|
||||
call TmuxTest(l:command, a:paneId)
|
||||
endfunction
|
||||
|
||||
function NpmSplitTest(verticalSplit = 0)
|
||||
let l:command = GetNpmTestCommand()
|
||||
call SplitPaneTest(l:command, a:verticalSplit)
|
||||
endfunction
|
||||
|
||||
function NpmTest()
|
||||
let l:command = GetNpmTestCommand()
|
||||
call ShellEscapedTest(l:command)
|
||||
endfunction
|
||||
|
||||
|
||||
function GetNpmTestCommand()
|
||||
return "npm test"
|
||||
endfunction
|
Loading…
Reference in New Issue
Block a user