Skip to content

Forward user preferences in initialization options #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions server/src/lsp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ export class LspServer {
this.logger.log('initialize', params);
this.initializeParams = params;

const { logVerbosity, plugins }: TypeScriptInitializationOptions = {
const { logVerbosity, plugins, preferences }: TypeScriptInitializationOptions = {
logVerbosity: this.options.tsserverLogVerbosity,
plugins: [],
preferences: {},
...this.initializeParams.initializationOptions
};
const logFile = this.getLogFile(logVerbosity);
Expand All @@ -124,7 +125,8 @@ export class LspServer {
this.tspClient.start();
this.tspClient.request(CommandTypes.Configure, {
preferences: {
allowTextChangesInNewFiles: true
allowTextChangesInNewFiles: true,
...preferences
}
});

Expand Down
2 changes: 2 additions & 0 deletions server/src/ts-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* **IMPORTANT** this module should not depend on `vscode-languageserver` only protocol and types
*/
import * as lsp from 'vscode-languageserver-protocol';
import { UserPreferences } from 'typescript/lib/protocol';

export namespace TypeScriptRenameRequest {
export const type = new lsp.RequestType<lsp.TextDocumentPositionParams, any, void, void>("_typescript.rename");
Expand All @@ -22,6 +23,7 @@ export interface TypeScriptPlugin {
export interface TypeScriptInitializationOptions {
logVerbosity?: string
plugins: TypeScriptPlugin[]
preferences?: UserPreferences
}

export type TypeScriptInitializeParams = lsp.InitializeParams & {
Expand Down