Skip to content

Commit 356f245

Browse files
committed
Refactor global variables into autoload variables.
All global variables that are not part of the public API (mentioned in the documentation) are turned into autoload variables. This is intended to give all global variables defined by Vundle.vim a common prefix. The variable g:default_git_proto is part of the public API and is therefor not changed. This is the only exception. Changed: g:bundle_dir -> vundle#bundle_dir g:bundles -> vundle#bundles g:updated_bundles -> vundle#updated_bundles g:vundle_lazy_load -> vundle#lazy_load g:vundle_log -> vundle#log Unchanged: g:default_git_proto
1 parent 5f27abb commit 356f245

4 files changed

Lines changed: 37 additions & 36 deletions

File tree

autoload/vundle.vim

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ com! -nargs=? -bang PluginClean
2121
\ call vundle#installer#clean('!' == '<bang>')
2222

2323
com! -nargs=0 PluginDocs
24-
\ call vundle#installer#helptags(g:bundles)
24+
\ call vundle#installer#helptags(g:vundle#bundles)
2525

2626
" Aliases
2727
com! -nargs=* -complete=custom,vundle#scripts#complete PluginUpdate PluginInstall! <args>
@@ -61,22 +61,22 @@ endif
6161
" :Plugin command in the vimrc. It is not possible to do this automatically
6262
" because when loading the vimrc file no plugins where loaded yet.
6363
func! vundle#rc(...) abort
64-
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
65-
let g:updated_bundles = []
66-
let g:vundle_log = []
64+
let g:vundle#bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
65+
let g:vundle#updated_bundles = []
66+
let g:vundle#log = []
6767
call vundle#config#init()
6868
endf
6969

7070
" Alternative to vundle#rc, offers speed up by modifying rtp only when end()
7171
" called later.
7272
func! vundle#begin(...) abort
73-
let g:vundle_lazy_load = 1
73+
let g:vundle#lazy_load = 1
7474
call call('vundle#rc', a:000)
7575
endf
7676

7777
" Finishes putting plugins on the rtp.
7878
func! vundle#end(...) abort
79-
unlet g:vundle_lazy_load
79+
unlet g:vundle#lazy_load
8080
call vundle#config#activate_bundles()
8181
endf
8282

autoload/vundle/config.vim

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ func! vundle#config#bundle(arg, ...)
1010
if !s:check_bundle_name(bundle)
1111
return
1212
endif
13-
if exists('g:vundle_lazy_load') && g:vundle_lazy_load
14-
call add(g:bundles, bundle)
13+
if exists('g:vundle#lazy_load') && g:vundle#lazy_load
14+
call add(g:vundle#bundles, bundle)
1515
else
1616
call s:rtp_rm_a()
17-
call add(g:bundles, bundle)
17+
call add(g:vundle#bundles, bundle)
1818
call s:rtp_add_a()
1919
call s:rtp_add_defaults()
2020
endif
@@ -40,9 +40,9 @@ endf
4040
" once.
4141
" ---------------------------------------------------------------------------
4242
func! vundle#config#init()
43-
if !exists('g:bundles') | let g:bundles = [] | endif
43+
if !exists('g:vundle#bundles') | let g:vundle#bundles = [] | endif
4444
call s:rtp_rm_a()
45-
let g:bundles = []
45+
let g:vundle#bundles = []
4646
let s:bundle_names = {}
4747
endf
4848

@@ -55,11 +55,11 @@ endf
5555
func! vundle#config#require(bundles) abort
5656
for b in a:bundles
5757
call s:rtp_add(b.rtpath)
58-
call s:rtp_add(g:bundle_dir)
58+
call s:rtp_add(g:vundle#bundle_dir)
5959
" TODO: it has to be relative rtpath, not bundle.name
6060
exec 'runtime! '.b.name.'/plugin/*.vim'
6161
exec 'runtime! '.b.name.'/after/*.vim'
62-
call s:rtp_rm(g:bundle_dir)
62+
call s:rtp_rm(g:vundle#bundle_dir)
6363
endfor
6464
call s:rtp_add_defaults()
6565
endf
@@ -180,7 +180,7 @@ endf
180180
" runtimepath.
181181
" ---------------------------------------------------------------------------
182182
func! s:rtp_rm_a()
183-
let paths = map(copy(g:bundles), 'v:val.rtpath')
183+
let paths = map(copy(g:vundle#bundles), 'v:val.rtpath')
184184
let prepends = join(paths, ',')
185185
let appends = join(paths, '/after,').'/after'
186186
exec 'set rtp-='.fnameescape(prepends)
@@ -193,7 +193,7 @@ endf
193193
" runtimepath.
194194
" ---------------------------------------------------------------------------
195195
func! s:rtp_add_a()
196-
let paths = map(copy(g:bundles), 'v:val.rtpath')
196+
let paths = map(copy(g:vundle#bundles), 'v:val.rtpath')
197197
let prepends = join(paths, ',')
198198
let appends = join(paths, '/after,').'/after'
199199
exec 'set rtp^='.fnameescape(prepends)
@@ -262,7 +262,7 @@ let s:bundle = {}
262262
" return -- the target location to clone this bundle to
263263
" ---------------------------------------------------------------------------
264264
func! s:bundle.path()
265-
return s:expand_path(g:bundle_dir.'/'.self.name)
265+
return s:expand_path(g:vundle#bundle_dir.'/'.self.name)
266266
endf
267267

268268

autoload/vundle/installer.vim

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
" ---------------------------------------------------------------------------
2-
" Try to clone all new bundles given (or all bundles in g:bundles by default)
3-
" to g:bundle_dir. If a:bang is 1 it will also update all plugins (git pull).
2+
" Try to clone all new bundles given (or all bundles in g:vundle#bundles by
3+
" default) to g:vundle#bundle_dir. If a:bang is 1 it will also update all
4+
" plugins (git pull).
45
"
56
" bang -- 1 or 0
67
" ... -- any number of bundle specifications (separate arguments)
78
" ---------------------------------------------------------------------------
89
func! vundle#installer#new(bang, ...) abort
910
" No specific plugins are specified. Operate on all plugins.
1011
if a:0 == 0
11-
let bundles = g:bundles
12+
let bundles = g:vundle#bundles
1213
" Specific plugins are specified for update. Update them.
1314
elseif (a:bang)
14-
let bundles = filter(copy(g:bundles), 'index(a:000, v:val.name) > -1')
15+
let bundles = filter(copy(g:vundle#bundles), 'index(a:000, v:val.name) > -1')
1516
" Specific plugins are specified for installation. Install them.
1617
else
1718
let bundles = map(copy(a:000), 'vundle#config#bundle(v:val, {})')
@@ -23,7 +24,7 @@ func! vundle#installer#new(bang, ...) abort
2324
endif
2425

2526
let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec'))
26-
call vundle#scripts#view('Installer',['" Installing plugins to '.expand(g:bundle_dir, 1)], names + ['Helptags'])
27+
call vundle#scripts#view('Installer',['" Installing plugins to '.expand(g:vundle#bundle_dir, 1)], names + ['Helptags'])
2728

2829
" This calls 'add' as a normal mode command. This is a buffer local mapping
2930
" defined in vundle#scripts#view(). The mapping will call a buffer local
@@ -163,10 +164,10 @@ endf
163164
" return -- the return value from s:sync()
164165
" ---------------------------------------------------------------------------
165166
func! vundle#installer#install(bang, name) abort
166-
if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif
167+
if !isdirectory(g:vundle#bundle_dir) | call mkdir(g:vundle#bundle_dir, 'p') | endif
167168

168169
let n = substitute(a:name,"['".'"]\+','','g')
169-
let matched = filter(copy(g:bundles), 'v:val.name_spec == n')
170+
let matched = filter(copy(g:vundle#bundles), 'v:val.name_spec == n')
170171

171172
if len(matched) > 0
172173
let b = matched[0]
@@ -179,12 +180,12 @@ endf
179180

180181

181182
" ---------------------------------------------------------------------------
182-
" Call :helptags for all bundles in g:bundles.
183+
" Call :helptags for all bundles in g:vundle#bundles.
183184
"
184185
" return -- 'error' if an error occurred, else return 'helptags'
185186
" ---------------------------------------------------------------------------
186187
func! vundle#installer#docs() abort
187-
let error_count = vundle#installer#helptags(g:bundles)
188+
let error_count = vundle#installer#helptags(g:vundle#bundles)
188189
if error_count > 0
189190
return 'error'
190191
endif
@@ -222,10 +223,10 @@ endf
222223
" bang -- not used
223224
" ---------------------------------------------------------------------------
224225
func! vundle#installer#list(bang) abort
225-
let bundles = vundle#scripts#bundle_names(map(copy(g:bundles), 'v:val.name_spec'))
226+
let bundles = vundle#scripts#bundle_names(map(copy(g:vundle#bundles), 'v:val.name_spec'))
226227
call vundle#scripts#view('list', ['" My Plugins'], bundles)
227228
redraw
228-
echo len(g:bundles).' plugins configured'
229+
echo len(g:vundle#bundles).' plugins configured'
229230
endf
230231

231232

@@ -237,10 +238,10 @@ endf
237238
" should be removed unconditionally
238239
" ---------------------------------------------------------------------------
239240
func! vundle#installer#clean(bang) abort
240-
let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
241+
let bundle_dirs = map(copy(g:vundle#bundles), 'v:val.path()')
241242
let all_dirs = (v:version > 702 || (v:version == 702 && has("patch51")))
242-
\ ? split(globpath(g:bundle_dir, '*', 1), "\n")
243-
\ : split(globpath(g:bundle_dir, '*'), "\n")
243+
\ ? split(globpath(g:vundle#bundle_dir, '*', 1), "\n")
244+
\ : split(globpath(g:vundle#bundle_dir, '*'), "\n")
244245
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
245246

246247
if empty(x_dirs)
@@ -465,7 +466,7 @@ func! s:sync(bang, bundle) abort
465466
return 'todate'
466467
endif
467468

468-
call add(g:updated_bundles, [initial_sha, updated_sha, a:bundle])
469+
call add(g:vundle#updated_bundles, [initial_sha, updated_sha, a:bundle])
469470
return 'updated'
470471
endf
471472

@@ -527,7 +528,7 @@ func! s:log(str, ...) abort
527528
let lines = split(a:str, '\n', 1)
528529
let time = strftime(fmt)
529530
for line in lines
530-
call add(g:vundle_log, '['. time .'] '. prefix . line)
531+
call add(g:vundle#log, '['. time .'] '. prefix . line)
531532
endfor
532533
return a:str
533534
endf

autoload/vundle/scripts.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ endf
4242
func! vundle#scripts#complete(a,c,d)
4343
if match(a:c, '\v^%(Plugin|Vundle)%(Install!|Update)') == 0
4444
" Only installed plugins if updating
45-
return join(map(copy(g:bundles), 'v:val.name'), "\n")
45+
return join(map(copy(g:vundle#bundles), 'v:val.name'), "\n")
4646
else
4747
" Or all known plugins otherwise
4848
return join(s:load_scripts(0),"\n")
@@ -61,7 +61,7 @@ func! s:view_log()
6161
if bufloaded(s:log_file)
6262
execute 'silent bdelete' s:log_file
6363
endif
64-
call writefile(g:vundle_log, s:log_file)
64+
call writefile(g:vundle#log, s:log_file)
6565
execute 'silent pedit ' . s:log_file
6666

6767
wincmd P | wincmd H
@@ -74,7 +74,7 @@ endf
7474
" ---------------------------------------------------------------------------
7575
func! s:create_changelog() abort
7676
let changelog = ['Updated Plugins:']
77-
for bundle_data in g:updated_bundles
77+
for bundle_data in g:vundle#updated_bundles
7878
let initial_sha = bundle_data[0]
7979
let updated_sha = bundle_data[1]
8080
let bundle = bundle_data[2]
@@ -258,7 +258,7 @@ endf
258258
" specifications) of all plugins from vim-scripts.org
259259
" ---------------------------------------------------------------------------
260260
func! s:load_scripts(bang)
261-
let f = expand(g:bundle_dir.'/.vundle/script-names.vim-scripts.org.json', 1)
261+
let f = expand(g:vundle#bundle_dir.'/.vundle/script-names.vim-scripts.org.json', 1)
262262
if a:bang || !filereadable(f)
263263
if 0 != s:fetch_scripts(f)
264264
return []

0 commit comments

Comments
 (0)