diff --git a/site-modules/core/files/vim/plugin/term.vim b/site-modules/core/files/vim/plugin/term.vim new file mode 100644 index 0000000..de3eab2 --- /dev/null +++ b/site-modules/core/files/vim/plugin/term.vim @@ -0,0 +1,70 @@ +" +" All of the good bits from `split_term` +" https://github.com/vimlab/split-term.vim/blob/master/plugin/split-term.vim +" + +let s:force_vertical = exists('g:split_term_vertical') ? 1 : 0 +let s:default_shell = exists('g:split_term_default_shell') ? g:split_term_default_shell : 0 + +au BufEnter * if &buftype == 'terminal' | :startinsert | endif + +" Opens up a new buffer, either vertical or horizontal. Count can be used to +" specify the number of visible columns or rows. +fun! s:openBuffer(count, vertical) + let cmd = a:vertical ? 'vnew' : 'new' + let cmd = a:count ? a:count . cmd : cmd + exe cmd +endf + +" Opens a new terminal buffer, but instead of doing so using 'enew' (same +" window), it uses :vnew and :new instead. Usually, I want to open a new +" terminal and not replace my current buffer. +fun! s:openSplitTerm(args, count, vertical) + let direction = s:force_vertical ? 1 : a:vertical + + call s:openBuffer(a:count, direction) + call s:openTerm(a:args) +endf + +" Opens a new terminal buffer, but instead of doing so using split buffer, it +" uses :tabnew instead. +fun! s:openTabTerm(args) + exe 'tabnew' + call s:openTerm(a:args) +endf + +" Open a new terminal in the active buffer, while defining default mappings +" for this plugin. +fun! s:openTerm(args) + let prevShell = &shell + if exists('g:split_term_default_shell') + exe 'set shell =' . s:default_shell + endif + + exe 'terminal' a:args + + setlocal norelativenumber + setlocal nonumber + setlocal signcolumn=no + + exe 'startinsert' + + " + " Add teminal mappings + " + tnoremap + tnoremap 'pi' + tnoremap h + tnoremap j + tnoremap k + tnoremap l + + if exists('g:split_term_default_shell') + exe 'set shell =' . prevShell + endif +endf + +command! -count -nargs=* Term call s:openTerm() +command! -count -nargs=* VTerm call s:openSplitTerm(, , 1) +command! -count -nargs=* HTerm call s:openSplitTerm(, , 0) +command! -nargs=* TTerm call s:openTabTerm() diff --git a/site-modules/core/files/zshrc b/site-modules/core/files/zshrc index 1a65ceb..da3ccd5 100644 --- a/site-modules/core/files/zshrc +++ b/site-modules/core/files/zshrc @@ -45,13 +45,11 @@ printf '\033[5 q' # # Configure base16 shell for colors if the terminal is not running inside of -# emacs +# emacs or vim # -if [[ -z $INSIDE_EMACS ]] && [[ -z "$SSH_TTY" ]] ; then - BASE16_SHELL="$HOME/.config/base16-shell/" - [ -n "$PS1" ] && \ - [ -s "$BASE16_SHELL/profile_helper.sh" ] && \ - eval "$("$BASE16_SHELL/profile_helper.sh")" +if [[ -z "$VIM" ]] && [[ -z "$INSIDE_EMACS" ]] && [[ -z "$SSH_TTY" ]] ; then + BASE16_SHELL="$HOME/.config/base16-shell/" + [ -s "$BASE16_SHELL/profile_helper.sh" ] && eval "$("$BASE16_SHELL/profile_helper.sh")" fi #