feat(vim): add term script back in from the history
This is from the dotfiles a long time ago, its still in vimscript, don't think I will ever convert it over to lua. This also disables base16 shell when the terminal is running inside vim like I am doing with emacs.
This commit is contained in:
parent
490cd76629
commit
3d387e4552
2 changed files with 74 additions and 6 deletions
70
site-modules/core/files/vim/plugin/term.vim
Normal file
70
site-modules/core/files/vim/plugin/term.vim
Normal file
|
|
@ -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 <buffer> <Esc> <C-\><C-n>
|
||||
tnoremap <buffer> <expr> <C-v> '<C-\><C-N>pi'
|
||||
tnoremap <buffer> <c-h> <C-\><C-n><C-w>h
|
||||
tnoremap <buffer> <c-j> <C-\><C-n><C-w>j
|
||||
tnoremap <buffer> <c-k> <C-\><C-n><C-w>k
|
||||
tnoremap <buffer> <c-l> <C-\><C-n><C-w>l
|
||||
|
||||
if exists('g:split_term_default_shell')
|
||||
exe 'set shell =' . prevShell
|
||||
endif
|
||||
endf
|
||||
|
||||
command! -count -nargs=* Term call s:openTerm(<q-args>)
|
||||
command! -count -nargs=* VTerm call s:openSplitTerm(<q-args>, <count>, 1)
|
||||
command! -count -nargs=* HTerm call s:openSplitTerm(<q-args>, <count>, 0)
|
||||
command! -nargs=* TTerm call s:openTabTerm(<q-args>)
|
||||
|
|
@ -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
|
||||
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in a new issue