Skip to content

Commit

Permalink
Fix ':LspStopServer' not working when enable native lsp client support (
Browse files Browse the repository at this point in the history
#1473)

When set `let g:lsp_use_native_client = 1` to enable native lsp client support,
if call `:LspStopServer` to stop the lsp server, the server stopped but the
status still show it as `running` by `:LspStatus`, this patch try to fix
this issue.
  • Loading branch information
zbinlin authored May 15, 2023
1 parent 8351fd3 commit e74bd3c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions autoload/lsp/client.vim
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ function! s:native_err_cb(cbctx, channel, response) abort
endif
endfunction

function! s:native_exit_cb(cbctx, channel, response) abort
if !has_key(a:cbctx, 'ctx') | return | endif
let l:ctx = a:cbctx['ctx']
if has_key(l:ctx['opts'], 'on_exit')
try
call l:ctx['opts']['on_exit'](l:ctx['id'], a:response, 'exit')
catch
call lsp#log('s:on_exit exception', v:exception, v:throwpoint)
echom v:exception
endtry
endif
call s:dispose_context(l:ctx['id'])
endfunction

" public apis {{{

function! lsp#client#start(opts) abort
Expand All @@ -324,6 +338,7 @@ function! lsp#client#start(opts) abort
let l:jobopt = { 'in_mode': 'lsp', 'out_mode': 'lsp', 'noblock': 1,
\ 'out_cb': function('s:native_out_cb', [l:cbctx]),
\ 'err_cb': function('s:native_err_cb', [l:cbctx]),
\ 'exit_cb': function('s:native_exit_cb', [l:cbctx]),
\ }
if has_key(a:opts, 'cwd') | let l:jobopt['cwd'] = a:opts['cwd'] | endif
if has_key(a:opts, 'env') | let l:jobopt['env'] = a:opts['env'] | endif
Expand Down

0 comments on commit e74bd3c

Please sign in to comment.