Old version(s) of vim config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

132 lines
4.0 KiB

  1. " pathogen.vim - path option manipulation
  2. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  3. " Version: 1.2
  4. " Install in ~/.vim/autoload (or ~\vimfiles\autoload).
  5. "
  6. " API is documented below.
  7. if exists("g:loaded_pathogen") || &cp
  8. finish
  9. endif
  10. let g:loaded_pathogen = 1
  11. " Split a path into a list.
  12. function! pathogen#split(path) abort " {{{1
  13. if type(a:path) == type([]) | return a:path | endif
  14. let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
  15. return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
  16. endfunction " }}}1
  17. " Convert a list to a path.
  18. function! pathogen#join(...) abort " {{{1
  19. if type(a:1) == type(1) && a:1
  20. let i = 1
  21. let space = ' '
  22. else
  23. let i = 0
  24. let space = ''
  25. endif
  26. let path = ""
  27. while i < a:0
  28. if type(a:000[i]) == type([])
  29. let list = a:000[i]
  30. let j = 0
  31. while j < len(list)
  32. let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
  33. let path .= ',' . escaped
  34. let j += 1
  35. endwhile
  36. else
  37. let path .= "," . a:000[i]
  38. endif
  39. let i += 1
  40. endwhile
  41. return substitute(path,'^,','','')
  42. endfunction " }}}1
  43. " Convert a list to a path with escaped spaces for 'path', 'tag', etc.
  44. function! pathogen#legacyjoin(...) abort " {{{1
  45. return call('pathogen#join',[1] + a:000)
  46. endfunction " }}}1
  47. " Remove duplicates from a list.
  48. function! pathogen#uniq(list) abort " {{{1
  49. let i = 0
  50. let seen = {}
  51. while i < len(a:list)
  52. if has_key(seen,a:list[i])
  53. call remove(a:list,i)
  54. else
  55. let seen[a:list[i]] = 1
  56. let i += 1
  57. endif
  58. endwhile
  59. return a:list
  60. endfunction " }}}1
  61. " \ on Windows unless shellslash is set, / everywhere else.
  62. function! pathogen#separator() abort " {{{1
  63. return !exists("+shellslash") || &shellslash ? '/' : '\'
  64. endfunction " }}}1
  65. " Convenience wrapper around glob() which returns a list.
  66. function! pathogen#glob(pattern) abort " {{{1
  67. let files = split(glob(a:pattern),"\n")
  68. return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
  69. endfunction "}}}1
  70. " Like pathogen#glob(), only limit the results to directories.
  71. function! pathogen#glob_directories(pattern) abort " {{{1
  72. return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
  73. endfunction "}}}1
  74. " Prepend all subdirectories of path to the rtp, and append all after
  75. " directories in those subdirectories.
  76. function! pathogen#runtime_prepend_subdirectories(path) " {{{1
  77. let sep = pathogen#separator()
  78. let before = pathogen#glob_directories(a:path.sep."*[^~]")
  79. let after = pathogen#glob_directories(a:path.sep."*[^~]".sep."after")
  80. let rtp = pathogen#split(&rtp)
  81. let path = expand(a:path)
  82. call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
  83. let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
  84. return &rtp
  85. endfunction " }}}1
  86. " For each directory in rtp, check for a subdirectory named dir. If it
  87. " exists, add all subdirectories of that subdirectory to the rtp, immediately
  88. " after the original directory. If no argument is given, 'bundle' is used.
  89. " Repeated calls with the same arguments are ignored.
  90. function! pathogen#runtime_append_all_bundles(...) " {{{1
  91. let sep = pathogen#separator()
  92. let name = a:0 ? a:1 : 'bundle'
  93. if "\n".s:done_bundles =~# "\\M\n".name."\n"
  94. return ""
  95. endif
  96. let s:done_bundles .= name . "\n"
  97. let list = []
  98. for dir in pathogen#split(&rtp)
  99. if dir =~# '\<after$'
  100. let list += pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after') + [dir]
  101. else
  102. let list += [dir] + pathogen#glob_directories(dir.sep.name.sep.'*[^~]')
  103. endif
  104. endfor
  105. let &rtp = pathogen#join(pathogen#uniq(list))
  106. return 1
  107. endfunction
  108. let s:done_bundles = ''
  109. " }}}1
  110. " Invoke :helptags on all non-$VIM doc directories in runtimepath.
  111. function! pathogen#helptags() " {{{1
  112. for dir in pathogen#split(&rtp)
  113. if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
  114. helptags `=dir.'/doc'`
  115. endif
  116. endfor
  117. endfunction " }}}1
  118. " vim:set ft=vim ts=8 sw=2 sts=2: