Created
December 9, 2008 08:25
-
-
Save segphault/33842 to your computer and use it in GitHub Desktop.
VimGist - a plugin that integrates support for GitHub Gist in Vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
" 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"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment