Skip to content
Open
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -97,14 +102,18 @@ 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];

return buildDocumentSymbols(uri, analysis);
}

private onWorkspaceSymbol(handler: WorkspaceSymbolParams) {
if (!this.rootUri) {
if (!this.rootUri || !this.settings.symbol.enabled) {
return [];
}

Expand Down Expand Up @@ -230,6 +239,7 @@ class ServiceDispatcher {
this.settings.format.singleQuote = validateSetting<boolean>(this.settings.format.singleQuote, false);
this.settings.format.linebreakMultipleAssignments = validateSetting<boolean>(
this.settings.format.linebreakMultipleAssignments, false);
this.settings.symbol.enabled = validateSetting<boolean>(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.
Expand Down