Skip to content

Commit

Permalink
Merge pull request #15 from jannis-baum/issue/7-curl-data-without-arg…
Browse files Browse the repository at this point in the history
…ument

`curl` data without argument
  • Loading branch information
jannis-baum authored Jul 28, 2024
2 parents 8114625 + 58421d0 commit e5a4f4a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions autoload/vivify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@ let s:viv_url = 'http://localhost:' . ($VIV_PORT == '' ? '31622' : $VIV_PORT)
" See here: https://stackoverflow.com/questions/74999614/difference-between-vims-job-start-function-and-neovims-jobstart-functi
if has("nvim")
let s:job_start = function("jobstart")

" job is job_id as returned from jobstart()
function! s:stdin_send_and_close(job, data)
call chansend(a:job, a:data)
call chanclose(a:job, 'stdin')
endfunction
else
" job is job object as returned from job_start()
function! s:stdin_send_and_close(job, data)
let l:channel = job_getchannel(a:job)
call ch_sendraw(l:channel, a:data)
call ch_close_in(l:channel)
endfunction

let s:job_start = function("job_start")
endif

function! s:post(data)
call s:job_start([
\ 'curl', '-X', 'POST', '-H', 'Content-type: application/json',
\ '--data', json_encode(a:data),
let l:job = s:job_start([
\ 'curl',
\ '-X', 'POST',
\ '-H', 'Content-type: application/json',
\ '--data', '@-',
\ s:viv_url . '/viewer' . expand('%:p')
\])
call s:stdin_send_and_close(l:job, json_encode(a:data))
endfunction

function! vivify#sync_content()
Expand Down

0 comments on commit e5a4f4a

Please sign in to comment.