Browse files

TPluginRoot!: With bang, mark this root for shallow scans

  • Loading branch information...
1 parent 762af30 commit b0a8aee32173db30b3066ca89f555e4d782edf65 @tomtom committed Dec 25, 2011
Showing with 49 additions and 22 deletions.
  1. +32 −14 autoload/tplugin.vim
  2. +17 −8 macros/tplugin.vim
View
46 autoload/tplugin.vim
@@ -4,7 +4,7 @@
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2010-09-17.
" @Last Change: 2011-12-25.
-" @Revision: 196
+" @Revision: 203
if !exists('g:tplugin#autoload_exclude')
@@ -30,11 +30,16 @@ if !exists('g:tplugin#scan')
endif
+if !exists('g:tplugin#shallow_scan')
+ let g:tplugin#shallow_scan = 'hm' "{{{2
+endif
+
+
" Write autoload information for each root directory to
" "ROOT/_tplugin.vim".
" Search in autoload/tplugin/autoload/*.vim for prefabricated autoload
" definitions. The file's basenames are repo names.
-function! tplugin#ScanRoots(immediate, roots, args) "{{{3
+function! tplugin#ScanRoots(immediate, roots, shallow_roots, args) "{{{3
let prefabs = {}
for prefab in split(globpath(&rtp, 'autoload/tplugin/autoload/*.vim'), '\n')
let prefab_key = fnamemodify(prefab, ':t:r')
@@ -44,15 +49,7 @@ function! tplugin#ScanRoots(immediate, roots, args) "{{{3
endif
endfor
- let awhat = get(a:args, 0, '')
- if empty(awhat)
- let awhat = g:tplugin#scan
- endif
- if awhat == 'all'
- let what = ['c', 'f', 'a', 'p', 'h', 't', 'l', 'm', '_']
- else
- let what = split(awhat, '\zs')
- endif
+ let awhat0 = get(a:args, 0, '')
" echom "DBG what" string(what)
let aroot = get(a:args, 1, '')
@@ -64,12 +61,29 @@ function! tplugin#ScanRoots(immediate, roots, args) "{{{3
" TLogVAR what, a:roots
- if index(what, 'h') != -1
- call s:MakeHelpTags(roots, 'guess')
- endif
+ let helptags_roots = []
for root in roots
+ if empty(awhat0)
+ if index(a:shallow_roots, root) != -1
+ let awhat = g:tplugin#shallow_scan
+ else
+ let awhat = g:tplugin#scan
+ endif
+ else
+ let awhat = awhat0
+ endif
+ if awhat == 'all'
+ let what = ['c', 'f', 'a', 'p', 'h', 't', 'l', 'm', '_']
+ else
+ let what = split(awhat, '\zs')
+ endif
+
+ if index(what, 'h') != -1
+ call add(helptags_roots, root)
+ endif
+
" TLogVAR root
let [is_tree, root] = s:GetRealRoot(root)
" TLogVAR root, is_tree, isdirectory(root), len(files0)
@@ -229,6 +243,10 @@ function! tplugin#ScanRoots(immediate, roots, args) "{{{3
endif
endfor
+
+ if !empty(helptags_roots)
+ call s:MakeHelpTags(helptags_roots, 'guess')
+ endif
endf
View
25 macros/tplugin.vim
@@ -4,8 +4,8 @@
" @GIT: http://github.com/tomtom/tplugin_vim/
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Created: 2010-01-04.
-" @Last Change: 2011-12-17.
-" @Revision: 1933
+" @Last Change: 2011-12-25.
+" @Revision: 1936
" GetLatestVimScripts: 2917 1 :AutoInstall: tplugin.vim
if &cp || exists("loaded_tplugin")
@@ -84,11 +84,14 @@ command! -bang -nargs=+ -complete=customlist,s:TPluginComplete TPlugin
\ call TPluginRequire(!empty("<bang>"), '', <f-args>)
-" :display: :TPluginRoot DIRECTORY
+" :display: :TPluginRoot[!] DIRECTORY
" Define the root directory for the following |:TPlugin| commands.
" Read autoload information if available (see |g:tplugin_autoload| and
" |:TPluginScan|).
"
+" With the optional <bang>, don't register commands, functions etc. when
+" scanning the root with |:TPluginScan|.
+"
" If DIRECTORY ends with "*", it doesn't refer to a directory hierarchy
" à la vimfiles but to a single "flat" directory.
"
@@ -103,8 +106,8 @@ command! -bang -nargs=+ -complete=customlist,s:TPluginComplete TPlugin
" TPluginRoot ~/src/git_repos
" " A directory with experimental plugins
" TPluginRoot ~/vimfiles/experimental_plugins/*
-command! -nargs=+ -complete=dir TPluginRoot
- \ call s:SetRoot(<q-args>)
+command! -bang -nargs=+ -complete=dir TPluginRoot
+ \ call s:SetRoot(<q-args>, !empty("<bang>"))
" :display: :TPluginScan[!] [WHAT] [ROOT]
@@ -143,7 +146,7 @@ command! -nargs=+ -complete=dir TPluginRoot
" TPluginRoot dir2
" TPluginScan
command! -bang -nargs=* TPluginScan
- \ call tplugin#ScanRoots(!empty("<bang>"), s:roots, [<f-args>])
+ \ call tplugin#ScanRoots(!empty("<bang>"), s:roots, s:shallow_roots, [<f-args>])
" :display: :TPluginBefore FILE_RX COMMAND
@@ -186,6 +189,7 @@ command! -bang TPluginUpdate call tplugin#vcsdo#Update(!empty('<bang>'), s:roots
let &rtp .= ','. escape(expand('<sfile>:p:h:h'), ',')
let s:roots = []
+let s:shallow_roots = []
let s:rtp = split(&rtp, ',')
let s:reg = {}
let s:repos = {}
@@ -544,8 +548,10 @@ endf
let s:rescanned_roots = 0
-function! s:SetRoot(dir) "{{{3
+" function! s:SetRoot(dir, ?shallow=0)
+function! s:SetRoot(dir, ...) "{{{3
" echom "DBG SetRoot" a:dir
+ let shallow = a:0 >= 1 ? a:1 : 0
let root = TPluginGetCanonicalFilename(fnamemodify(a:dir, ':p'))
let idx = index(s:roots, root)
if idx > 0
@@ -554,6 +560,9 @@ function! s:SetRoot(dir) "{{{3
if idx != 0
call insert(s:roots, root)
endif
+ if shallow
+ call insert(s:shallow_roots, root)
+ endif
" Don't reload the file. Old autoload definitions won't be
" overwritten anyway.
if idx == -1 && g:tplugin_autoload
@@ -571,7 +580,7 @@ function! s:SetRoot(dir) "{{{3
\ echohl WarningMsg |
\ echom "TPlugin: Outdated _tplugin.vim files ... Rescanning roots: Please be patient" |
\ echohl NONE
- autocmd VimEnter * call tplugin#ScanRoots(1, s:roots, [])
+ autocmd VimEnter * call tplugin#ScanRoots(1, s:roots, s:shallow_roots, [])
let s:rescanned_roots = 1
endif
catch

0 comments on commit b0a8aee

Please sign in to comment.