aboutsummaryrefslogtreecommitdiff
path: root/vim/.vim/autoload/dyamon/terminal.vim
blob: ba4807a355ca836c9aed4d46a46e0502eb810dee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
" Autoload function for the internal terminal emulator.
" Last Changed: 2021-07-28
" Author: Federico Igne <git@federicoigne.com>
" License: This file is placed in the public domain.

"" Toggle a (tab-specific) terminal scratchpad.
"
" This is similar to terminal consoles available in other editors. This
" still allows (and does not interfere with) other terminal windows open
" for other porpuses.
function! dyamon#terminal#toggle() abort
    if exists("t:terminal_scratchpad") && bufexists(t:terminal_scratchpad)
        " This could be simplified if `switchbuf` contains "useopen"
        if bufwinnr(t:terminal_scratchpad) == -1
            echomsg "here"
            exec "botright sbuffer" t:terminal_scratchpad
        else
            exec bufwinnr(t:terminal_scratchpad) . "hide"
        endif
    else
      botright terminal
      let t:terminal_scratchpad = bufnr('%')
    endif
endfunction