Skip to content

Commit 16aa3a7

Browse files
committed
Added g:lsp_settings_use_install_file config.
Added a configuration where the installer looks for the installed files first.
1 parent 02cd145 commit 16aa3a7

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

autoload/lsp_settings.vim

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,35 @@ function! lsp_settings#get(name, key, default) abort
223223
endfunction
224224

225225
function! lsp_settings#exec_path(cmd) abort
226+
227+
if get(g:, 'lsp_settings_use_install_file', 0) == 1
228+
let l:exec_path = lsp_settings#find_from_install_dir(a:cmd)
229+
if l:exec_path != ''
230+
return l:exec_path
231+
endif
232+
endif
233+
234+
let l:exec_path = lsp_settings#find_from_path(a:cmd)
235+
if l:exec_path != ''
236+
return l:exec_path
237+
endif
238+
239+
let l:exec_path = lsp_settings#find_from_extra_path(a:cmd)
240+
if l:exec_path != ''
241+
return l:exec_path
242+
endif
243+
244+
if get(g:, 'lsp_settings_use_install_file', 0) == 0
245+
let l:exec_path = lsp_settings#find_from_install_dir(a:cmd)
246+
if l:exec_path != ''
247+
return l:exec_path
248+
endif
249+
endif
250+
251+
return ''
252+
endfunction
253+
254+
function! lsp_settings#find_from_path(cmd) abort
226255
let l:paths = []
227256
if has('win32')
228257
for l:path in split($PATH, ';')
@@ -249,16 +278,32 @@ function! lsp_settings#exec_path(cmd) abort
249278
endif
250279
endfor
251280
endif
281+
return ''
282+
endfunction
252283

284+
function! lsp_settings#find_from_extra_path(cmd) abort
253285
let l:paths = get(g:, 'lsp_settings_extra_paths', '')
254286
if type(l:paths) == type([])
255287
let l:paths = join(l:paths, ',') . ','
256288
endif
257289
if !has('win32')
258-
let l:paths .= lsp_settings#servers_dir() . '/' . a:cmd
259290
return lsp_settings#utils#first_one(globpath(l:paths, a:cmd, 1))
260291
endif
261-
let l:paths .= lsp_settings#servers_dir() . '\' . a:cmd
292+
for l:ext in ['.exe', '.cmd', '.bat']
293+
let l:path = globpath(l:paths, a:cmd . l:ext, 1)
294+
if !empty(l:path)
295+
return lsp_settings#utils#first_one(l:path)
296+
endif
297+
endfor
298+
return ''
299+
endfunction
300+
301+
function! lsp_settings#find_from_install_dir(cmd) abort
302+
if !has('win32')
303+
let l:paths = lsp_settings#servers_dir() . '/' . a:cmd
304+
return lsp_settings#utils#first_one(globpath(l:paths, a:cmd, 1))
305+
endif
306+
let l:paths = lsp_settings#servers_dir() . '\' . a:cmd
262307
for l:ext in ['.exe', '.cmd', '.bat']
263308
let l:path = globpath(l:paths, a:cmd . l:ext, 1)
264309
if !empty(l:path)

doc/vim-lsp-settings.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,13 @@ g:lsp_settings_filetype_xxx
172172
one element and type of the element is |function|, vim-lsp-settings call it
173173
and the result is evaluated lazy.
174174

175+
*g:lsp_settings_use_install_file*
176+
g:lsp_settings_use_install_file
177+
Default: 0
178+
Set 0 Look for the executable file in the PATH environment variable and
179+
execute it first if found.
180+
Set 1 vim-lsp-settings installed executable if available
181+
175182
:LspSettingsLocalEdit [root] *:LspSettingsLocalEdit*
176183
Edit local settings. Accepts an optional explicit [root] directory that
177184
contains the .vim-lsp-settings config directory.

0 commit comments

Comments
 (0)