-
Notifications
You must be signed in to change notification settings - Fork 24
/
vam_known_repositories.vim
64 lines (50 loc) · 2.53 KB
/
vam_known_repositories.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
if !exists('g:vim_addon_manager')
let g:vim_addon_manager={}
endif
let s:c=g:vim_addon_manager
let s:c['MergeSources']=get(g:vim_addon_manager, 'MergeSources', 'vam_known_repositories#MergeSources')
" the function returning the package pool.
" It can be configured in VAM and is run when command completion is used or
" when an update/ install action takes place.
" If you have custom packages overwrite this function and patch whatever you
" want to patch...
"
" arg www_vim_org: See vimpi#www_vim_org_generated#Sources() (result is patched vamkr#patch#Patch)
" arg scm_plugin_sources: See vimpi#scm#Sources() (vim_script_nr_X is replaced by plugin's name in keys)
fun! vam_known_repositories#MergeSources(plugin_sources, www_vim_org, scm_plugin_sources, patch_function, snr_to_name)
let merge_strategy = get(s:c, 'scm_merge_strategy', 'force')
let d = {}
" (1) merge in www.vim.org sources:
call extend(d, a:www_vim_org)
" (2) merge in SCM sources only if support isn't disabled
" (See VAMs documentation 4. Options -> drop_{scm}_soucres)
"
" g:vim_addon_manager['scm_merge_strategy'] options:
" force: prefer scm version over www.vim.org
" keep: only add scm version which have no released versions on www.vim.org
" never: Don't add scm versions to list of known sources
if merge_strategy isnot# 'never'
call filter(a:scm_plugin_sources, '!get(s:c, "drop_".(v:val.type)."_sources", 0)')
" old code, will be dropped: scm_support was renamed to drop_scm_sources
call filter(a:scm_plugin_sources, 'get(s:c, (v:val.type)."_support", 1)')
call extend(d, a:scm_plugin_sources, merge_strategy)
endif
let d=call(a:patch_function, [d, a:snr_to_name], {})
" always keep what the user has set:
call extend(a:plugin_sources, d, 'keep')
endf
" returns the package pool. Probably you want to overwrite MergeSources instead
" This function preparse www_vim_org and scm sources for MergeSources
" Its the default implementation for the one function returning the pool of
" known addons.
fun! vam_known_repositories#Pool()
let www_vim_org = vimpi#LoadDBFile('vimorgsources.json')
let snr_to_name = vimpi#GetNrToNameMap(www_vim_org)
let scm = vimpi#GetSCMSources(snr_to_name, www_vim_org)
" start from scratch adding plugin sources to pool:
let pool = copy(get(s:c, 'plugin_sources', {}))
" now call MergeSources merge function so that user can pick scm over
" www_vim_org sources as she desires.
call call(s:c['MergeSources'], [pool, www_vim_org, scm, 'vimpi#PatchSources', snr_to_name], {})
return pool
endf