startify.vim 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. call map(v:oldfiles, 'fnamemodify(v:val, ":p")')
  39. autocmd startify BufNewFile,BufRead,BufFilePre *
  40. \ call s:update_oldfiles(expand('<afile>:p'))
  41. autocmd! startify VimEnter
  42. endfunction
  43. function! s:extinction()
  44. if exists('v:this_session') && 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 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>