Permalink
Browse files

implement customizable pool function making it explicit that VAM can …

…be used with any kind of "plugin-pool".

Update VAM-kr when running :UpdateAddon before checking for updates.
Previously running :UpdateAddon was required to run twice:
The first time to update  VAM-kr, restart, the second time to update the plugins..

drop missing_addon_infos in favor of addon's
'addon-info'] key. This way different addon-info
files cane be specified for scm and non scm versions.
This changce is inspired by ZyX's work
  • Loading branch information...
MarcWeber committed Jan 5, 2012
1 parent 6565b0c commit e7b8ee494ade0da67cf492e228f1d8cc424919b4
Showing with 62 additions and 17 deletions.
  1. +5 −2 autoload/vam.vim
  2. +47 −13 autoload/vam/install.vim
  3. +2 −2 autoload/vam/test.vim
  4. +8 −0 doc/vim-addon-manager.txt
View
@@ -31,7 +31,6 @@ let s:c['auto_install'] = get(s:c,'auto_install', 0)
" repository locations:
let s:c['plugin_sources'] = get(s:c,'plugin_sources', {})
" if a plugin has an item here the dict value contents will be written as plugin info file
-let s:c['missing_addon_infos'] = get(s:c,'missing_addon_infos', {})
let s:c['activated_plugins'] = get(s:c,'activated_plugins', {})
" gentoo users may install VAM system wide. In that case s:d is not writeable.
@@ -47,6 +46,10 @@ let s:c['change_to_unix_ff'] = get(s:c, 'change_to_unix_ff', (g:os=~#'unix'))
let s:c['do_diff'] = get(s:c, 'do_diff', 1)
let s:c['dont_source'] = get(s:c, 'dont_source', 0)
let s:c['plugin_dir_by_name'] = get(s:c, 'plugin_dir_by_name', 'vam#DefaultPluginDirByName')
+" the function returning the list of known repositories
+let s:c['MergeSources'] = get(s:c, 'MergeSources', 'vam_known_repositories#MergeSources')
+let s:c['pool_fun'] = get(s:c, 'pool_fun', 'vam_known_repositories#Pool')
+let s:c['renamings_fun'] = get(s:c, 'renamings_fun', 'vamkr#rename_dict_parts_generated#Renamings')
" for testing it is necessary to avoid the "Press enter to continue lines"
" (cygwin?). Thus provide an option making all shell commands silent
@@ -287,7 +290,7 @@ fun! vam#DisplayAddonInfo(name)
endfun
fun! vam#DisplayAddonsInfo(names)
- call vam#install#LoadKnownRepos({})
+ call vam#install#LoadPool()
for name in a:names
call vam#DisplayAddonInfo(name)
endfor
View
@@ -4,6 +4,7 @@ let s:curl = exists('g:netrw_http_cmd') ? g:netrw_http_cmd : 'curl -o'
exec vam#DefineAndBind('s:c','g:vim_addon_manager','{}')
let s:c.name_rewriting = get(s:c, 'name_rewriting', {})
+
call extend(s:c.name_rewriting, {'99git+github': 'vam#install#RewriteName'})
fun! s:confirm(msg, ...)
@@ -81,11 +82,19 @@ fun! vam#install#Install(toBeInstalledList, ...)
let opts = a:0 == 0 ? {} : a:1
let auto_install = s:c['auto_install'] || get(opts,'auto_install',0)
for name in toBeInstalledList
+ if has_key(s:c.renamings_dict, name)
+ call vam#Log( "VAM: error installing ".name." because it has been renamed to ". s:c.renamings_dict[name] )
+ continue " due to abort this won't take place ?
+ " yes - we could make VAM use the new name automatically ...
+ " However that would require loading the dictionary containing the names
+ " on each startup. Would be cheap enough for considering ..
+ endif
+
" make sure all sources are known
if vam#IsPluginInstalled(name)
continue
endif
- if name != s:c['known'] | call vam#install#LoadKnownRepos(opts) | endif
+ if name != s:c['known'] | call vam#install#LoadPool() |endif
let repository = get(s:c['plugin_sources'], name, get(opts, name,0))
@@ -138,8 +147,8 @@ fun! vam#install#Install(toBeInstalledList, ...)
let infoFile = vam#AddonInfoFile(name)
call vam#install#Checkout(pluginDir, repository)
- if !filereadable(infoFile) && has_key(s:c['missing_addon_infos'], name)
- call writefile([s:c['missing_addon_infos'][name]], infoFile)
+ if !filereadable(infoFile) && has_key(repository, 'addon-info')
+ call writefile([string(repository['addon-info'])], infoFile)
endif
" install dependencies
@@ -176,7 +185,7 @@ fun! vam#install#UpdateAddon(name)
"Next, try updating plugin by archive
" we have to find out whether there is a new version:
- call vam#install#LoadKnownRepos({})
+ call vam#install#LoadPool()
let repository = get(s:c['plugin_sources'], a:name, {})
if empty(repository)
call vam#Log("Don't know how to update ".a:name." because it is not contained in plugin_sources")
@@ -284,13 +293,19 @@ endf
fun! vam#install#Update(list)
let list = a:list
+
+
+ " include vim-addon-manager in list only if writeable (non gentoo system
+ " wide installation)
+ if s:c.pool_fun == 'vam_known_repositories#Pool'
+ \ && filewritable(vam#PluginDirByName('vim-addon-manager'))==2
+ call vam#install#UpdateAddon('vim-addon-manager-known-repositories')
+ call vam#install#HelpTags('vim-addon-manager-known-repositories')
+ endif
+ " refresh sources:
+ call vam#install#LoadPool(1)
+
if empty(list) && s:confirm('Update all loaded plugins?')
- call vam#install#LoadKnownRepos({}, ' so that its updated as well')
- " include vim-addon-manager in list only if writeable (non gentoo system
- " wide installation)
- if filewritable(vam#PluginDirByName('vim-addon-manager'))==2
- call vam#ActivateAddons(['vim-addon-manager'])
- endif
let list = keys(s:c['activated_plugins'])
endif
let failed = []
@@ -315,7 +330,7 @@ fun! vam#install#KnownAddons(...)
let list = filter(split(glob(vam#PluginDirByName('*')),"\n"), 'isdirectory(v:val)')
let list = map(list, "fnamemodify(v:val,':t')")
if which == "installable"
- call vam#install#LoadKnownRepos({})
+ call vam#install#LoadPool()
call extend(list, keys(s:c['plugin_sources']))
elseif which == "installed"
" hard to find out. Doing glob is best thing to do..
@@ -448,11 +463,13 @@ fun! vam#install#Copy(f,t)
endif
endfun
+" fun! vam#install#LoadKnownRepos(opts, ...):
+" OLD code: replaced by vam_known_repositories#Pool() See VAM-kr
" VAM does call this function for you when using {Activate/Install}Addon() or
" one of those commands. Read doc/vim-addon-manager.txt to learn about the
" pool of plugin sources. Also see option "known_repos_activation_policy"
-fun! vam#install#LoadKnownRepos(opts, ...)
+fun! vam#install#LoadKnownRepos()
" opts: only used to pass topLevel argument
" this could be done better: see BUGS section in documantation "force".
@@ -479,13 +496,30 @@ fun! vam#install#LoadKnownRepos(opts, ...)
if has('vim_starting')
" This is not done in .vimrc because Vim loads plugin/*.vim files after
" having finished processing .vimrc. So do it manually
- exec 'source '.vam#PluginDirByName(known).'/plugin/vim-addon-manager-known-repositories.vim'
+ let rtp.=','.vam#PluginDirByName(known)
+ " exec 'source '.vam#PluginDirByName(known).'/plugin/vim-addon-manager-known-repositories.vim'
endif
endif
endif
unlet g:in_load_known_repositories
endf
+" (re)loads pool of known plugins
+fun! vam#install#LoadPool(...)
+ let force = a:0 > 0 ? a:1 : 0
+ if force || !has_key(s:c, 'pool_loaded')
+ if s:c.pool_fun == 'vam_known_repositories#Pool'
+ call vam#install#LoadKnownRepos()
+ endif
+
+ " update plugin_sources and renamings_dict
+ let s:c.plugin_sources = call(s:c.pool_fun,[])
+ " in case of VAM-kr TryCall is called in #Pool()
+ let s:c.renamings_dict = call(s:c.renamings_fun, [])
+
+ let s:c.pool_loaded = 1
+ endif
+endf
fun! vam#install#MergeTarget()
return split(&runtimepath,",")[0].'/after/plugin/vim-addon-manager-merged.vim'
View
@@ -49,7 +49,7 @@ fun! vam#test#TestUnpack(test) abort
let tmpDir = vam#utils#TempDir("vim-addon-manager-test")
- call vam#install#LoadKnownRepos({})
+ call vam#install#LoadPool()
for [k,v] in items(tests)
if k !~ a:test | continue | endif
@@ -73,7 +73,7 @@ endf
" tests that creating and applying diffs when updating archive plugins (found
" on www.vim.org) works as expected.
fun! vam#test#TestUpdate(case) abort
- call vam#install#LoadKnownRepos({})
+ call vam#install#LoadPool()
let tmpDir = vam#utils#TempDir("vim-addon-manager-test")
let plugin_name = "www_vim_org_update_test"
let plugin_source_file = tmpDir.'/'.plugin_name.'.vim'
@@ -483,6 +483,14 @@ MergeSources *VAM-MergeSources*
An Example can be found in this file.
+pool_fun *VAM-pool_fun*
+ Function reference returning list of known plugins VAM knows about.
+ If default function vam_known_repositories#Pool is used VAM-kr is
+ activated .. See |VAM-known_repos_activation_policy|
+renamings_fun *VAM-renamings_fun*
+ Function reference returning list of renamings used by VAM-kr and
+ InstallAddons() function.
+
==============================================================================
6. Uninstalling Plugins *VAM-uninstall-plugins*

0 comments on commit e7b8ee4

Please sign in to comment.