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. autocmd VimEnter * nested call s:genesis()
  12. if get(g:, 'startify_session_persistence')
  13. autocmd VimLeave * call s:extinction()
  14. endif
  15. autocmd QuickFixCmdPre *vimgrep* let g:startify_locked = 1
  16. autocmd QuickFixCmdPost *vimgrep* let g:startify_locked = 0
  17. augroup END
  18. function! s:update_oldfiles(file)
  19. if g:startify_locked || !exists('v:oldfiles')
  20. return
  21. endif
  22. let idx = index(v:oldfiles, a:file)
  23. if idx != -1
  24. call remove(v:oldfiles, idx)
  25. endif
  26. call insert(v:oldfiles, a:file, 0)
  27. endfunction
  28. function! s:genesis()
  29. if !argc() && (line2byte('$') == -1)
  30. if get(g:, 'startify_session_autoload') && filereadable('Session.vim')
  31. source Session.vim
  32. elseif !get(g:, 'startify_disable_at_vimenter')
  33. call startify#insane_in_the_membrane()
  34. endif
  35. endif
  36. if get(g:, 'startify_update_oldfiles')
  37. call map(v:oldfiles, 'fnamemodify(v:val, ":p")')
  38. autocmd startify BufNewFile,BufRead,BufFilePre *
  39. \ call s:update_oldfiles(expand('<afile>:p'))
  40. endif
  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>