1 " pathogen.vim - path option manipulation
2 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
5 " Install in ~/.vim/autoload (or ~\vimfiles\autoload).
7 " API is documented below.
9 if exists("g:loaded_pathogen") || &cp
12 let g:loaded_pathogen = 1
14 " Split a path into a list.
15 function! pathogen#split(path) abort " {{{1
16 if type(a:path) == type([]) | return a:path | endif
17 let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
18 return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
21 " Convert a list to a path.
22 function! pathogen#join(...) abort " {{{1
23 if type(a:1) == type(1) && a:1
32 if type(a:000[i]) == type([])
36 let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
37 let path .= ',' . escaped
41 let path .= "," . a:000[i]
45 return substitute(path,'^,','','')
48 " Convert a list to a path with escaped spaces for 'path', 'tag', etc.
49 function! pathogen#legacyjoin(...) abort " {{{1
50 return call('pathogen#join',[1] + a:000)
53 " Remove duplicates from a list.
54 function! pathogen#uniq(list) abort " {{{1
58 if has_key(seen,a:list[i])
61 let seen[a:list[i]] = 1
68 " Returns a hash indicating which filetype features are enabled.
69 function! pathogen#filetype() abort " {{{1
74 let result.detection = match(output,'detection:ON') >= 0
75 let result.indent = match(output,'indent:ON') >= 0
76 let result.plugin = match(output,'plugin:ON') >= 0
80 " \ on Windows unless shellslash is set, / everywhere else.
81 function! pathogen#separator() abort " {{{1
82 return !exists("+shellslash") || &shellslash ? '/' : '\'
85 " Convenience wrapper around glob() which returns a list.
86 function! pathogen#glob(pattern) abort " {{{1
87 let files = split(glob(a:pattern),"\n")
88 return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
91 " Like pathogen#glob(), only limit the results to directories.
92 function! pathogen#glob_directories(pattern) abort " {{{1
93 return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
96 " Prepend all subdirectories of path to the rtp, and append all after
97 " directories in those subdirectories.
98 function! pathogen#runtime_prepend_subdirectories(path) " {{{1
99 let sep = pathogen#separator()
100 let before = pathogen#glob_directories(a:path.sep."*[^~]")
101 let after = pathogen#glob_directories(a:path.sep."*[^~]".sep."after")
102 let rtp = pathogen#split(&rtp)
103 let path = expand(a:path)
104 call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
105 let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
109 " For each directory in rtp, check for a subdirectory named dir. If it
110 " exists, add all subdirectories of that subdirectory to the rtp, immediately
111 " after the original directory. If no argument is given, 'bundle' is used.
112 " Repeated calls with the same arguments are ignored.
113 function! pathogen#runtime_append_all_bundles(...) " {{{1
114 let sep = pathogen#separator()
115 let name = a:0 ? a:1 : 'bundle'
117 for dir in pathogen#split(&rtp)
118 if dir =~# '\<after$'
119 let list += pathogen#glob_directories(substitute(dir,'after$',name.sep.'*[^~]'.sep.'after','')) + [dir]
121 let list += [dir] + pathogen#glob_directories(dir.sep.name.sep.'*[^~]')
124 let &rtp = pathogen#join(pathogen#uniq(list))
130 " Invoke :helptags on all non-$VIM doc directories in runtimepath.
131 function! pathogen#helptags() " {{{1
132 for dir in pathogen#split(&rtp)
133 if dir[0 : strlen($VIM)-1] !=# $VIM && isdirectory(dir.'/doc') && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
134 helptags `=dir.'/doc'`
139 " vim:set ft=vim ts=8 sw=2 sts=2: