" | |
" Plugin: VimGist | |
" Author: SegPhault (Ryan Paul) - 12/08/2008 | |
" Description: This plugin integrates support for GitHub Gist in Vim | |
" | |
python << EOF | |
import vim, sys, os.path | |
sys.path.append("/home/segphault/project/utilities/gist") | |
import gist | |
EOF | |
function! GistComplete(arglead, cmdline, cursorpos) | |
python vim.command("return %s" % repr([str("%s %s" % ( | |
\ g["repo"], g["description"] or "")) for g in gist.user(gist.LOGIN) | |
\ if g["repo"].startswith(vim.eval("a:arglead"))])) | |
endfun | |
command! -nargs=* -complete=customlist,GistComplete GistPaste | |
\ :python vim.command("append\n%s\n.\n" % ( | |
\ gist.get("<args>".split()[0]).replace("\r", ""))) | |
command! -nargs=? -range=% GistPostSelection | |
\ :python vim.command("let @+ = '%s/%s'" % (gist.BASE_URL, gist.new( | |
\ {os.path.basename(vim.current.buffer.name): | |
\ "\n".join(vim.current.buffer[<line1>:<line2>])}, description="<args>", | |
\ login=gist.LOGIN, token=gist.TOKEN)["repo"])) |