annotate vendor/vim-autoload/pathogen.vim @ 684:6010e722b5da

[irbrc] Disable syntax highlighting as it slows down things Reference: https://github.com/ruby/irb/issues/292
author nanaya <me@nanaya.pro>
date Wed, 14 Sep 2022 19:06:13 +0900
parents c74dffea6a0a
children 17cacf387f7c
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
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
19 " pathogen#interpose() or an absolute path to invoke pathogen#surround().
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
20 " Curly braces are expanded with pathogen#expand(): "bundle/{}" finds all
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
21 " subdirectories inside "bundle" inside all directories in the runtime path.
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
22 " If no arguments are given, defaults "bundle/{}", and also "pack/{}/start/{}"
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
23 " on versions of Vim without native package support.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
24 function! pathogen#infect(...) abort
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
25 if a:0
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
26 let paths = filter(reverse(copy(a:000)), 'type(v:val) == type("")')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
27 else
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
28 let paths = ['bundle/{}', 'pack/{}/start/{}']
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
29 endif
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
30 if has('packages')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
31 call filter(paths, 'v:val !~# "^pack/[^/]*/start/[^/]*$"')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
32 endif
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
33 let static = '^\%([$~\\/]\|\w:[\\/]\)[^{}*]*$'
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
34 for path in filter(copy(paths), 'v:val =~# static')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
35 call pathogen#surround(path)
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
36 endfor
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
37 for path in filter(copy(paths), 'v:val !~# static')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
38 if path =~# '^\%([$~\\/]\|\w:[\\/]\)'
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
39 call pathogen#surround(path)
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
40 else
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
41 call pathogen#interpose(path)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
42 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
43 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
44 call pathogen#cycle_filetype()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
45 if pathogen#is_disabled($MYVIMRC)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
46 return 'finish'
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
47 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
48 return ''
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
49 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
50
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
51 " Split a path into a list.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
52 function! pathogen#split(path) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
53 if type(a:path) == type([]) | return a:path | endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
54 if empty(a:path) | return [] | endif
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
55 let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
56 return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
57 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
58
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
59 " Convert a list to a path.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
60 function! pathogen#join(...) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
61 if type(a:1) == type(1) && a:1
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 let space = ' '
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
64 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
65 let i = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
66 let space = ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
67 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
68 let path = ""
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
69 while i < a:0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
70 if type(a:000[i]) == type([])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
71 let list = a:000[i]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
72 let j = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
73 while j < len(list)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
74 let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
75 let path .= ',' . escaped
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
76 let j += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
77 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
78 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
79 let path .= "," . a:000[i]
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
80 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
81 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
82 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
83 return substitute(path,'^,','','')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
84 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
85
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
86 " 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
87 function! pathogen#legacyjoin(...) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
88 return call('pathogen#join',[1] + a:000)
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
89 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
90
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
91 " Turn filetype detection off and back on again if it was already enabled.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
92 function! pathogen#cycle_filetype() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
93 if exists('g:did_load_filetypes')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
94 filetype off
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
95 filetype on
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
96 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
97 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
98
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
99 " 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
100 " 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
101 " comma delimited environment variable $VIMBLACKLIST.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
102 function! pathogen#is_disabled(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
103 if a:path =~# '\~$'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
104 return 1
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
105 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
106 let sep = pathogen#slash()
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
107 let blacklist = get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) + pathogen#split($VIMBLACKLIST)
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
108 if !empty(blacklist)
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
109 call map(blacklist, 'substitute(v:val, "[\\/]$", "", "")')
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
110 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
111 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
112 endfunction
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
113
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
114 " Prepend the given directory to the runtime path and append its corresponding
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
115 " after directory. Curly braces are expanded with pathogen#expand().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
116 function! pathogen#surround(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
117 let sep = pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
118 let rtp = pathogen#split(&rtp)
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
119 let path = fnamemodify(a:path, ':s?[\\/]\=$??')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
120 let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
661
c74dffea6a0a [vim-syntax] Update syntax
nanaya <me@nanaya.pro>
parents: 612
diff changeset
121 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
122 call filter(rtp, 'index(before + after, v:val) == -1')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
123 let &rtp = pathogen#join(before, rtp, after)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
124 return &rtp
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
125 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
126
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
127 " 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
128 " argument appended. Curly braces are expanded with pathogen#expand().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
129 function! pathogen#interpose(name) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
130 let sep = pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
131 let name = a:name
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
132 if has_key(s:done_bundles, name)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
133 return ""
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
134 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
135 let s:done_bundles[name] = 1
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
136 let list = []
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
137 for dir in pathogen#split(&rtp)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
138 if dir =~# '\<after$'
661
c74dffea6a0a [vim-syntax] Update syntax
nanaya <me@nanaya.pro>
parents: 612
diff changeset
139 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
140 else
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
141 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
142 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
143 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
144 let &rtp = pathogen#join(pathogen#uniq(list))
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
145 return 1
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
146 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
147
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
148 let s:done_bundles = {}
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
149
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
150 " Invoke :helptags on all non-$VIM doc directories in runtimepath.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
151 function! pathogen#helptags() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
152 let sep = pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
153 for glob in pathogen#split(&rtp)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
154 for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
155 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
156 silent! execute 'helptags' pathogen#fnameescape(dir)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
157 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
158 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
159 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
160 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
161
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
162 command! -bar Helptags :call pathogen#helptags()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
163
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
164 " Execute the given command. This is basically a backdoor for --remote-expr.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
165 function! pathogen#execute(...) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
166 for command in a:000
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
167 execute command
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
168 endfor
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
169 return ''
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
170 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
171
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
172 " Section: Unofficial
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
173
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
174 function! pathogen#is_absolute(path) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
175 return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
176 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
177
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
178 " Given a string, returns all possible permutations of comma delimited braced
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
179 " alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
180 " ['/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
181 " and globbed. Actual globs are preserved.
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
182 function! pathogen#expand(pattern, ...) abort
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
183 let after = a:0 ? a:1 : ''
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
184 let pattern = substitute(a:pattern, '^[~$][^\/]*', '\=expand(submatch(0))', '')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
185 if pattern =~# '{[^{}]\+}'
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
186 let [pre, pat, post] = split(substitute(pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
187 let found = map(split(pat, ',', 1), 'pre.v:val.post')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
188 let results = []
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
189 for pattern in found
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
190 call extend(results, pathogen#expand(pattern))
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
191 endfor
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
192 elseif pattern =~# '{}'
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
193 let pat = matchstr(pattern, '^.*{}[^*]*\%($\|[\\/]\)')
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
194 let post = pattern[strlen(pat) : -1]
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
195 let results = map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
196 else
612
b305f2ce5f88 Update vendored files
nanaya <me@nanaya.pro>
parents: 595
diff changeset
197 let results = [pattern]
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
198 endif
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
199 let vf = pathogen#slash() . 'vimfiles'
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
200 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
201 return filter(results, '!empty(v:val)')
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
202 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
203
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
204 " \ on Windows unless shellslash is set, / everywhere else.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
205 function! pathogen#slash() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
206 return !exists("+shellslash") || &shellslash ? '/' : '\'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
207 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
208
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
209 function! pathogen#separator() abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
210 return pathogen#slash()
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
211 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
212
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
213 " Convenience wrapper around glob() which returns a list.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
214 function! pathogen#glob(pattern) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
215 let files = split(glob(a:pattern),"\n")
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
216 return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
217 endfunction
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
218
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
219 " Like pathogen#glob(), only limit the results to directories.
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
220 function! pathogen#glob_directories(pattern) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
221 return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
222 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
223
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
224 " Remove duplicates from a list.
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
225 function! pathogen#uniq(list) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
226 let i = 0
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
227 let seen = {}
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
228 while i < len(a:list)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
229 if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
230 call remove(a:list,i)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
231 elseif a:list[i] ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
232 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
233 let empty = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
234 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
235 let seen[a:list[i]] = 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
236 let i += 1
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
237 endif
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
238 endwhile
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
239 return a:list
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
240 endfunction
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
241
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
242 " Backport of fnameescape().
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
243 function! pathogen#fnameescape(string) abort
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
244 if exists('*fnameescape')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
245 return fnameescape(a:string)
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
246 elseif a:string ==# '-'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
247 return '\-'
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
248 else
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
249 return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
250 endif
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
251 endfunction
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
252
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
253 " Like findfile(), but hardcoded to use the runtimepath.
589
7fbadf8bd22e Update vendor
nanaya <me@myconan.net>
parents: 572
diff changeset
254 function! pathogen#runtime_findfile(file,count) abort
425
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
255 let rtp = pathogen#join(1,pathogen#split(&rtp))
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
256 let file = findfile(a:file,rtp,a:count)
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
257 if file ==# ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
258 return ''
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
259 else
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
260 return fnamemodify(file,':p')
7394b88bf1c6 Pathogen in vim.
Edho Arief <edho@myconan.net>
parents:
diff changeset
261 endif
569
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
262 endfunction
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
263
ea4bc5799d71 Update pathogen.
nanaya <me@myconan.net>
parents: 425
diff changeset
264 " vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':