forked from vim-scripts/lodgeit.vim
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 84fa270
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
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
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. |
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
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>) |