resolve local tsserver from workspaceFolders
This commit is contained in:
parent
f29a6f424b
commit
fe5c4d84dd
2 changed files with 6 additions and 7 deletions
|
@ -242,7 +242,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
private async startService(resendModels = false): Promise<ForkedTsServerProcess> {
|
private async startService(resendModels = false): Promise<ForkedTsServerProcess> {
|
||||||
let currentVersion = this.versionProvider.getLocalVersion(workspace.root)
|
let currentVersion = this.versionProvider.getLocalVersion()
|
||||||
if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) {
|
if (!currentVersion || !fs.existsSync(currentVersion.tsServerPath)) {
|
||||||
currentVersion = await this.versionProvider.getDefaultVersion()
|
currentVersion = await this.versionProvider.getDefaultVersion()
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { getParentDirs } from './fs'
|
import { getParentDirs } from './fs'
|
||||||
import { workspace } from 'coc.nvim'
|
import { workspace, Uri } from 'coc.nvim'
|
||||||
import API from './api'
|
import API from './api'
|
||||||
import { TypeScriptServiceConfiguration } from './configuration'
|
import { TypeScriptServiceConfiguration } from './configuration'
|
||||||
|
|
||||||
|
@ -101,11 +101,10 @@ export class TypeScriptVersionProvider {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLocalVersion(root): TypeScriptVersion | undefined {
|
public getLocalVersion(): TypeScriptVersion | undefined {
|
||||||
let paths = getParentDirs(root)
|
let folders = workspace.workspaceFolders.map(f => Uri.parse(f.uri).fsPath)
|
||||||
paths.unshift(root)
|
for (let p of folders) {
|
||||||
for (let p of paths) {
|
if (fs.existsSync(path.join(p, 'node_modules/typescript/lib'))) {
|
||||||
if (fs.existsSync(path.join(p, 'node_modules'))) {
|
|
||||||
let lib = path.join(p, 'node_modules/typescript/lib')
|
let lib = path.join(p, 'node_modules/typescript/lib')
|
||||||
return new TypeScriptVersion(lib)
|
return new TypeScriptVersion(lib)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue