1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:20:04 +08:00

feat(lsp): support #{cwd} for the current working directory

* In lsp config replace #{cwd} for the current working directory.

* Fix bug introduced by renaming a variable

Co-authored-by: Alessio Linares <alessio.linares@king.com>
This commit is contained in:
Alessio Linares 2022-04-22 06:14:16 +02:00 committed by GitHub
parent 4b617500ec
commit 0a1af5b6bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -258,15 +258,23 @@ function! SpaceVim#layers#lsp#set_variable(var) abort
if !empty(override)
call extend(s:lsp_servers, override, 'force')
endif
let l:cwd = getcwd()
for ft in get(a:var, 'filetypes', [])
let cmd = get(s:lsp_servers, ft, [''])[0]
if empty(cmd)
let l:cmds = get(s:lsp_servers, ft, [''])
let l:exec = l:cmds[0]
if empty(l:exec)
call SpaceVim#logger#warn('Failed to find the lsp server command for ' . ft)
else
if executable(cmd)
if executable(l:exec)
call add(s:enabled_fts, ft)
let l:newcmds = []
for l:cmd in l:cmds
let l:newcmd = substitute(l:cmd, '#{cwd}', l:cwd, 'g')
call add(l:newcmds, l:newcmd)
endfor
let s:lsp_servers[ft] = l:newcmds
else
call SpaceVim#logger#warn('Failed to enable lsp for ' . ft . ', ' . cmd . ' is not executable!')
call SpaceVim#logger#warn('Failed to enable lsp for ' . ft . ', ' . l:exec . ' is not executable!')
endif
endif
endfor