use tsserver.pluginPaths replace tsserver.pluginRoot

This commit is contained in:
Qiming Zhao 2020-07-13 19:56:13 +08:00
parent 8e2d3eefef
commit 50d6c6241a
4 changed files with 22 additions and 11 deletions

View file

@ -104,7 +104,7 @@ Checkout [using the configuration file](https://github.com/neoclide/coc.nvim/wik
- `tsserver.npm`:Executable path of npm for download typings, default: `""`
- `tsserver.log`:Log level of tsserver, default: `"off"`
- `tsserver.trace.server`:Trace level of tsserver, default: `"off"`
- `tsserver.pluginRoot`:Folder contains tsserver plugins, default: `[]`
- `tsserver.pluginPaths`:Folders contains tsserver plugins, default: `[]`
- `tsserver.debugPort`:Debug port number of tsserver
- `tsserver.watchOptions`:Configure which watching strategies should be used to keep track of files and directories. Requires using TypeScript 3.8+ in the workspace, default: undefined.
- `tsserver.reportStyleChecksAsWarnings` default: `true`

View file

@ -211,13 +211,13 @@
],
"description": "Trace level of tsserver"
},
"tsserver.pluginRoot": {
"type": "string",
"tsserver.pluginPaths": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"description": "Folder contains tsserver plugins"
"description": "Folders contains tsserver plugins"
},
"tsserver.debugPort": {
"type": "number",

View file

@ -281,7 +281,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
this._tscPath = currentVersion.tscPath
this.versionStatus.onDidChangeTypeScriptVersion(currentVersion)
this.lastError = null
const tsServerForkArgs = await this.getTsServerArgs()
const tsServerForkArgs = await this.getTsServerArgs(currentVersion)
const debugPort = this._configuration.debugPort
const maxTsServerMemory = this._configuration.maxTsServerMemory
const options = {
@ -766,7 +766,7 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
}
}
private async getTsServerArgs(): Promise<string[]> {
private async getTsServerArgs(currentVersion: TypeScriptVersion): Promise<string[]> {
const args: string[] = []
args.push('--allowLocalPluginLoads')
@ -809,15 +809,26 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
if (this.apiVersion.gte(API.v230)) {
const pluginNames = this.pluginManager.plugins.map(x => x.name)
const pluginRoot = this._configuration.tsServerPluginRoot
const pluginPaths = pluginRoot ? [pluginRoot] : []
let pluginPaths = this._configuration.tsServerPluginPaths
pluginPaths = pluginPaths.reduce((p, c) => {
if (path.isAbsolute(c)) {
p.push(c)
} else {
let roots = workspace.workspaceFolders.map(o => Uri.parse(o.uri).fsPath)
p.push(...roots.map(r => path.join(r, c)))
}
return p
}, [])
if (pluginNames.length) {
const isUsingBundledTypeScriptVersion = currentVersion.path == this.versionProvider.bundledVersion.path
args.push('--globalPlugins', pluginNames.join(','))
for (const plugin of this.pluginManager.plugins) {
if (isUsingBundledTypeScriptVersion || plugin.enableForWorkspaceTypeScriptVersions) {
pluginPaths.push(plugin.path)
}
}
}
if (pluginPaths.length) {
args.push('--pluginProbeLocations', pluginPaths.join(','))

View file

@ -73,8 +73,8 @@ export class TypeScriptServiceConfiguration {
return this._configuration.get<string>('typingsCacheLocation', '')
}
public get tsServerPluginRoot(): string | null {
return this._configuration.get<string | null>('tsServerPluginRoot', null)
public get tsServerPluginPaths(): string[] {
return this._configuration.get<string[]>('pluginPaths', [])
}
public get checkJs(): boolean {