annotate vendor/vim-autoload/pathogen.vim @ 597:fb8bb030a573

Merge
author nanaya <me@myconan.net>
date Wed, 22 Mar 2017 00:29:46 +0900
parents 0e72765944d4
children b305f2ce5f88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
1 " pathogen.vim - path option manipulation
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
2 " Maintainer: Tim Pope <http://tpo.pe/>
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
3 " Version: 2.4
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
4
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
5 " Install in ~/.vim/autoload (or ~\vimfiles\autoload).
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
6 "
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
7 " For management of individually installed plugins in ~/.vim/bundle (or
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
8 " ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
9 " .vimrc is the only other setup necessary.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
10 "
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
11 " The API is documented inline below.
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
12
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
13 if exists("g:loaded_pathogen") || &cp
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
14 finish
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
15 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
16 let g:loaded_pathogen = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
17
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
18 " Point of entry for basic default usage. Give a relative path to invoke
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
19 " pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
20 " pathogen#surround(). Curly braces are expanded with pathogen#expand():
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
21 " "bundle/{}" finds all subdirectories inside "bundle" inside all directories
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
22 " in the runtime path.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
23 function! pathogen#infect(...) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
24 for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}']
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
25 if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
26 call pathogen#surround(path)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
27 elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
28 call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
29 call pathogen#surround(path . '/{}')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
30 elseif path =~# '[{}*]'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
31 call pathogen#interpose(path)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
32 else
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
33 call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
34 call pathogen#interpose(path . '/{}')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
35 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
36 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
37 call pathogen#cycle_filetype()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
38 if pathogen#is_disabled($MYVIMRC)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
39 return 'finish'
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
40 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
41 return ''
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
42 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
43
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
44 " Split a path into a list.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
45 function! pathogen#split(path) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
46 if type(a:path) == type([]) | return a:path | endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
47 if empty(a:path) | return [] | endif
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
48 let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
49 return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
50 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
51
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
52 " Convert a list to a path.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
53 function! pathogen#join(...) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
54 if type(a:1) == type(1) && a:1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
55 let i = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
56 let space = ' '
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
57 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
58 let i = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
59 let space = ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
60 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
61 let path = ""
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
62 while i < a:0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
63 if type(a:000[i]) == type([])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
64 let list = a:000[i]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
65 let j = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
66 while j < len(list)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
67 let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
68 let path .= ',' . escaped
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
69 let j += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
70 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
71 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
72 let path .= "," . a:000[i]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
73 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
74 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
75 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
76 return substitute(path,'^,','','')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
77 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
78
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
79 " Convert a list to a path with escaped spaces for 'path', 'tag', etc.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
80 function! pathogen#legacyjoin(...) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
81 return call('pathogen#join',[1] + a:000)
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
82 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
83
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
84 " Turn filetype detection off and back on again if it was already enabled.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
85 function! pathogen#cycle_filetype() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
86 if exists('g:did_load_filetypes')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
87 filetype off
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
88 filetype on
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
89 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
90 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
91
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
92 " Check if a bundle is disabled. A bundle is considered disabled if its
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
93 " basename or full name is included in the list g:pathogen_blacklist or the
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
94 " comma delimited environment variable $VIMBLACKLIST.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
95 function! pathogen#is_disabled(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
96 if a:path =~# '\~$'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
97 return 1
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
98 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
99 let sep = pathogen#slash()
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
100 let blacklist =
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
101 \ get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) +
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
102 \ pathogen#split($VIMBLACKLIST)
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
103 if !empty(blacklist)
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
104 call map(blacklist, 'substitute(v:val, "[\\/]$", "", "")')
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
105 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
106 return index(blacklist, fnamemodify(a:path, ':t')) != -1 || index(blacklist, a:path) != -1
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
107 endfunction
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
108
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
109 " Prepend the given directory to the runtime path and append its corresponding
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
110 " after directory. Curly braces are expanded with pathogen#expand().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
111 function! pathogen#surround(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
112 let sep = pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
113 let rtp = pathogen#split(&rtp)
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
114 let path = fnamemodify(a:path, ':s?[\\/]\=$??')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
115 let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
116 let after = filter(reverse(pathogen#expand(path, sep.'after')), '!pathogen#is_disabled(v:val[0:-7])')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
117 call filter(rtp, 'index(before + after, v:val) == -1')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
118 let &rtp = pathogen#join(before, rtp, after)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
119 return &rtp
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
120 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
121
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
122 " For each directory in the runtime path, add a second entry with the given
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
123 " argument appended. Curly braces are expanded with pathogen#expand().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
124 function! pathogen#interpose(name) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
125 let sep = pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
126 let name = a:name
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
127 if has_key(s:done_bundles, name)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
128 return ""
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
129 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
130 let s:done_bundles[name] = 1
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
131 let list = []
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
132 for dir in pathogen#split(&rtp)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
133 if dir =~# '\<after$'
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
134 let list += reverse(filter(pathogen#expand(dir[0:-6].name, sep.'after'), '!pathogen#is_disabled(v:val[0:-7])')) + [dir]
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
135 else
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
136 let list += [dir] + filter(pathogen#expand(dir.sep.name), '!pathogen#is_disabled(v:val)')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
137 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
138 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
139 let &rtp = pathogen#join(pathogen#uniq(list))
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
140 return 1
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
141 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
142
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
143 let s:done_bundles = {}
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
144
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
145 " Invoke :helptags on all non-$VIM doc directories in runtimepath.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
146 function! pathogen#helptags() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
147 let sep = pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
148 for glob in pathogen#split(&rtp)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
149 for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
150 if (dir)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir) == 2 && !empty(split(glob(dir.'*.txt'))) && (!filereadable(dir.'tags') || filewritable(dir.'tags'))
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
151 silent! execute 'helptags' pathogen#fnameescape(dir)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
152 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
153 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
154 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
155 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
156
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
157 command! -bar Helptags :call pathogen#helptags()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
158
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
159 " Execute the given command. This is basically a backdoor for --remote-expr.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
160 function! pathogen#execute(...) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
161 for command in a:000
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
162 execute command
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
163 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
164 return ''
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
165 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
166
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
167 " Section: Unofficial
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
168
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
169 function! pathogen#is_absolute(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
170 return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
171 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
172
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
173 " Given a string, returns all possible permutations of comma delimited braced
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
174 " alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
175 " ['/a/c', '/a/d', '/b/c', '/b/d']. Empty braces are treated as a wildcard
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
176 " and globbed. Actual globs are preserved.
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
177 function! pathogen#expand(pattern, ...) abort
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
178 let after = a:0 ? a:1 : ''
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
179 if a:pattern =~# '{[^{}]\+}'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
180 let [pre, pat, post] = split(substitute(a:pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
181 let found = map(split(pat, ',', 1), 'pre.v:val.post')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
182 let results = []
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
183 for pattern in found
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
184 call extend(results, pathogen#expand(pattern))
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
185 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
186 elseif a:pattern =~# '{}'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
187 let pat = matchstr(a:pattern, '^.*{}[^*]*\%($\|[\\/]\)')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
188 let post = a:pattern[strlen(pat) : -1]
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
189 let results = map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
190 else
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
191 let results = [a:pattern]
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
192 endif
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
193 let vf = pathogen#slash() . 'vimfiles'
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
194 call map(results, 'v:val =~# "\\*" ? v:val.after : isdirectory(v:val.vf.after) ? v:val.vf.after : isdirectory(v:val.after) ? v:val.after : ""')
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
195 return filter(results, '!empty(v:val)')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
196 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
197
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
198 " \ on Windows unless shellslash is set, / everywhere else.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
199 function! pathogen#slash() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
200 return !exists("+shellslash") || &shellslash ? '/' : '\'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
201 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
202
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
203 function! pathogen#separator() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
204 return pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
205 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
206
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
207 " Convenience wrapper around glob() which returns a list.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
208 function! pathogen#glob(pattern) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
209 let files = split(glob(a:pattern),"\n")
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
210 return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
211 endfunction
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
212
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
213 " Like pathogen#glob(), only limit the results to directories.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
214 function! pathogen#glob_directories(pattern) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
215 return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
216 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
217
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
218 " Remove duplicates from a list.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
219 function! pathogen#uniq(list) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
220 let i = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
221 let seen = {}
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
222 while i < len(a:list)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
223 if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
224 call remove(a:list,i)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
225 elseif a:list[i] ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
226 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
227 let empty = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
228 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
229 let seen[a:list[i]] = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
230 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
231 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
232 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
233 return a:list
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
234 endfunction
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
235
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
236 " Backport of fnameescape().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
237 function! pathogen#fnameescape(string) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
238 if exists('*fnameescape')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
239 return fnameescape(a:string)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
240 elseif a:string ==# '-'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
241 return '\-'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
242 else
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
243 return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
244 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
245 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
246
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
247 " Like findfile(), but hardcoded to use the runtimepath.
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
248 function! pathogen#runtime_findfile(file,count) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
249 let rtp = pathogen#join(1,pathogen#split(&rtp))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
250 let file = findfile(a:file,rtp,a:count)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
251 if file ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
252 return ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
253 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
254 return fnamemodify(file,':p')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
255 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
256 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
257
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
258 " Section: Deprecated
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
259
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
260 function! s:warn(msg) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
261 echohl WarningMsg
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
262 echomsg a:msg
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
263 echohl NONE
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
264 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
265
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
266 " Prepend all subdirectories of path to the rtp, and append all 'after'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
267 " directories in those subdirectories. Deprecated.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
268 function! pathogen#runtime_prepend_subdirectories(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
269 call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
270 return pathogen#surround(a:path . pathogen#slash() . '{}')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
271 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
272
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
273 function! pathogen#incubate(...) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
274 let name = a:0 ? a:1 : 'bundle/{}'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
275 call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
276 return pathogen#interpose(name)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
277 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
278
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
279 " Deprecated alias for pathogen#interpose().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
280 function! pathogen#runtime_append_all_bundles(...) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
281 if a:0
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
282 call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')')
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
283 else
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
284 call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()')
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
285 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
286 return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
287 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
288
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
289 " vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':