Skip to content

Commit

Permalink
Collect rubyLsp settings as well
Browse files Browse the repository at this point in the history
  • Loading branch information
st0012 committed Aug 20, 2024
1 parent 3d68ae1 commit 7b034e7
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions vscode/src/infoCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function collectRubyLspInfo(workspace: Workspace | undefined) {

async function gatherLspInfo(
workspace: Workspace,
): Promise<Record<string, string | string[]>> {
): Promise<Record<string, string | string[] | Record<string, unknown>>> {
const vscodeVersion = vscode.version;
const rubyLspExtension = vscode.extensions.getExtension("Shopify.ruby-lsp")!;
const rubyLspExtensionVersion = rubyLspExtension.packageJSON.version;
Expand All @@ -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<string, unknown> = {};
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,
Expand All @@ -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 */
};
}
Expand All @@ -65,7 +84,7 @@ async function getPublicExtensions(): Promise<string[]> {
}

function generateRubyLspInfoReport(
info: Record<string, string | string[]>,
info: Record<string, string | string[] | Record<string, unknown>>,
): string {
let markdown = "\n### Ruby LSP Information\n\n";

Expand All @@ -80,6 +99,14 @@ function generateRubyLspInfoReport(
} else {
markdown += `${value.map((val) => `- ${val}`).join("\n")}\n`;
}
} else if (typeof value === "object" && value !== null) {
markdown +=
"&lt;details&gt;\n&lt;summary&gt;Click to expand&lt;/summary&gt;\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 += "&lt;/details&gt;\n";
} else {
markdown += `${value}\n`;
}
Expand Down

0 comments on commit 7b034e7

Please sign in to comment.