Skip to content

Commit

Permalink
feat: add support for locale option (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehaas committed May 11, 2022
1 parent 65efc2a commit be6a95d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The language server accepts various settings through the `initializationOptions`
| logVerbosity | string | The verbosity level of the information printed in the log by `tsserver`. Accepts values: `"off"`, `"terse"`, `"normal"`, `"requesttime"`, `"verbose"`. **Default**: `undefined` (`"off"`). |
| maxTsServerMemory | number | The maximum size of the V8's old memory section in megabytes (for example `4096` means 4GB). The default value is dynamically configured by Node so can differ per system. Increase for very big projects that exceed allowed memory usage. **Default**: `undefined` |
| npmLocation | string | Specifies the path to the NPM executable used for Automatic Type Acquisition. |
| locale | string | The locale to use to show error messages. |
| plugins | object[] | An array of `{ name: string, location: string }` objects for registering a Typescript plugins. **Default**: [] |
| preferences | object | Preferences passed to the Typescript (`tsserver`) process. See below for more info. |

Expand Down
3 changes: 2 additions & 1 deletion src/lsp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class LspServer {
);

const userInitializationOptions: TypeScriptInitializationOptions = this.initializeParams.initializationOptions || {};
const { disableAutomaticTypingAcquisition, hostInfo, maxTsServerMemory, npmLocation } = userInitializationOptions;
const { disableAutomaticTypingAcquisition, hostInfo, maxTsServerMemory, npmLocation, locale } = userInitializationOptions;
const { logVerbosity, plugins, preferences }: TypeScriptInitializationOptions = {
logVerbosity: userInitializationOptions.logVerbosity || this.options.tsserverLogVerbosity,
plugins: userInitializationOptions.plugins || [],
Expand Down Expand Up @@ -184,6 +184,7 @@ export class LspServer {
disableAutomaticTypingAcquisition,
maxTsServerMemory,
npmLocation,
locale,
globalPlugins,
pluginProbeLocations,
logger: this.options.logger,
Expand Down
1 change: 1 addition & 0 deletions src/ts-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface TypeScriptInitializationOptions {
logVerbosity?: string;
maxTsServerMemory?: number;
npmLocation?: string;
locale?: string;
plugins: TypeScriptPlugin[];
preferences?: UserPreferences;
hostInfo?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface TspClientOptions {
disableAutomaticTypingAcquisition?: boolean;
maxTsServerMemory?: number;
npmLocation?: string;
locale?: string;
globalPlugins?: string[];
pluginProbeLocations?: string[];
onEvent?: (event: protocol.Event) => void;
Expand Down Expand Up @@ -92,6 +93,7 @@ export class TspClient {
disableAutomaticTypingAcquisition,
maxTsServerMemory,
npmLocation,
locale,
globalPlugins,
pluginProbeLocations
} = this.options;
Expand All @@ -115,6 +117,9 @@ export class TspClient {
this.logger.info(`using npm from ${npmLocation}`);
args.push('--npmLocation', npmLocation);
}
if (locale) {
args.push('--locale', locale);
}

this.cancellationPipeName = tempy.file({ name: 'tscancellation' });
args.push('--cancellationPipeName', `${this.cancellationPipeName}*`);
Expand Down

0 comments on commit be6a95d

Please sign in to comment.