startify.vim 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. if !get(g:, 'startify_disable_at_vimenter')
  12. autocmd VimEnter * nested call s:genesis()
  13. endif
  14. if get(g:, 'startify_session_persistence')
  15. autocmd VimLeave * call s:extinction()
  16. endif
  17. autocmd QuickFixCmdPre *vimgrep* let g:startify_locked = 1
  18. autocmd QuickFixCmdPost *vimgrep* let g:startify_locked = 0
  19. augroup END
  20. function! s:update_oldfiles(file)
  21. if g:startify_locked || !exists('v:oldfiles')
  22. return
  23. endif
  24. let idx = index(v:oldfiles, a:file)
  25. if idx != -1
  26. call remove(v:oldfiles, idx)
  27. endif
  28. call insert(v:oldfiles, a:file, 0)
  29. endfunction
  30. function! s:genesis()
  31. if !argc() && (line2byte('$') == -1)
  32. if get(g:, 'startify_session_autoload') && filereadable('Session.vim')
  33. source Session.vim
  34. else
  35. call startify#insane_in_the_membrane()
  36. endif
  37. endif
  38. if get(g:, 'startify_update_oldfiles')
  39. call map(v:oldfiles, 'fnamemodify(v:val, ":p")')
  40. autocmd startify BufNewFile,BufRead,BufFilePre *
  41. \ call s:update_oldfiles(expand('<afile>:p'))
  42. endif
  43. autocmd! startify VimEnter
  44. endfunction
  45. function! s:extinction()
  46. if exists('v:this_session') && filewritable(v:this_session)
  47. call startify#session_write(fnameescape(v:this_session))
  48. endif
  49. endfunction
  50. command! -nargs=? -bar -complete=customlist,startify#session_list SSave call startify#session_save(<f-args>)
  51. command! -nargs=? -bar -complete=customlist,startify#session_list SLoad call startify#session_load(<f-args>)
  52. command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
  53. command! -nargs=0 -bar SClose call startify#session_close()
  54. command! -nargs=0 -bar Startify enew | call startify#insane_in_the_membrane()
  55. command! -nargs=0 -bar StartifyDebug call startify#debug()
  56. nnoremap <silent><plug>(startify-open-buffers) :<c-u>call startify#open_buffers()<cr>