Fix npm (un)install with whitespace paths

This commit is contained in:
Dominic Della Valle
2021-05-30 10:59:49 -04:00
committed by mattn
parent faa4d2c14a
commit 104d20f4fe
2 changed files with 12 additions and 5 deletions

View File

@@ -188,10 +188,11 @@ function! lsp_settings#exec_path(cmd) abort
if type(l:paths) == type([])
let l:paths = join(l:paths, ',') . ','
endif
let l:paths .= lsp_settings#servers_dir() . '/' . a:cmd
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)
@@ -298,6 +299,9 @@ function! s:vim_lsp_uninstall_server(command) abort
endif
call lsp_settings#utils#msg('Uninstalling ' . a:command)
let l:server_install_dir = lsp_settings#servers_dir() . '/' . a:command
if has('win32')
let l:server_install_dir = substitute(l:server_install_dir, '/', '\', 'g')
endif
if !isdirectory(l:server_install_dir)
call lsp_settings#utils#error('Server not found')
return
@@ -345,6 +349,9 @@ function! s:vim_lsp_install_server(ft, command, bang) abort
return
endif
let l:server_install_dir = lsp_settings#servers_dir() . '/' . l:entry[0]
if has('win32')
let l:server_install_dir = substitute(l:server_install_dir, '/', '\', 'g')
endif
if isdirectory(l:server_install_dir)
call lsp_settings#utils#msg('Uninstalling ' . l:entry[0])
call delete(l:server_install_dir, 'rf')
@@ -353,9 +360,9 @@ function! s:vim_lsp_install_server(ft, command, bang) abort
call lsp_settings#utils#msg('Installing ' . l:entry[0])
if has('nvim')
split new
call termopen(l:entry[1], {'cwd': l:server_install_dir, 'on_exit': function('s:vim_lsp_install_server_post', [l:entry[0]])}) | startinsert
call termopen(shellescape(l:entry[1]), {'cwd': l:server_install_dir, 'on_exit': function('s:vim_lsp_install_server_post', [l:entry[0]])}) | startinsert
else
let l:bufnr = term_start(l:entry[1], {'cwd': l:server_install_dir})
let l:bufnr = term_start(shellescape(l:entry[1]), {'cwd': l:server_install_dir})
let l:job = term_getjob(l:bufnr)
if l:job != v:null
call job_setoptions(l:job, {'exit_cb': function('s:vim_lsp_install_server_post', [l:entry[0]])})

View File

@@ -14,6 +14,6 @@ call npm install "%2"
echo @echo off ^
call %%~dp0\node_modules\.bin\%1.cmd %%* ^
call ^"%%~dp0\node_modules\.bin\%1.cmd^" %%* ^
> %1.cmd
> "%1.cmd"