Skip to content

Commit 6fb6fa2

Browse files
authored
Merge pull request #92 from vimark1/patch-1
add support for neovim fix
2 parents ca3c880 + 56ca8ad commit 6fb6fa2

File tree

3 files changed

+52
-13
lines changed

3 files changed

+52
-13
lines changed

.travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ jobs:
2727
script:
2828
- cd $HOME/build/heavenshell/vim-jsdoc/tests
2929
- VIM_EXE=$HOME/bin/vim/bin/vim ./run.sh
30+
31+
- env: ENV="Neovim"
32+
install:
33+
- mkdir -p ~/tmp/nvim/bin
34+
- curl -L https://github.com/neovim/neovim/releases/download/v0.4.3/nvim.appimage -o ~/tmp/nvim/bin/nvim
35+
- chmod u+x ~/tmp/nvim/bin/nvim
36+
37+
before_script:
38+
- cd $HOME/build/heavenshell/vim-jsdoc
39+
- make install
40+
41+
script:
42+
- cd $HOME/build/heavenshell/vim-jsdoc/tests
43+
- VIM_EXE=$HOME/tmp/nvim/bin/nvim ./run.sh

autoload/jsdoc.vim

+33-13
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ function! s:exit_callback(msg) abort
9393
if len(s:results)
9494
let view = winsaveview()
9595
silent execute '% delete'
96-
call setline(1, s:results)
96+
if has('nvim')
97+
" the -2 slicing is required to remove an extra new line
98+
call setline(1, s:results[0][:-2])
99+
else
100+
call setline(1, s:results)
101+
endif
97102
call winrestview(view)
98103
endif
99104

@@ -106,20 +111,35 @@ function! s:exit_callback(msg) abort
106111
endfunction
107112

108113
function! s:vim.execute(cmd, lines, start_lineno, is_method, cb, ex_cb) dict
109-
if exists('s:job') && job_status(s:job) != 'stop'
110-
call job_stop(s:job)
111-
endif
114+
if has('nvim')
115+
if exists('s:job') && jobwait([s:job], 0)[0] == -1
116+
call jobstop(s:job)
117+
endif
112118

113-
let s:job = job_start(a:cmd, {
114-
\ 'callback': {_, m -> a:cb(m, a:start_lineno, a:is_method)},
115-
\ 'exit_cb': {_, m -> a:ex_cb(m)},
116-
\ 'in_mode': 'nl',
117-
\ })
119+
let s:job = jobstart(a:cmd, {
120+
\ 'on_stdout': {_, m -> a:cb(m, a:start_lineno, a:is_method)},
121+
\ 'on_exit': {_, m -> a:ex_cb(m)},
122+
\ 'stdout_buffered': 1,
123+
\ })
124+
125+
call chansend(s:job, a:lines)
126+
call chanclose(s:job, 'stdin')
127+
elseif v:version >= 800 && !has('nvim')
128+
if exists('s:job') && job_status(s:job) != 'dead'
129+
call job_stop(s:job)
130+
endif
131+
132+
let s:job = job_start(a:cmd, {
133+
\ 'callback': {_, m -> a:cb(m, a:start_lineno, a:is_method)},
134+
\ 'exit_cb': {_, m -> a:ex_cb(m)},
135+
\ 'in_mode': 'nl',
136+
\ })
118137

119-
let channel = job_getchannel(s:job)
120-
if ch_status(channel) ==# 'open'
121-
call ch_sendraw(channel, a:lines)
122-
call ch_close_in(channel)
138+
let channel = job_getchannel(s:job)
139+
if ch_status(channel) ==# 'open'
140+
call ch_sendraw(channel, a:lines)
141+
call ch_close_in(channel)
142+
endif
123143
endif
124144
endfunction
125145

tests/run.sh

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/sh
22
: "${VIM_EXE:=vim}"
33

4+
# download test dependency if needed
5+
if [[ ! -d "./vader.vim" ]]; then
6+
git clone https://github.com/junegunn/vader.vim.git vader.vim
7+
fi
8+
49
# If nvim is available in PATH, then we prefer to use nvim
510
# since it works better with nodemon
611
if hash nvim 2>/dev/null ; then

0 commit comments

Comments
 (0)