Skip to content

Commit e74bd3c

Browse files
authored
Fix ':LspStopServer' not working when enable native lsp client support (#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.
1 parent 8351fd3 commit e74bd3c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

autoload/lsp/client.vim

+15
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,20 @@ function! s:native_err_cb(cbctx, channel, response) abort
315315
endif
316316
endfunction
317317

318+
function! s:native_exit_cb(cbctx, channel, response) abort
319+
if !has_key(a:cbctx, 'ctx') | return | endif
320+
let l:ctx = a:cbctx['ctx']
321+
if has_key(l:ctx['opts'], 'on_exit')
322+
try
323+
call l:ctx['opts']['on_exit'](l:ctx['id'], a:response, 'exit')
324+
catch
325+
call lsp#log('s:on_exit exception', v:exception, v:throwpoint)
326+
echom v:exception
327+
endtry
328+
endif
329+
call s:dispose_context(l:ctx['id'])
330+
endfunction
331+
318332
" public apis {{{
319333

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

0 commit comments

Comments
 (0)