startify.vim 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. " Plugin: https://github.com/mhinz/vim-startify
  2. " Description: Start screen displaying recently used stuff.
  3. " Maintainer: Marco Hinz <http://github.com/mhinz>
  4. " Version: 1.0
  5. if exists('g:autoloaded_startify') || &cp
  6. finish
  7. endif
  8. let g:autoloaded_startify = 1
  9. function! startify#get_session_names(lead, ...) abort
  10. return map(split(globpath(g:startify_session_dir, '*'.a:lead.'*', '\n')), 'fnamemodify(v:val, ":t")')
  11. endfunction
  12. function! startify#get_session_names_as_string(lead, ...) abort
  13. return join(map(split(globpath(g:startify_session_dir, '*'.a:lead.'*', '\n')), 'fnamemodify(v:val, ":t")'), "\n")
  14. endfunction
  15. function! startify#save_session(...) abort
  16. let spath = g:startify_session_dir .'/'. (exists('a:1')
  17. \ ? a:1
  18. \ : input('Save under this session name: ', '', 'custom,startify#get_session_names_as_string'))
  19. \ | redraw
  20. if !filereadable(spath)
  21. execute 'mksession '. spath | echo 'Session saved under: '. spath
  22. return
  23. endif
  24. echo 'Session already exists. Overwrite? [y/n]' | redraw
  25. if nr2char(getchar()) == 'y'
  26. execute 'mksession! '. spath | echo 'Session saved under: '. spath
  27. else
  28. echo 'Did NOT save the session!'
  29. endif
  30. endfunction
  31. function! startify#load_session(...) abort
  32. let spath = g:startify_session_dir .'/'. (exists('a:1')
  33. \ ? a:1
  34. \ : input('Load this session: ', '', 'custom,startify#get_session_names_as_string'))
  35. \ | redraw
  36. if filereadable(spath)
  37. execute 'source '. spath
  38. else
  39. echo 'No such file: '. spath
  40. endif
  41. endfunction
  42. " vim: et sw=2 sts=2