summaryrefslogtreecommitdiff
path: root/modules/terminal.vim
blob: 5dfe28c3b227acd318324aaa6eafec47fe407307 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
" I am experimenting with different ways to use the terminal in nvim "
" So far I hate all my options

let s:term_buf = 0
let s:term_win = 0

function! Term_toggle(height)
    if win_gotoid(s:term_win)
        hide
    else
        botright new
        exec "resize " . a:height
        try
            exec "buffer " . s:term_buf
        catch
            call termopen($SHELL, {"detach": 0})
            let s:term_buf = bufnr("")
        endtry
        startinsert!
        let s:term_win = win_getid()
    endif
endfunction

nnoremap <silent> <M-t> :call Term_toggle(10)<cr>
tnoremap <silent> <M-t> <C-\><C-n>:call Term_toggle(10)<cr>