[vim] Convenient terminal behaviour

Alt+T to toggle a 12-row high split at bottom
Bo Jeanes 2020-08-24 14:31:21 +10:00
parent 0d6565f2e7
commit 12b8e40957
1 changed files with 28 additions and 0 deletions

View File

@ -549,6 +549,34 @@ nnoremap zS :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:v
" https://github.com/phoenixframework/phoenix/issues/1165#issuecomment-437130681
let $MIX_ENV='test'
" Terminal Function
" Courtesy of https://www.reddit.com/r/vim/comments/8n5bzs/using_neovim_is_there_a_way_to_display_a_terminal/dzt3fix
let g:term_buf = 0
let g:term_win = 0
function! TermToggle(height)
if win_gotoid(g:term_win)
hide
else
botright new
exec "resize " . a:height
try
exec "buffer " . g:term_buf
catch
call termopen($SHELL, {"detach": 0})
let g:term_buf = bufnr("")
set nonumber
set norelativenumber
set signcolumn=no
endtry
startinsert!
let g:term_win = win_getid()
endif
endfunction
nnoremap <silent> <leader>te :call TermToggle(12)<CR>
nnoremap <A-t> :call TermToggle(12)<CR>
inoremap <A-t> <Esc>:call TermToggle(12)<CR>
tnoremap <A-t> <C-\><C-n>:call TermToggle(12)<CR>
if filereadable(expand('~/.vimrc.local'))
source ~/.vimrc.local
endif