annotate rc/vim-autoload-pathogen @ 529:de3ff51840a3

Skip clipboard loading for speedup in current setup. - putty - opensuse - no X
author edogawaconan <me@myconan.net>
date Thu, 16 Oct 2014 21:47:36 +0900
parents 7394b88bf1c6
children ea4bc5799d71
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/>
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
3 " Version: 2.0
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
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
8 " ~\vimfiles\bundle), adding `call pathogen#infect()` to the top of your
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 "
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
11 " The API is documented inline below. For maximum ease of reading,
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
12 " :set foldmethod=marker
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
13
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
14 if exists("g:loaded_pathogen") || &cp
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
15 finish
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
16 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
17 let g:loaded_pathogen = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
18
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
19 " Point of entry for basic default usage. Give a directory name to invoke
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
20 " pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
21 " to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
22 " pathogen#cycle_filetype() is invoked.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
23 function! pathogen#infect(...) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
24 let source_path = a:0 ? a:1 : 'bundle'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
25 if source_path =~# '[\\/]'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
26 call pathogen#runtime_prepend_subdirectories(source_path)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
27 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
28 call pathogen#runtime_append_all_bundles(source_path)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
29 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
30 call pathogen#cycle_filetype()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
31 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
32
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
33 " Split a path into a list.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
34 function! pathogen#split(path) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
35 if type(a:path) == type([]) | return a:path | endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
36 let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
37 return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
38 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
39
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
40 " Convert a list to a path.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
41 function! pathogen#join(...) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
42 if type(a:1) == type(1) && a:1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
43 let i = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
44 let space = ' '
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
45 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
46 let i = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
47 let space = ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
48 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
49 let path = ""
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
50 while i < a:0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
51 if type(a:000[i]) == type([])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
52 let list = a:000[i]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
53 let j = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
54 while j < len(list)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
55 let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
56 let path .= ',' . escaped
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
57 let j += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
58 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
59 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
60 let path .= "," . a:000[i]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
61 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
62 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
63 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
64 return substitute(path,'^,','','')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
65 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
66
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
67 " Convert a list to a path with escaped spaces for 'path', 'tag', etc.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
68 function! pathogen#legacyjoin(...) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
69 return call('pathogen#join',[1] + a:000)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
70 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
71
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
72 " Remove duplicates from a list.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
73 function! pathogen#uniq(list) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
74 let i = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
75 let seen = {}
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
76 while i < len(a:list)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
77 if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
78 call remove(a:list,i)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
79 elseif a:list[i] ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
80 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
81 let empty = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
82 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
83 let seen[a:list[i]] = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
84 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
85 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
86 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
87 return a:list
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
88 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
89
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
90 " \ on Windows unless shellslash is set, / everywhere else.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
91 function! pathogen#separator() abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
92 return !exists("+shellslash") || &shellslash ? '/' : '\'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
93 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
94
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
95 " Convenience wrapper around glob() which returns a list.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
96 function! pathogen#glob(pattern) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
97 let files = split(glob(a:pattern),"\n")
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
98 return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
99 endfunction "}}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
100
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
101 " Like pathogen#glob(), only limit the results to directories.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
102 function! pathogen#glob_directories(pattern) abort " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
103 return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
104 endfunction "}}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
105
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
106 " Turn filetype detection off and back on again if it was already enabled.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
107 function! pathogen#cycle_filetype() " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
108 if exists('g:did_load_filetypes')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
109 filetype off
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
110 filetype on
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
111 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
112 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
113
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
114 " Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
115 " its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
116 function! pathogen#is_disabled(path) " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
117 if a:path =~# '\~$'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
118 return 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
119 elseif !exists("g:pathogen_disabled")
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
120 return 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
121 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
122 let sep = pathogen#separator()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
123 return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
124 endfunction "}}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
125
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
126 " Prepend all subdirectories of path to the rtp, and append all 'after'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
127 " directories in those subdirectories.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
128 function! pathogen#runtime_prepend_subdirectories(path) " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
129 let sep = pathogen#separator()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
130 let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
131 let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
132 let rtp = pathogen#split(&rtp)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
133 let path = expand(a:path)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
134 call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
135 let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
136 return &rtp
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
137 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
138
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
139 " For each directory in rtp, check for a subdirectory named dir. If it
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
140 " exists, add all subdirectories of that subdirectory to the rtp, immediately
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
141 " after the original directory. If no argument is given, 'bundle' is used.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
142 " Repeated calls with the same arguments are ignored.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
143 function! pathogen#runtime_append_all_bundles(...) " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
144 let sep = pathogen#separator()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
145 let name = a:0 ? a:1 : 'bundle'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
146 if "\n".s:done_bundles =~# "\\M\n".name."\n"
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
147 return ""
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
148 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
149 let s:done_bundles .= name . "\n"
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
150 let list = []
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
151 for dir in pathogen#split(&rtp)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
152 if dir =~# '\<after$'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
153 let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
154 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
155 let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
156 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
157 endfor
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
158 let &rtp = pathogen#join(pathogen#uniq(list))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
159 return 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
160 endfunction
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
161
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
162 let s:done_bundles = ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
163 " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
164
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
165 " Invoke :helptags on all non-$VIM doc directories in runtimepath.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
166 function! pathogen#helptags() " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
167 let sep = pathogen#separator()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
168 for dir in pathogen#split(&rtp)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
169 if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.sep.'doc') == 2 && !empty(filter(split(glob(dir.sep.'doc'.sep.'*'),"\n>"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
170 helptags `=dir.'/doc'`
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
171 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
172 endfor
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
173 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
174
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
175 command! -bar Helptags :call pathogen#helptags()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
176
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
177 " Like findfile(), but hardcoded to use the runtimepath.
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
178 function! pathogen#runtime_findfile(file,count) "{{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
179 let rtp = pathogen#join(1,pathogen#split(&rtp))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
180 let file = findfile(a:file,rtp,a:count)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
181 if file ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
182 return ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
183 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
184 return fnamemodify(file,':p')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
185 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
186 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
187
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
188 " Backport of fnameescape().
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
189 function! pathogen#fnameescape(string) " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
190 if exists('*fnameescape')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
191 return fnameescape(a:string)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
192 elseif a:string ==# '-'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
193 return '\-'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
194 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
195 return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
196 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
197 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
198
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
199 if exists(':Vedit')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
200 finish
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
201 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
202
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
203 function! s:find(count,cmd,file,lcd) " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
204 let rtp = pathogen#join(1,pathogen#split(&runtimepath))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
205 let file = pathogen#runtime_findfile(a:file,a:count)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
206 if file ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
207 return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
208 elseif a:lcd
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
209 let path = file[0:-strlen(a:file)-2]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
210 execute 'lcd `=path`'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
211 return a:cmd.' '.pathogen#fnameescape(a:file)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
212 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
213 return a:cmd.' '.pathogen#fnameescape(file)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
214 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
215 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
216
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
217 function! s:Findcomplete(A,L,P) " {{{1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
218 let sep = pathogen#separator()
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
219 let cheats = {
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
220 \'a': 'autoload',
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
221 \'d': 'doc',
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
222 \'f': 'ftplugin',
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
223 \'i': 'indent',
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
224 \'p': 'plugin',
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
225 \'s': 'syntax'}
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
226 if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
227 let request = cheats[a:A[0]].a:A[1:-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 request = a:A
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
230 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
231 let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*'
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
232 let found = {}
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
233 for path in pathogen#split(&runtimepath)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
234 let path = expand(path, ':p')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
235 let matches = split(glob(path.sep.pattern),"\n")
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
236 call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
237 call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
238 for match in matches
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
239 let found[match] = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
240 endfor
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
241 endfor
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
242 return sort(keys(found))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
243 endfunction " }}}1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
244
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
245 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>,0)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
246 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>,0)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
247 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,1)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
248 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split',<q-args>,<bang>1)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
249 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit',<q-args>,<bang>1)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
250 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit',<q-args>,<bang>1)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
251 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit',<q-args>,<bang>1)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
252 command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read',<q-args>,<bang>1)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
253
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
254 " vim:set et sw=2: