Skip to content

Documentation example replaces g:vim_addon_manager while it should just add property. #64

Closed
kyrisu opened this Issue Mar 12, 2012 · 2 comments

3 participants

@kyrisu
kyrisu commented Mar 12, 2012

In the example in the documentation there is something like:

let g:vim_addon_manager = {'scms': {'git': {}}}

I'm not a git expert but shouldn't there be something like:

let g:vim_addon_manager.scms = {'git': {}}

The first assignment replaces the entire vim_addon_manager object (at least for me) and I'm unable to override the settings. The second option works perfectly.

@MarcWeber
Owner
@ZyX-I
Collaborator
ZyX-I commented Mar 12, 2012

The first assignment replaces the entire vim_addon_manager object (at least for me) and I'm unable to override the settings. The second option works perfectly.

It was assuming that user knows what he is doing. That example works perfectly at the very top of the vimrc and also works in any other place before calling VAM, though having undesired side-effect of unsetting all previously set options. I was thinking of adding either vam#Setoption function or adding a possibility of using g:vam_{option_name} in addition with adding vam#Addoption(option, default) because in this case expressions populating s:c and keeping backwards compatibility grow too complex for repeating them every time option is set.

function s:Setoption(var, option, value)
    if !exists(a:var)
        execute 'let '.a:var.'={}'
    endif
    let idx=stridx(a:option, '.')
    if idx==-1
        execute 'let '.a:var.'['.string(a:option).']=a:value'
    else
        return s:Setoption(a:var.'['.string(a:option[:(idx-1)]).']', a:option[idx+1:], a:value)
    endif
endfunction
function vam#Setoption(option, value)
    return s:Setoption('g:vim_addon_manager')
endfunction

function vam#Addoption(option, default)
    if has_key(g:vim_addon_manager, a:option)
        " Old-style sets have priority
        return
    elseif exists('g:vam_'.tr(a:option, '-', '_'))
        let g:vim_addon_manager[a:option]=g:vam_{tr(a:option, '-', '_')}
    else
        let g:vim_addon_manager[a:option]=a:default
    endif
endfunction
@MarcWeber MarcWeber closed this Apr 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.