From 2e1943c52511fc7e10c5314177b4fd23d705479e Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 16 Dec 2019 11:37:14 +0900 Subject: Use first_one --- autoload/lsp_settings.vim | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'autoload') diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index 3514b3f..80c8ceb 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -24,9 +24,25 @@ function! s:first_one(cmd) abort endfunction function! lsp_settings#exec_path(cmd) abort - if executable(a:cmd) - return a:cmd + let l:paths = split($PATH, has('win32') ? ';' : ':') + let l:paths = join(l:paths, ',') + let l:path = globpath(l:paths, a:cmd) + if !has('win32') + return s:first_one(globpath(l:paths, a:cmd)) + endif + let l:path = globpath(l:paths, a:cmd . '.exe') + if !empty(l:path) + return s:first_one(l:path) + endif + let l:path = globpath(l:paths, a:cmd . '.cmd') + if !empty(l:path) + return s:first_one(l:path) + endif + let l:path = globpath(l:paths, a:cmd . '.bat') + if !empty(l:path) + return s:first_one(l:path) endif + let l:paths = get(g:, 'lsp_settings_extra_paths', '') if type(l:paths) == type([]) let l:paths = join(l:paths, ',') @@ -37,15 +53,15 @@ function! lsp_settings#exec_path(cmd) abort endif let l:path = globpath(l:paths, a:cmd . '.exe') if !empty(l:path) - return l:path + return s:first_one(l:path) endif let l:path = globpath(l:paths, a:cmd . '.cmd') if !empty(l:path) - return l:path + return s:first_one(l:path) endif let l:path = globpath(l:paths, a:cmd . '.bat') if !empty(l:path) - return l:path + return s:first_one(l:path) endif return '' endfunction -- cgit v1.2.3-54-g00ecf