Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added g:lsp_settings_use_install_file config. #779

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading