mhinz / vim-startify

:link: The fancy start screen for Vim.
MIT License
5.3k stars 186 forks source link

Startify leaving an empty buffer and split after closing built-in terminal #537

Closed PR0BLEMCH1LD closed 1 year ago

PR0BLEMCH1LD commented 2 years ago

Steps to recreate

  1. Startify screen
  2. :term
  3. exit the shell

Screenshots image

Happens in vanilla vim as well image

PR0BLEMCH1LD commented 2 years ago

I ended up kinda-fixing it with a custom event and closing the empty buffer:

let s:terminal_opened = 0
function! s:trigger()
    if empty(filter(range(1, bufnr('$')), 'buflisted(v:val) && "terminal" ==? getbufvar(v:val, "&buftype")'))
        if s:terminal_opened == 1
            let s:terminal_opened = 0
            if exists('#User#TerminalClose')
                execute 'doautocmd User TerminalClose'
            endif
        endif
    endif
endfunction
augroup startify_fix
    autocmd!
    autocmd TerminalOpen * let s:terminal_opened = 1
    autocmd BufEnter * call s:trigger()
    autocmd User TerminalClose if line2byte('.') == -1 && winnr('$') > 1 && empty(bufname()) | execute winnr('#') ' wincmd w' | execute 'Bdelete! nameless' | endif
augroup END

I only tested it slightly so let me know if you have the same issue and found bugs in the solution above.

PR0BLEMCH1LD commented 1 year ago

Right so I found out that this was covered in the FAQs but with vim-plug.