mhinz / vim-startify

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

Option to Quit Startify But Not Vim Even if there Are No Unlisted Buffers #514

Open jeetsukumaran opened 2 years ago

jeetsukumaran commented 2 years ago

Hi,

For my workflow I would like to toggle startify on/off on demand.

I can sort of get this with the following:

let g:startify_disable_at_vimenter = 1
augroup rcstartify
    autocmd User Startified nmap <buffer> <F12> q
augroup END
nnoremap <F12> <cmd>Startify<CR>

It works as I would like it, except if I have a blank (No Name) buffer. In that case, by design Startify quits Vim.

Would it be possible to support a way to close/clean-up the Startify buffer but not quit Vim? Binding that to a key once I'm in a startify buffer will provide the workflow above.

If there is interest in supporting this option, but no time to implement this, I can submit a PR?

Basically, just one line needs to be changed in https://github.com/mhinz/vim-startify/blob/81e36c352a8deea54df5ec1e2f4348685569bed2/autoload/startify.vim#L1007-L1017. For e.g.:

function! s:close() abort
  if len(filter(range(0, bufnr('$')), 'buflisted(v:val)')) - &buflisted
    if bufloaded(bufnr('#')) && bufnr('#') != bufnr('%')
      buffer #
    else
      bnext
    endif
  elseif get(g:, "startify_quit_on_no_listed_buffers", 1) 
    quit
  endif
endfunction