terminal.vim 639 B

12345678910111213141516171819202122232425
  1. " I am experimenting with different ways to use the terminal in nvim "
  2. " So far I hate all my options
  3. let s:term_buf = 0
  4. let s:term_win = 0
  5. function! Term_toggle(height)
  6. if win_gotoid(s:term_win)
  7. hide
  8. else
  9. botright new
  10. exec "resize " . a:height
  11. try
  12. exec "buffer " . s:term_buf
  13. catch
  14. call termopen($SHELL, {"detach": 0})
  15. let s:term_buf = bufnr("")
  16. endtry
  17. startinsert!
  18. let s:term_win = win_getid()
  19. endif
  20. endfunction
  21. nnoremap <silent> <M-t> :call Term_toggle(10)<cr>
  22. tnoremap <silent> <M-t> <C-\><C-n>:call Term_toggle(10)<cr>