Skip to content

Commit

Permalink
Added g:lsp_settings_use_install_file config.
Browse files Browse the repository at this point in the history
Added a configuration where the installer looks for the installed files first.
  • Loading branch information
mikoto2000 committed Oct 18, 2024
1 parent 02cd145 commit 16aa3a7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
49 changes: 47 additions & 2 deletions autoload/lsp_settings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,35 @@ function! lsp_settings#get(name, key, default) abort
endfunction

function! lsp_settings#exec_path(cmd) abort

if get(g:, 'lsp_settings_use_install_file', 0) == 1
let l:exec_path = lsp_settings#find_from_install_dir(a:cmd)
if l:exec_path != ''
return l:exec_path
endif
endif

let l:exec_path = lsp_settings#find_from_path(a:cmd)
if l:exec_path != ''
return l:exec_path
endif

let l:exec_path = lsp_settings#find_from_extra_path(a:cmd)
if l:exec_path != ''
return l:exec_path
endif

if get(g:, 'lsp_settings_use_install_file', 0) == 0
let l:exec_path = lsp_settings#find_from_install_dir(a:cmd)
if l:exec_path != ''
return l:exec_path
endif
endif

return ''
endfunction

function! lsp_settings#find_from_path(cmd) abort
let l:paths = []
if has('win32')
for l:path in split($PATH, ';')
Expand All @@ -249,16 +278,32 @@ function! lsp_settings#exec_path(cmd) abort
endif
endfor
endif
return ''
endfunction

function! lsp_settings#find_from_extra_path(cmd) abort
let l:paths = get(g:, 'lsp_settings_extra_paths', '')
if type(l:paths) == type([])
let l:paths = join(l:paths, ',') . ','
endif
if !has('win32')
let l:paths .= lsp_settings#servers_dir() . '/' . a:cmd
return lsp_settings#utils#first_one(globpath(l:paths, a:cmd, 1))
endif
let l:paths .= lsp_settings#servers_dir() . '\' . a:cmd
for l:ext in ['.exe', '.cmd', '.bat']
let l:path = globpath(l:paths, a:cmd . l:ext, 1)
if !empty(l:path)
return lsp_settings#utils#first_one(l:path)
endif
endfor
return ''
endfunction

function! lsp_settings#find_from_install_dir(cmd) abort
if !has('win32')
let l:paths = lsp_settings#servers_dir() . '/' . a:cmd
return lsp_settings#utils#first_one(globpath(l:paths, a:cmd, 1))
endif
let l:paths = lsp_settings#servers_dir() . '\' . a:cmd
for l:ext in ['.exe', '.cmd', '.bat']
let l:path = globpath(l:paths, a:cmd . l:ext, 1)
if !empty(l:path)
Expand Down
7 changes: 7 additions & 0 deletions doc/vim-lsp-settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ g:lsp_settings_filetype_xxx
one element and type of the element is |function|, vim-lsp-settings call it
and the result is evaluated lazy.

*g:lsp_settings_use_install_file*
g:lsp_settings_use_install_file
Default: 0
Set 0 Look for the executable file in the PATH environment variable and
execute it first if found.
Set 1 vim-lsp-settings installed executable if available

:LspSettingsLocalEdit [root] *:LspSettingsLocalEdit*
Edit local settings. Accepts an optional explicit [root] directory that
contains the .vim-lsp-settings config directory.
Expand Down

0 comments on commit 16aa3a7

Please sign in to comment.