Add setting to configure the max memory for tsserver (#129)

This commit is contained in:
Konstantin Saveljev 2020-03-23 05:31:53 +02:00 committed by GitHub
parent 54bea1ec1a
commit 7a8d2ec524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View file

@ -79,6 +79,7 @@ Checkout [using the configuration file](https://github.com/neoclide/coc.nvim/wik
- `tsserver.typingsCacheLocation`:Folder path for cache typings, default: `""`
- `tsserver.formatOnType`:Run format on type special characters., default: `true`
- `tsserver.enableJavascript`:Use tsserver for javascript files, default: `true`
- `tsserver.maxTsServerMemory`:Set the maximum amount of memory to allocate to the TypeScript server process
- `tsserver.tsdk`:Directory contains tsserver.js,, default: `""`
- `tsserver.npm`:Executable path of npm for download typings, default: `""`
- `tsserver.log`:Log level of tsserver, default: `"off"`

View file

@ -134,6 +134,11 @@
"default": false,
"description": "Always use tsserver module from tsserver.tsdk or tsserver extension."
},
"tsserver.maxTsServerMemory": {
"type": "number",
"default": 0,
"description": "Set the maximum amount of memory to allocate to the TypeScript server process"
},
"tsserver.tsdk": {
"type": "string",
"default": "",

View file

@ -278,8 +278,12 @@ export default class TypeScriptServiceClient implements ITypeScriptServiceClient
this.lastError = null
const tsServerForkArgs = await this.getTsServerArgs()
const debugPort = this._configuration.debugPort
const maxTsServerMemory = this._configuration.maxTsServerMemory
const options = {
execArgv: debugPort ? [`--inspect=${debugPort}`] : [], // [`--debug-brk=5859`]
execArgv: [
...(debugPort ? [`--inspect=${debugPort}`] : []), // [`--debug-brk=5859`]
...(maxTsServerMemory ? [`--max-old-space-size=${maxTsServerMemory}`] : []),
],
cwd: workspace.root
}
this.servicePromise = this.startProcess(currentVersion, tsServerForkArgs, options, resendModels)

View file

@ -88,6 +88,10 @@ export class TypeScriptServiceConfiguration {
return this._configuration.get<boolean>('formatOnType', false)
}
public get maxTsServerMemory(): number {
return this._configuration.get<number>('maxTsServerMemory', 0)
}
public get debugPort(): number | null {
return this._configuration.get<number>('debugPort', parseInt(process.env['TSS_DEBUG'], 10))
}