Skip to content

Instantly share code, notes, and snippets.

@veirus
Created March 31, 2020 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veirus/b17bd160cefbcab7b288b879b439f8fd to your computer and use it in GitHub Desktop.
Save veirus/b17bd160cefbcab7b288b879b439f8fd to your computer and use it in GitHub Desktop.
Quick add plugin from Github to your *.vimrc* or wherever you keep your plugins. Also minpac
command! -nargs=+ -bar Plug call minpac#add(<args>)
" quick add plugins for a minpac {{{1
function! AddPacFromCb(arg) abort
if v:version >= 801 || (v:version == 800 && has("patch1630"))
let l:cb = trim(@+)
else
" do oldschool way to trim all spaces and whatnot
let l:cb = substitute(@+,'\v^\s*(.{-})\s*\n$','\1','')
endif
let l:cb = substitute(l:cb, '\v^https://github.com/','','')
if a:arg
put = 'Plug ''' . l:cb . ''''
else
" without the `Plug` command
put = 'call minpac#add(''' . l:cb . ''')'
endif
endfunction
nnoremap <leader>v :call AddPacFromCb(1)<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment