diff options
author | wordi <wordijp@gmail.com> | 2020-01-03 14:44:12 +0900 |
---|---|---|
committer | wordi <wordijp@gmail.com> | 2020-01-03 14:56:22 +0900 |
commit | 24de62683bbe337b4389cb57d48eb68c9afcf4ea (patch) | |
tree | 2141a1d1082b061a3f991a8e63d5f308488b71d4 | |
parent | ac4f61f82fd8d0c4b0cbabd4e364dced0c72c645 (diff) | |
download | vim-lsp-settings-24de62683bbe337b4389cb57d48eb68c9afcf4ea.tar.gz vim-lsp-settings-24de62683bbe337b4389cb57d48eb68c9afcf4ea.tar.bz2 vim-lsp-settings-24de62683bbe337b4389cb57d48eb68c9afcf4ea.zip |
fix: not found tsserver for typescript-language-server
-rw-r--r-- | autoload/lsp_settings.vim | 22 | ||||
-rw-r--r-- | installer/npm_install.cmd | 8 | ||||
-rw-r--r-- | settings/typescript-language-server.vim | 2 |
3 files changed, 20 insertions, 12 deletions
diff --git a/autoload/lsp_settings.vim b/autoload/lsp_settings.vim index f8c145d..ce3d09c 100644 --- a/autoload/lsp_settings.vim +++ b/autoload/lsp_settings.vim @@ -24,23 +24,27 @@ function! s:first_one(cmd) abort endfunction function! lsp_settings#exec_path(cmd) abort + let l:s= split(a:cmd, '/') + let l:dir = len(l:s) >= 1 ? l:s[0] : '' + let l:cmd = len(l:s) >= 2 ? l:s[1] : l:s[0] + let l:paths = split($PATH, has('win32') ? ';' : ':') let l:paths = join(l:paths, ',') - let l:path = globpath(l:paths, a:cmd) + let l:path = globpath(l:paths, l:cmd) if !has('win32') if !empty(l:path) return s:first_one(l:path) endif else - let l:path = globpath(l:paths, a:cmd . '.exe') + let l:path = globpath(l:paths, l:cmd . '.exe') if !empty(l:path) return s:first_one(l:path) endif - let l:path = globpath(l:paths, a:cmd . '.cmd') + let l:path = globpath(l:paths, l:cmd . '.cmd') if !empty(l:path) return s:first_one(l:path) endif - let l:path = globpath(l:paths, a:cmd . '.bat') + let l:path = globpath(l:paths, l:cmd . '.bat') if !empty(l:path) return s:first_one(l:path) endif @@ -51,19 +55,19 @@ function! lsp_settings#exec_path(cmd) abort let l:paths = join(l:paths, ',') . ',' endif let l:servers_dir = get(g:, 'lsp_settings_servers_dir', s:servers_dir) - let l:paths .= l:servers_dir . '/' . a:cmd + let l:paths .= l:servers_dir . '/' . l:dir if !has('win32') - return s:first_one(globpath(l:paths, a:cmd)) + return s:first_one(globpath(l:paths, l:cmd)) endif - let l:path = globpath(l:paths, a:cmd . '.exe') + let l:path = globpath(l:paths, l:cmd . '.exe') if !empty(l:path) return s:first_one(l:path) endif - let l:path = globpath(l:paths, a:cmd . '.cmd') + let l:path = globpath(l:paths, l:cmd . '.cmd') if !empty(l:path) return s:first_one(l:path) endif - let l:path = globpath(l:paths, a:cmd . '.bat') + let l:path = globpath(l:paths, l:cmd . '.bat') if !empty(l:path) return s:first_one(l:path) endif diff --git a/installer/npm_install.cmd b/installer/npm_install.cmd index 5f1d9bb..12347e2 100644 --- a/installer/npm_install.cmd +++ b/installer/npm_install.cmd @@ -3,9 +3,13 @@ if "x%1" equ "x" goto :EOF
if "x%2" equ "x" goto :EOF
-call npm init -y
+if not exist package.json (
+
+ call npm init -y
+
+ echo {"name":""}>package.json
+)
-echo {"name":""}>package.json
call npm install "%2"
diff --git a/settings/typescript-language-server.vim b/settings/typescript-language-server.vim index 534a151..708e693 100644 --- a/settings/typescript-language-server.vim +++ b/settings/typescript-language-server.vim @@ -2,7 +2,7 @@ augroup vimlsp_settings_typescript_language_server au! LspRegisterServer { \ 'name': 'typescript-language-server', - \ 'cmd': {server_info->lsp_settings#get('typescript-language-server', 'cmd', [lsp_settings#exec_path('typescript-language-server'), '--stdio', '--tsserver-path', lsp_settings#exec_path('tsserver')])}, + \ 'cmd': {server_info->lsp_settings#get('typescript-language-server', 'cmd', [lsp_settings#exec_path('typescript-language-server'), '--stdio', '--tsserver-path', lsp_settings#exec_path('typescript-language-server/tsserver')])}, \ 'root_uri':{server_info->lsp_settings#get('typescript-language-server', 'root_uri', lsp_settings#root_uri(['.git/', 'package.json']))}, \ 'initialization_options': lsp_settings#get('typescript-language-server', 'initialization_options', {"diagnostics": "true"}), \ 'whitelist': lsp_settings#get('typescript-language-server', 'whitelist', ['javascript', 'javascriptreact', 'typescript', 'typescriptreact']), |