startify.vim 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. " vim: et sw=2 sts=2
  2. " Plugin: https://github.com/mhinz/vim-startify
  3. " Description: A fancy start screen for Vim.
  4. " Maintainer: Marco Hinz <http://github.com/mhinz>
  5. if exists('g:loaded_startify') || &cp
  6. finish
  7. endif
  8. let g:loaded_startify = 1
  9. let g:startify_locked = 0
  10. augroup startify
  11. autocmd VimEnter * nested call s:genesis()
  12. autocmd VimLeave * call s:extinction()
  13. autocmd QuickFixCmdPre *vimgrep* let g:startify_locked = 1
  14. autocmd QuickFixCmdPost *vimgrep* let g:startify_locked = 0
  15. augroup END
  16. function! s:update_oldfiles(file)
  17. if g:startify_locked || !exists('v:oldfiles')
  18. return
  19. endif
  20. let idx = index(v:oldfiles, a:file)
  21. if idx != -1
  22. call remove(v:oldfiles, idx)
  23. endif
  24. call insert(v:oldfiles, a:file, 0)
  25. endfunction
  26. function! s:genesis()
  27. if !argc() && (line2byte('$') == -1)
  28. if get(g:, 'startify_session_autoload') && filereadable('Session.vim')
  29. source Session.vim
  30. elseif !get(g:, 'startify_disable_at_vimenter')
  31. call startify#insane_in_the_membrane()
  32. endif
  33. endif
  34. if get(g:, 'startify_update_oldfiles')
  35. call map(v:oldfiles, 'fnamemodify(v:val, ":p")')
  36. autocmd startify BufNewFile,BufRead,BufFilePre *
  37. \ call s:update_oldfiles(expand('<afile>:p'))
  38. endif
  39. autocmd! startify VimEnter
  40. endfunction
  41. function! s:extinction()
  42. if get(g:, 'startify_session_persistence')
  43. \ && exists('v:this_session')
  44. \ && filewritable(v:this_session)
  45. call startify#session_write(fnameescape(v:this_session))
  46. endif
  47. endfunction
  48. command! -nargs=? -bar -complete=customlist,startify#session_list SSave call startify#session_save(<f-args>)
  49. command! -nargs=? -bar -complete=customlist,startify#session_list SLoad call startify#session_load(<f-args>)
  50. command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
  51. command! -nargs=0 -bar SClose call startify#session_close()
  52. command! -nargs=0 -bar Startify noautocmd enew | call startify#insane_in_the_membrane()
  53. command! -nargs=0 -bar StartifyDebug call startify#debug()
  54. nnoremap <silent><plug>(startify-open-buffers) :<c-u>call startify#open_buffers()<cr>