Skip to content

Add support for Neovim #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions autoload/pydocstring.vim
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,44 @@ function! s:execute(cmd, lines, indent, start_lineno, cb, ex_cb) abort
echohl None
return
endif
if exists('s:job') && job_status(s:job) != 'stop'
call job_stop(s:job)
endif

let s:job = job_start(a:cmd, {
\ 'callback': {_, m -> a:cb(m, a:indent, a:start_lineno)},
\ 'exit_cb': {_, m -> a:ex_cb(m)},
\ 'in_mode': 'nl',
\ })
if has('nvim')
if exists('s:job')
call jobstop(s:job)
endif

let s:job = jobstart(a:cmd, {
\ 'on_stdout': {_c, m, _e -> a:cb(m, a:indent, a:start_lineno)},
\ 'on_stderr': {_c, m, _e -> a:cb(m, a:indent, a:start_lineno)},
\ 'on_exit': {_c, m, _e -> a:ex_cb(m)},
\ })

if exists('*chansend')
" Neovim >0.3.0
call chansend(s:job, a:lines)
call chanclose(s:job, 'stdin')
else
" Legacy API
call jobsend(s:job, a:lines)
call jobclose(s:job, 'stdin')
endif

let channel = job_getchannel(s:job)
if ch_status(channel) ==# 'open'
call ch_sendraw(channel, a:lines)
call ch_close_in(channel)
else
if exists('s:job') && job_status(s:job) != 'stop'
call job_stop(s:job)
endif

let s:job = job_start(a:cmd, {
\ 'callback': {_, m -> a:cb(m, a:indent, a:start_lineno)},
\ 'exit_cb': {_, m -> a:ex_cb(m)},
\ 'in_mode': 'nl',
\ })

let channel = job_getchannel(s:job)
if ch_status(channel) ==# 'open'
call ch_sendraw(channel, a:lines)
call ch_close_in(channel)
endif
endif
endfunction

Expand Down