From c972a43e49fa8b25b34254c73b6bea30ca5fc2fc Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sun, 15 Dec 2019 15:31:44 +0900 Subject: Check requires --- plugin/lsp_setup.vim | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'plugin') diff --git a/plugin/lsp_setup.vim b/plugin/lsp_setup.vim index 91499b6..59c6fcb 100644 --- a/plugin/lsp_setup.vim +++ b/plugin/lsp_setup.vim @@ -3,10 +3,28 @@ let s:installer_dir = expand(':h:h').'/installer' let s:setting = json_decode(join(readfile(expand(':h:h').'/setting.json'), "\n")) function! s:vimlsp_installer() - if empty(s:setting[&filetype]) + let l:setting = s:setting[&filetype] + if empty(l:setting) return '' endif - let l:command = printf('%s/install-%s', s:installer_dir, s:setting[&filetype][0].command) + let l:found = {} + for l:conf in l:setting + let l:missing = 0 + for l:require in l:conf.requires + if !executable(l:require) + let l:missing = 1 + break + endif + endfor + if l:missing == 0 + let l:found = l:conf + break + endif + endfor + if empty(l:found) + return '' + endif + let l:command = printf('%s/install-%s', s:installer_dir, l:setting[0].command) if has('win32') let l:command = substitute(l:command, '/', '\', 'g') . '.cmd' else -- cgit v1.2.3-54-g00ecf