diff --git a/vim/formatting.vim b/vim/formatting.vim index a3df37e..b15a4fd 100644 --- a/vim/formatting.vim +++ b/vim/formatting.vim @@ -43,7 +43,7 @@ augroup end " -- Format Override Layers ------------------------------ {{{ -source $VIM_DIR/rd_formatting.vim +source $VIM_DIR/rentdynamics.vim " }}} diff --git a/vim/global_sets.vim b/vim/options.vim similarity index 100% rename from vim/global_sets.vim rename to vim/options.vim diff --git a/vim/rc.vim b/vim/rc.vim index b3445a1..d45bf79 100644 --- a/vim/rc.vim +++ b/vim/rc.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 nnoremap _ :m -2 - " \t for rerun last 'test' command: - nnoremap t q:?test + " \t for rerun last 'vimtest' command: + nnoremap t q:?vimtest " \b for git blame nnoremap b :set termwinsize=15*0:execute "terminal git blame -L " .eval(line(".")-5) . ",+10 %":set termwinsize& diff --git a/vim/rd_formatting.vim b/vim/rentdynamics.vim similarity index 100% rename from vim/rd_formatting.vim rename to vim/rentdynamics.vim diff --git a/vim/testing.vim b/vim/testing.vim new file mode 100644 index 0000000..a333df1 --- /dev/null +++ b/vim/testing.vim @@ -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