diff --git a/package.json b/package.json index ea79c69..ce83c27 100644 --- a/package.json +++ b/package.json @@ -143,6 +143,11 @@ }, "default": [], "description": "Additional arguments to pass to luacheck" + }, + "lua.symbol.enabled": { + "type": "boolean", + "default": true, + "description": "Specifies whether to enable the 'Go to symbol' feature." } } } diff --git a/server/src/server.ts b/server/src/server.ts index 86d3db0..9c09cd8 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -39,12 +39,17 @@ export interface LintingOptions { luaCheckArgs: string[]; } +export interface SymbolOptions { + enabled: boolean; +} + export interface Settings { luacheckPath: string; preferLuaCheckErrors: boolean; targetVersion: string; format: FormatOptions; linting: LintingOptions; + symbol: SymbolOptions; } class ServiceDispatcher { @@ -97,6 +102,10 @@ class ServiceDispatcher { } private onDocumentSymbol(handler: DocumentSymbolParams): SymbolInformation[] { + if (!this.settings.symbol.enabled) { + return []; + } + const uri = handler.textDocument.uri; const analysis: Analysis.Analysis = this.perDocumentAnalysis[uri]; @@ -104,7 +113,7 @@ class ServiceDispatcher { } private onWorkspaceSymbol(handler: WorkspaceSymbolParams) { - if (!this.rootUri) { + if (!this.rootUri || !this.settings.symbol.enabled) { return []; } @@ -230,6 +239,7 @@ class ServiceDispatcher { this.settings.format.singleQuote = validateSetting(this.settings.format.singleQuote, false); this.settings.format.linebreakMultipleAssignments = validateSetting( this.settings.format.linebreakMultipleAssignments, false); + this.settings.symbol.enabled = validateSetting(this.settings.symbol.enabled, true); // Validate the version. onDidChangeConfiguration seems to be called for every keystroke the user enters, // so its possible that the version string will be malformed.