Skip to content

Commit

Permalink
Merge pull request #4 from tuurep/neovim-support
Browse files Browse the repository at this point in the history
feat: NeoVim support
  • Loading branch information
jannis-baum authored Nov 9, 2023
2 parents e4f415d + c657c38 commit 7f763bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
This plugin connects Vim to [vivify Markdown
viewer](https://github.com/jannis-baum/vivify).

NeoVim is supported.

## Features

- all open viewers automatically update their content as you are editing it in Vim
Expand Down
13 changes: 11 additions & 2 deletions autoload/vivify.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
let s:viv_url = 'http://localhost:' . ($VIV_PORT == '' ? '31622' : $VIV_PORT)

" Note: nvim's jobstart isn't exactly a drop-in replacement for vim's job_start
" 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")
else
let s:job_start = function("job_start")
endif

function! s:post(data)
call job_start([
call s:job_start([
\ 'curl', '-X', 'POST', '-H', 'Content-type: application/json',
\ '--data', json_encode(a:data),
\ s:viv_url . '/viewer' . expand('%:p')
Expand All @@ -17,7 +25,8 @@ function! vivify#sync_cursor()
endfunction

function! vivify#open()
call job_start(
" Note: nvim's jobstart doesn't use these opt keys
call s:job_start(
\ ['viv', expand('%:p')],
\ {"in_io": "null", "out_io": "null", "err_io": "null"}
\)
Expand Down

0 comments on commit 7f763bc

Please sign in to comment.