Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
86 lines
2.6 KiB
VimL
86 lines
2.6 KiB
VimL
"=============================================================================
|
|
" pastebin.vim --- Pastebin support for SpaceVim
|
|
" Copyright (c) 2016-2023 Wang Shidong & Contributors
|
|
" Author: Wang Shidong < wsdjeg@outlook.com >
|
|
" URL: https://spacevim.org
|
|
" License: GPLv3
|
|
"=============================================================================
|
|
|
|
if has('nvim-0.9.0')
|
|
function! SpaceVim#plugins#pastebin#paste() abort
|
|
lua require('spacevim.plugin.pastebin').paste()
|
|
endfunction
|
|
finish
|
|
endif
|
|
|
|
|
|
let s:JOB = SpaceVim#api#import('job')
|
|
let s:LOGGER =SpaceVim#logger#derive('pastebin')
|
|
let s:job_id = -1
|
|
|
|
function! SpaceVim#plugins#pastebin#paste() abort
|
|
let s:url = ''
|
|
let context = s:get_visual_selection()
|
|
if empty(context)
|
|
call s:LOGGER.info('no selection text, skipped.')
|
|
return
|
|
endif
|
|
" let ft = &filetype
|
|
if s:job_id != -1
|
|
call s:LOGGER.info('previous job has not been finished, killed!')
|
|
call s:JOB.stop(s:job_id)
|
|
endif
|
|
let cmd = 'curl -s -F "content=<-" http://dpaste.com/api/v2/'
|
|
let s:job_id = s:JOB.start(cmd,{
|
|
\ 'on_stdout' : function('s:on_stdout'),
|
|
\ 'on_stderr' : function('s:on_stderr'),
|
|
\ 'on_exit' : function('s:on_exit'),
|
|
\ })
|
|
call s:LOGGER.info('job id: '. s:job_id)
|
|
call s:JOB.send(s:job_id, split(context, "\n"))
|
|
call s:JOB.chanclose(s:job_id, 'stdin')
|
|
endfunction
|
|
function! s:on_stdout(job_id, data, event) abort
|
|
for url in filter(a:data, '!empty(v:val)')
|
|
call s:LOGGER.info('stdout: '. url)
|
|
let s:url = url
|
|
endfor
|
|
endfunction
|
|
|
|
function! s:on_stderr(job_id, data, event) abort
|
|
call s:LOGGER.warn('stderr:' . string(a:data))
|
|
endfunction
|
|
|
|
function! s:on_exit(job_id, data, event) abort
|
|
let s:job_id = -1
|
|
if a:data ==# 0 && !empty(s:url)
|
|
let @+ = s:url . '.txt'
|
|
echo 'Pastbin: ' . s:url . '.txt'
|
|
else
|
|
call s:LOGGER.warn('exit code: ' . string(a:data))
|
|
call s:LOGGER.warn('url: ' . s:url)
|
|
endif
|
|
endfunction
|
|
|
|
" ref: https://stackoverflow.com/a/6271254
|
|
function! s:get_visual_selection() abort
|
|
" Why is this not a built-in Vim script function?!
|
|
let [line_start, column_start] = getpos("'<")[1:2]
|
|
let [line_end, column_end] = getpos("'>")[1:2]
|
|
let lines = getline(line_start, line_end)
|
|
if len(lines) == 0
|
|
return ''
|
|
endif
|
|
" check v-block mode
|
|
if visualmode() ==# "\<C-v>"
|
|
for i in range(len(lines))
|
|
let lines[i] = lines[i][: column_end - (&selection ==# 'inclusive' ? 1 : 2)]
|
|
let lines[i] = lines[i][column_start - 1:]
|
|
endfor
|
|
else
|
|
let lines[-1] = lines[-1][: column_end - (&selection ==# 'inclusive' ? 1 : 2)]
|
|
let lines[0] = lines[0][column_start - 1:]
|
|
endif
|
|
return join(lines, "\n")
|
|
endfunction
|