startify.vim 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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') && (!has('nvim') || has('nvim-0.3.5'))
  11. " Only for Nvim v0.3.5+: https://github.com/neovim/neovim/issues/9885
  12. set shortmess+=I
  13. endif
  14. augroup startify
  15. autocmd VimEnter * nested call s:on_vimenter()
  16. autocmd VimLeavePre * nested call s:on_vimleavepre()
  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:on_vimenter()
  31. if !argc() && line('$') == 1 && getline('.') == ''
  32. if get(g:, 'startify_session_autoload') && filereadable('Session.vim')
  33. source Session.vim
  34. elseif !get(g:, 'startify_disable_at_vimenter')
  35. call startify#insane_in_the_membrane(1)
  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:on_vimleavepre()
  46. if get(g:, 'startify_session_persistence')
  47. \ && exists('v:this_session')
  48. \ && filewritable(v:this_session)
  49. call startify#session_write(fnameescape(v:this_session))
  50. endif
  51. endfunction
  52. command! -nargs=? -bar -bang -complete=customlist,startify#session_list SLoad call startify#session_load(<bang>0, <f-args>)
  53. command! -nargs=? -bar -bang -complete=customlist,startify#session_list SSave call startify#session_save(<bang>0, <f-args>)
  54. command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
  55. command! -nargs=0 -bar SClose call startify#session_close()
  56. command! -nargs=0 -bar Startify call startify#insane_in_the_membrane(0)
  57. command! -nargs=0 -bar StartifyDebug call startify#debug()
  58. nnoremap <silent><plug>(startify-open-buffers) :<c-u>call startify#open_buffers()<cr>