Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated pathogen

  • Loading branch information...
commit add330994f02ae020699d7fb634896de58b9bc3c 1 parent 18ffc26
Kevin Kuchta authored April 18, 2012

Showing 1 changed file with 82 additions and 14 deletions. Show diff stats Hide diff stats

  1. 96  autoload/pathogen.vim
96  autoload/pathogen.vim
... ...
@@ -1,23 +1,32 @@
1 1
 " pathogen.vim - path option manipulation
2  
-" Maintainer:   Tim Pope <vimNOSPAM@tpope.org>
3  
-" Version:      1.3
  2
+" Maintainer:   Tim Pope <http://tpo.pe/>
  3
+" Version:      2.0
4 4
 
5 5
 " Install in ~/.vim/autoload (or ~\vimfiles\autoload).
6 6
 "
7  
-" For management of individually installed plugins in ~/.vim/bundle
8  
-" (or $HOME/vimfiles/bundle), adding 'call pathogen#infect()' to your
9  
-" .vimrc prior to 'fileype plugin indent on' is the only other setup necessary.
  7
+" For management of individually installed plugins in ~/.vim/bundle (or
  8
+" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
  9
+" prior to `fileype plugin indent on` is the only other setup necessary.
10 10
 "
11  
-" API is documented below.
  11
+" The API is documented inline below.  For maximum ease of reading,
  12
+" :set foldmethod=marker
12 13
 
13 14
 if exists("g:loaded_pathogen") || &cp
14 15
   finish
15 16
 endif
16 17
 let g:loaded_pathogen = 1
17 18
 
18  
-" Point of entry for basic default usage.
19  
-function! pathogen#infect() abort " {{{1
20  
-  call pathogen#runtime_append_all_bundles()
  19
+" Point of entry for basic default usage.  Give a directory name to invoke
  20
+" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
  21
+" to invoke pathogen#runtime_prepend_subdirectories().  Afterwards,
  22
+" pathogen#cycle_filetype() is invoked.
  23
+function! pathogen#infect(...) abort " {{{1
  24
+  let source_path = a:0 ? a:1 : 'bundle'
  25
+  if source_path =~# '[\\/]'
  26
+    call pathogen#runtime_prepend_subdirectories(source_path)
  27
+  else
  28
+    call pathogen#runtime_append_all_bundles(source_path)
  29
+  endif
21 30
   call pathogen#cycle_filetype()
22 31
 endfunction " }}}1
23 32
 
@@ -100,9 +109,11 @@ function! pathogen#cycle_filetype() " {{{1
100 109
 endfunction " }}}1
101 110
 
102 111
 " Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
103  
-" its 'basename()' is included in g:pathogen_disabled[]'.
  112
+" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
104 113
 function! pathogen#is_disabled(path) " {{{1
105  
-  if !exists("g:pathogen_disabled")
  114
+  if a:path =~# '\~$'
  115
+    return 1
  116
+  elseif !exists("g:pathogen_disabled")
106 117
     return 0
107 118
   endif
108 119
   let sep = pathogen#separator()
@@ -113,8 +124,8 @@ endfunction "}}}1
113 124
 " directories in those subdirectories.
114 125
 function! pathogen#runtime_prepend_subdirectories(path) " {{{1
115 126
   let sep    = pathogen#separator()
116  
-  let before = filter(pathogen#glob_directories(a:path.sep."*[^~]"), '!pathogen#is_disabled(v:val)')
117  
-  let after  = filter(pathogen#glob_directories(a:path.sep."*[^~]".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
  127
+  let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
  128
+  let after  = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
118 129
   let rtp = pathogen#split(&rtp)
119 130
   let path = expand(a:path)
120 131
   call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
@@ -150,8 +161,9 @@ let s:done_bundles = ''
150 161
 
151 162
 " Invoke :helptags on all non-$VIM doc directories in runtimepath.
152 163
 function! pathogen#helptags() " {{{1
  164
+  let sep = pathogen#separator()
153 165
   for dir in pathogen#split(&rtp)
154  
-    if dir[0 : strlen($VIMRUNTIME)-1] !=# $VIMRUNTIME && filewritable(dir.'/doc') == 2 && !empty(glob(dir.'/doc/*')) && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
  166
+    if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.'/doc') == 2 && !empty(glob(dir.'/doc/*')) && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
155 167
       helptags `=dir.'/doc'`
156 168
     endif
157 169
   endfor
@@ -159,4 +171,60 @@ endfunction " }}}1
159 171
 
160 172
 command! -bar Helptags :call pathogen#helptags()
161 173
 
  174
+" Like findfile(), but hardcoded to use the runtimepath.
  175
+function! pathogen#rtpfindfile(file,count) "{{{1
  176
+  let rtp = pathogen#join(1,pathogen#split(&rtp))
  177
+  return fnamemodify(findfile(a:file,rtp,a:count),':p')
  178
+endfunction " }}}1
  179
+
  180
+function! s:find(count,cmd,file,...) " {{{1
  181
+  let rtp = pathogen#join(1,pathogen#split(&runtimepath))
  182
+  let file = pathogen#rtpfindfile(a:file,a:count)
  183
+  if file ==# ''
  184
+    return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
  185
+  elseif a:0
  186
+    let path = file[0:-strlen(a:file)-2]
  187
+    execute a:1.' `=path`'
  188
+    return a:cmd.' '.fnameescape(a:file)
  189
+  else
  190
+    return a:cmd.' '.fnameescape(file)
  191
+  endif
  192
+endfunction " }}}1
  193
+
  194
+function! s:Findcomplete(A,L,P) " {{{1
  195
+  let sep = pathogen#separator()
  196
+  let cheats = {
  197
+        \'a': 'autoload',
  198
+        \'d': 'doc',
  199
+        \'f': 'ftplugin',
  200
+        \'i': 'indent',
  201
+        \'p': 'plugin',
  202
+        \'s': 'syntax'}
  203
+  if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
  204
+    let request = cheats[a:A[0]].a:A[1:-1]
  205
+  else
  206
+    let request = a:A
  207
+  endif
  208
+  let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
  209
+  let found = {}
  210
+  for path in pathogen#split(&runtimepath)
  211
+    let matches = split(glob(path.sep.pattern),"\n")
  212
+    call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
  213
+    call map(matches,'v:val[strlen(path)+1:-1]')
  214
+    for match in matches
  215
+      let found[match] = 1
  216
+    endfor
  217
+  endfor
  218
+  return sort(keys(found))
  219
+endfunction " }}}1
  220
+
  221
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Ve       :execute s:find(<count>,'edit<bang>',<q-args>)
  222
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit    :execute s:find(<count>,'edit<bang>',<q-args>)
  223
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit   :execute s:find(<count>,'split<bang>',<q-args>)
  224
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit  :execute s:find(<count>,'vsplit<bang>',<q-args>)
  225
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit<bang>',<q-args>)
  226
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit   :execute s:find(<count>,'pedit<bang>',<q-args>)
  227
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread    :execute s:find(<count>,'read<bang>',<q-args>)
  228
+command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen    :execute s:find(<count>,'edit<bang>',<q-args>,'lcd')
  229
+
162 230
 " vim:set ft=vim ts=8 sw=2 sts=2:

0 notes on commit add3309

Please sign in to comment.
Something went wrong with that request. Please try again.