Add Plugin from Clipboard

1 Point

Alex Alex

2 weeks ago

Convert github url in the Plug 'author/name' statement.

" 'Unify' all plugin managers under the `Plug` command
command! -nargs=+ -bar Plug call minpac#add(<args>)

function! AddPacFromCb(...) 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:0
		put = 'Plug ''' . l:cb . ''''
	else
		return 'Plug ''' . l:cb . ''''
	endif
endfunction
nnoremap <leader>l :call AddPacFromCb(1)<CR>
iabbr plu <C-R>=AddPacFromCb()<CR>