Skip to content

Commit 80ec75e

Browse files
authored
Export root_uri resolved (#729)
* Export root_uri resolved * Avoid uninitialized
1 parent 6f3d2d4 commit 80ec75e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

autoload/lsp.vim

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ function! lsp#get_server_info(server_name) abort
8585
return s:servers[a:server_name]['server_info']
8686
endfunction
8787

88+
function! lsp#get_server_root_uri(server_name) abort
89+
return get(s:servers[a:server_name]['server_info'], '_root_uri_resolved', '')
90+
endfunction
91+
8892
function! lsp#get_server_capabilities(server_name) abort
8993
let l:server = s:servers[a:server_name]
9094
return has_key(l:server, 'init_result') ? l:server['init_result']['result']['capabilities'] : {}
@@ -514,18 +518,13 @@ function! s:ensure_init(buf, server_name, cb) abort
514518
" server has already started, but not initialized
515519

516520
let l:server_info = l:server['server_info']
517-
if has_key(l:server_info, 'root_uri')
518-
let l:root_uri = l:server_info['root_uri'](l:server_info)
519-
else
520-
let l:root_uri = lsp#utils#get_default_root_uri()
521-
endif
522-
521+
let l:root_uri = has_key(l:server_info, 'root_uri') ? l:server_info['root_uri'](l:server_info) : ''
523522
if empty(l:root_uri)
524523
let l:msg = s:new_rpc_error('ignore initialization lsp server due to empty root_uri', { 'server_name': a:server_name, 'lsp_id': l:server['lsp_id'] })
525524
call lsp#log(l:msg)
526-
call a:cb(l:msg)
527-
return
525+
let l:root_uri = lsp#utils#get_default_root_uri()
528526
endif
527+
let l:server['server_info']['_root_uri_resolved'] = l:root_uri
529528

530529
if has_key(l:server_info, 'capabilities')
531530
let l:capabilities = l:server_info['capabilities']

0 commit comments

Comments
 (0)