Handle dependency error in a better way (#346)

If server is found, but dependencies are no found, then currently
"Server not found" is shown, making user clueless. This commit tries to
inform the user that server was found, but dependencies were not
satisfied.
This commit is contained in:
Subhaditya Nath
2020-11-30 07:20:05 +05:30
committed by GitHub
parent 753322a2c9
commit 10799e046b
2 changed files with 13 additions and 1 deletions

View File

@@ -105,6 +105,7 @@ function! s:vim_lsp_installer(ft, ...) abort
let l:missing = 0
for l:require in l:conf.requires
if !lsp_settings#executable(l:require)
call lsp_settings#utils#warning(l:conf.command . ' requires ' . l:require)
let l:missing = 1
break
endif
@@ -116,7 +117,7 @@ function! s:vim_lsp_installer(ft, ...) abort
return [l:conf.command, l:command]
endif
endfor
return []
return [v:false] " placeholder, so that empty() returns false, but len() < 2 returns true
endfunction
function! lsp_settings#server_config(name) abort
@@ -336,6 +337,10 @@ function! s:vim_lsp_install_server(ft, command, bang) abort
call lsp_settings#utils#error('Server not found')
return
endif
if len(l:entry) < 2
call lsp_settings#utils#error('Server could not be installed. See :messages for details.')
return
endif
if empty(a:bang) && confirm(printf('Install %s ?', l:entry[0]), "&Yes\n&Cancel") !=# 1
return
endif

View File

@@ -5,6 +5,13 @@ function! lsp_settings#utils#msg(msg) abort
echohl None
endfunction
function! lsp_settings#utils#warning(msg) abort
redraw
echohl WarningMsg
echomsg a:msg
echohl None
endfunction
function! lsp_settings#utils#error(msg) abort
redraw
echohl Error