Skip to content

Instantly share code, notes, and snippets.

@ony
Created October 24, 2017 23:18
Show Gist options
  • Save ony/efd1de13181f4bcebaf5795a4ee46905 to your computer and use it in GitHub Desktop.
Save ony/efd1de13181f4bcebaf5795a4ee46905 to your computer and use it in GitHub Desktop.
" minautopac.vim
" Naïve autoload of packs
" See https://github.com/k-takata/minpac/issues/28
" And https://github.com/junegunn/vim-plug/blob/9813d5e/plug.vim#L271-L276
function! minautopac#add(repo, ...)
let l:opts = get(a:000, 0, {})
if has_key(l:opts, 'for')
let l:name = substitute(a:repo, '^.*/', '', '')
let l:ft = l:opts.for " TODO: support array
execut printf('autocmd FileType %s packadd %s', l:ft, l:name)
endif
endfunction
if exists('*minpac#init')
call minpac#init()
command! -nargs=+ -bar Plugin call minpac#add(<args>) | call minautopac#add(<args>)
else
" do nothing
command! -nargs=+ Plugin call minautopac#add(<args>)
endif
command! -bar PackUpdate packadd minpac | runtime minautopac.vim | call minpac#update()
command! -bar PackClean packadd minpac | runtime minautopac.vim | call minpac#clean()
runtime! OPT ftdetect/*.vim
augroup MinAutoPac
autocmd!
runtime! myplugins.vim
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment