Skip to content

Commit

Permalink
Version 0.1: Initial upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko authored and vim-scripts committed Oct 18, 2010
0 parents commit 84fa270
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1965

Just do :Lodgeit to paste the file or selection.
65 changes: 65 additions & 0 deletions plugin/lodgeit.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
" lodgeit.vim: Vim plugin for paste.pocoo.org
" Maintainer: Armin Ronacher <[email protected]>
" Version: 0.1

" Usage:
" :Lodgeit create a paste from the current buffer of selection
"
" If you want to paste on ctrl + p just add this to your vimrc:
" map ^P :Lodgeit<CR>
" (where ^P is entered using ctrl + v, ctrl + p in vim)

function! s:Lodgeit(line1,line2,count)
python << EOF

import vim
from xmlrpclib import ServerProxy
pastes = ServerProxy('http://paste.pocoo.org/xmlrpc/').pastes

rng_start = int(vim.eval('a:line1')) - 1
rng_end = int(vim.eval('a:line2'))
rng_count = int(vim.eval('a:count'))
if rng_count:
code = '\n'.join(vim.current.buffer[rng_start:rng_end])
else:
code = '\n'.join(vim.current.buffer)

lng_code = {
'python': 'python',
'php': 'html+php',
'smarty': 'smarty',
'tex': 'tex',
'rst': 'rst',
'cs': 'csharp',
'haskell': 'haskell',
'xml': 'xml',
'html': 'html',
'xhtml': 'html',
'htmldjango': 'html+django',
'django': 'html+django',
'htmljinja': 'html+django',
'jinja': 'html+django',
'lua': 'lua',
'scheme': 'scheme',
'mako': 'html+mako',
'c': 'c',
'cpp': 'cpp',
'javascript': 'js',
'jsp': 'jsp',
'ruby': 'ruby',
'bash': 'bash',
'bat': 'bat',
'd': 'd',
'genshi': 'html+genshi'
}.get(vim.eval('&ft'), 'text')

paste_id = pastes.newPaste(lng_code, code)
url = 'http://paste.pocoo.org/show/%d' % paste_id

print 'Pasted #%d to %s' % (paste_id, url)
vim.command(':call setreg(\'+\', %r)' % url)

EOF
endfunction

command! -range=0 Lodgeit :call s:Lodgeit(<line1>,<line2>,<count>)

0 comments on commit 84fa270

Please sign in to comment.