From 7b034e7e449906d1e14fb94c55f27f85c47c2563 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Tue, 20 Aug 2024 22:39:10 +0100 Subject: [PATCH] Collect rubyLsp settings as well --- vscode/src/infoCollector.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/vscode/src/infoCollector.ts b/vscode/src/infoCollector.ts index 238898725..4198a79e8 100644 --- a/vscode/src/infoCollector.ts +++ b/vscode/src/infoCollector.ts @@ -21,7 +21,7 @@ export async function collectRubyLspInfo(workspace: Workspace | undefined) { async function gatherLspInfo( workspace: Workspace, -): Promise> { +): Promise>> { const vscodeVersion = vscode.version; const rubyLspExtension = vscode.extensions.getExtension("Shopify.ruby-lsp")!; const rubyLspExtensionVersion = rubyLspExtension.packageJSON.version; @@ -30,6 +30,21 @@ async function gatherLspInfo( workspace.lspClient?.addons?.map((addon) => addon.name) ?? []; const extensions = await getPublicExtensions(); + // Fetch rubyLsp settings + const workspaceSettings = vscode.workspace.getConfiguration( + "rubyLsp", + workspace.workspaceFolder, + ); + const userSettings = vscode.workspace.getConfiguration("rubyLsp"); + + // Get only the workspace-specific settings + const workspaceSpecificSettings: Record = {}; + for (const key of Object.keys(workspaceSettings)) { + if (workspaceSettings.inspect(key)?.workspaceValue !== undefined) { + workspaceSpecificSettings[key] = workspaceSettings.get(key); + } + } + return { /* eslint-disable @typescript-eslint/naming-convention */ "VS Code Version": vscodeVersion, @@ -39,6 +54,10 @@ async function gatherLspInfo( "Ruby Version": workspace.ruby.rubyVersion ?? "Unknown", "Ruby Version Manager": workspace.ruby.versionManager.identifier, "Installed Extensions": extensions, + "Ruby LSP Settings": { + Workspace: workspaceSpecificSettings, + User: userSettings, + }, /* eslint-enable @typescript-eslint/naming-convention */ }; } @@ -65,7 +84,7 @@ async function getPublicExtensions(): Promise { } function generateRubyLspInfoReport( - info: Record, + info: Record>, ): string { let markdown = "\n### Ruby LSP Information\n\n"; @@ -80,6 +99,14 @@ function generateRubyLspInfoReport( } else { markdown += `${value.map((val) => `- ${val}`).join("\n")}\n`; } + } else if (typeof value === "object" && value !== null) { + markdown += + "<details>\n<summary>Click to expand</summary>\n\n"; + for (const [subKey, subValue] of Object.entries(value)) { + markdown += `##### ${subKey}\n\n`; + markdown += `\`\`\`json\n${JSON.stringify(subValue, null, 2)}\n\`\`\`\n\n`; + } + markdown += "</details>\n"; } else { markdown += `${value}\n`; }