aboutsummaryrefslogtreecommitdiff
path: root/autoload/lsp_settings.vim
diff options
context:
space:
mode:
authorYasuhiro Matsumoto <mattn.jp@gmail.com>2019-12-16 11:37:14 +0900
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2019-12-16 11:37:14 +0900
commit2e1943c52511fc7e10c5314177b4fd23d705479e (patch)
tree4da4f600f844812a8ab10c776535309b43263c18 /autoload/lsp_settings.vim
parent0c3c00284f682d21a9f78fc7fe39f3b230060d89 (diff)
downloadvim-lsp-settings-2e1943c52511fc7e10c5314177b4fd23d705479e.tar.gz
vim-lsp-settings-2e1943c52511fc7e10c5314177b4fd23d705479e.tar.bz2
vim-lsp-settings-2e1943c52511fc7e10c5314177b4fd23d705479e.zip
Use first_one
Diffstat (limited to 'autoload/lsp_settings.vim')
-rw-r--r--autoload/lsp_settings.vim26
1 files changed, 21 insertions, 5 deletions
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