diff --git a/src/server/typescriptServiceClient.ts b/src/server/typescriptServiceClient.ts index 54a172e..605fefc 100644 --- a/src/server/typescriptServiceClient.ts +++ b/src/server/typescriptServiceClient.ts @@ -227,7 +227,16 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient if (this.tscPathVim) currentVersion = this.versionProvider.getVersionFromTscPath(this.tscPathVim) if (!currentVersion && !ignoreLocalTsserver) currentVersion = this.versionProvider.getLocalVersion() if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) { - this.info('Local tsserver not found, using bundled tsserver with coc-tsserver.') + if (ignoreLocalTsserver) { + this.info(`local tsserver is ignored, try global version`) + } else { + this.info(`local tsserver is not found, try global version`) + } + currentVersion = this.versionProvider.globalVersion + if (currentVersion) this.info('Local and global tsserver not found, using global tsserver from configuration') + } + if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) { + this.info('Local and global tsserver not found, using bundled tsserver with coc-tsserver.') currentVersion = this.versionProvider.getDefaultVersion() } if (!currentVersion || !currentVersion.isValid) { diff --git a/src/server/utils/versionProvider.ts b/src/server/utils/versionProvider.ts index b488bef..3fbd2db 100644 --- a/src/server/utils/versionProvider.ts +++ b/src/server/utils/versionProvider.ts @@ -102,7 +102,11 @@ export class TypeScriptVersionProvider { public get globalVersion(): TypeScriptVersion | undefined { let { globalTsdk } = this.configuration - if (globalTsdk) return new TypeScriptVersion(workspace.expand(globalTsdk)) + let folder = workspace.expand(globalTsdk) + if (!path.isAbsolute(folder)) { + folder = path.join(workspace.root, folder) + } + if (globalTsdk) return new TypeScriptVersion(folder) return undefined }