Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jeetsukumaran opened this issue Dec 8, 2021 · 0 comments

Comments

@jeetsukumaran
Copy link

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

function! s:close() abort
if len(filter(range(0, bufnr('$')), 'buflisted(v:val)')) - &buflisted
if bufloaded(bufnr('#')) && bufnr('#') != bufnr('%')
buffer #
else
bnext
endif
else
quit
endif
endfunction
. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant