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