diff options
-rw-r--r-- | installer/install-typescript-language-server.cmd | 15 | ||||
-rw-r--r-- | installer/install-typescript-language-server.sh | 20 | ||||
-rw-r--r-- | plugin/lsp_setup.vim | 38 |
3 files changed, 55 insertions, 18 deletions
diff --git a/installer/install-typescript-language-server.cmd b/installer/install-typescript-language-server.cmd new file mode 100644 index 0000000..e716a48 --- /dev/null +++ b/installer/install-typescript-language-server.cmd @@ -0,0 +1,15 @@ +@echo off + +cd %~dp0 +if exist "..\servers\typescript-language-server" rd /S /Q "..\servers\typescript-language-server" +md "..\servers\typescript-language-server" +cd "..\servers\typescript-language-server" +git clone https://github.com/theia-ide/typescript-language-server . +call yarn + +echo @echo off ^ + +node %%~dp0\server\lib\cli.js --stdio ^ + +> typescript-language-server.cmd + diff --git a/installer/install-typescript-language-server.sh b/installer/install-typescript-language-server.sh new file mode 100644 index 0000000..8b0cf7e --- /dev/null +++ b/installer/install-typescript-language-server.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) +[ -d ../servers/typescript-language-server ] && rm -rf ../servers/typescript-language-server +mkdir ../servers/typescript-language-server +cd ../servers/typescript-language-server +git clone https://github.com/theia-ide/typescript-language-server . +yarn +yarn build + +cat <<EOF > typescript-language-server +#!/bin/sh + +DIR=\$(cd \$(dirname \$0); pwd) +node \$DIR/server/lib/cli.js --stdio +EOF + +chmod +x typescript-language-server diff --git a/plugin/lsp_setup.vim b/plugin/lsp_setup.vim index 9deb09f..60abfa1 100644 --- a/plugin/lsp_setup.vim +++ b/plugin/lsp_setup.vim @@ -31,12 +31,12 @@ function! s:vimlsp_installer() abort if !has_key(s:settings, &filetype) return '' endif - let l:setting = s:settings[&filetype] - if empty(l:setting) + let l:server = s:settings[&filetype] + if empty(l:server) return '' endif let l:found = {} - for l:conf in l:setting + for l:conf in l:server let l:missing = 0 for l:require in l:conf.requires if !s:executable(l:require) @@ -52,20 +52,22 @@ function! s:vimlsp_installer() abort if empty(l:found) return '' endif - let l:command = s:vimlsp_settings_get(l:setting[0].command, 'cmd', l:setting[0].command) - if type(l:command) == type([]) - let l:command = l:command[0] - endif - let l:command = printf('%s/install-%s', s:installer_dir, l:command) - if has('win32') - let l:command = substitute(l:command, '/', '\', 'g') . '.cmd' - else - let l:command = l:command . '.sh' - endif - if !s:executable(l:command) - return '' - endif - return l:command + for l:conf in l:server + let l:command = s:vimlsp_settings_get(l:conf.command, 'cmd', l:conf.command) + if type(l:command) == type([]) + let l:command = l:command[0] + endif + let l:command = printf('%s/install-%s', s:installer_dir, l:command) + if has('win32') + let l:command = substitute(l:command, '/', '\', 'g') . '.cmd' + else + let l:command = l:command . '.sh' + endif + if s:executable(l:command) + return l:command + endif + endfor + return '' endfunction function! s:vimlsp_install_server() abort @@ -77,7 +79,7 @@ function! s:vimlsp_settings_suggest() abort if empty(s:vimlsp_installer()) return endif - echomsg printf("If you want to enable Language Server, please do :LspInstallServer") + echomsg printf('If you want to enable Language Server, please do :LspInstallServer') command! -buffer LspInstallServer call s:vimlsp_install_server() endfunction |