Skip to content

Commit

Permalink
Merge pull request #40 from vim-denops/fix-address-issue
Browse files Browse the repository at this point in the history
Fix server issues caused by Async.Promise removal
  • Loading branch information
lambdalisue authored Apr 30, 2021
2 parents 3e9df48 + f37de43 commit fbb6dff
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ jobs:
version:
- head
- v0.4.4
exclude:
# It seems 'head' of Neovim for macOS/Windows
# are not available (HttpError: Not Found) is raised.
- os: macos-latest
version: head
- os: windows-latest
version: head
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 23 additions & 1 deletion autoload/denops/server.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
let s:STATUS_STOPPED = 'stopped'
let s:STATUS_RUNNING = 'running'
let s:status = s:STATUS_STOPPED

function! denops#server#start() abort
if s:status is# s:STATUS_RUNNING
call denops#debug('Servers are already running. Skip')
return
endif
let s:status = s:STATUS_RUNNING
call denops#server#channel#start({ address -> s:start_service(address) })
endfunction

function! denops#server#stop() abort
call denops#server#channel#stop()
call denops#server#service#stop()
call denops#server#channel#start({ address -> s:start_service(address) })
let s:status = s:STATUS_STOPPED
endfunction

function! denops#server#restart() abort
call denops#server#stop()
call denops#server#start()
endfunction

function! denops#server#status() abort
return s:status
endfunction

function! s:start_service(address) abort
Expand Down
14 changes: 11 additions & 3 deletions autoload/denops/server/channel.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ let s:vim_exiting = 0
let s:job = v:null

function! denops#server#channel#start(notify) abort
let ctx = {
\ 'notified': 0,
\ 'notify': a:notify,
\}
let args = [g:denops#server#channel#deno, 'run']
let args += g:denops#server#channel#deno_args
let args += [s:script]
Expand All @@ -13,7 +17,7 @@ function! denops#server#channel#start(notify) abort
\ 'env': {
\ 'NO_COLOR': 1,
\ },
\ 'on_stderr': funcref('s:on_stderr', [a:notify]),
\ 'on_stderr': funcref('s:on_stderr', [ctx]),
\ 'on_exit': funcref('s:on_exit'),
\ 'raw_options': raw_options,
\})
Expand All @@ -40,9 +44,13 @@ function! denops#server#channel#request(method, params) abort
return s:request(s:job, a:method, a:params)
endfunction

function! s:on_stderr(notify, data, ...) abort dict
function! s:on_stderr(ctx, data, ...) abort dict
if a:ctx.notified
return
endif
let address = substitute(a:data, '[\s\r\n]*$', '', '')
call a:notify(address)
let a:ctx.notified = 1
call a:ctx.notify(address)
call denops#debug(printf('channel server resolve: %s', address))
endfunction

Expand Down

0 comments on commit fbb6dff

Please sign in to comment.