k-takata / minpac

A minimal package manager for Vim 8+ (and Neovim)
836 stars 30 forks source link

Specify minpac#add defaults in minpac#init #113

Closed averms closed 6 months ago

averms commented 4 years ago

I install all my plugins in opt so this would make it my init.vim cleaner :smile:.

I'm willing to submit a patch and I don't think it would be too complex: add a config key in minpac#init called 'defaults' and just extend it with the config specified in each minpac#add call.

It would turn this:

fun! MinpacInit() abort
    packadd minpac
    call minpac#init({'dir': $HOME . '/.local/share/nvim/site'})
    call minpac#add('k-takata/minpac',               {'type': 'opt'})
    call minpac#add('Shougo/neosnippet.vim',         {'type': 'opt'})
    call minpac#add('a-vrma/black-nvim',             {'type': 'opt'})
    ...
endfun

into this:

fun! MinpacInit() abort
    packadd minpac
    call minpac#init({'dir': $HOME . '/.local/share/nvim/site',
        \ 'defaults': {'type': 'opt'}})
    call minpac#add('k-takata/minpac')
    call minpac#add('Shougo/neosnippet.vim')
    call minpac#add('a-vrma/black-nvim')
    ...
endfun
averms commented 4 years ago

Just realized this is related to #68, in any case my solution was the following:

fun! s:pac_add(url, ...) abort
    " Wraps minpac#add with type: 'opt' as default.
    let l:options = get(a:000, 0, {})
    call minpac#add(a:url, extend({'type': 'opt'}, options, 'force'))
endfun