From f1fc079e413767103886c3f40f566bbe52266d1e Mon Sep 17 00:00:00 2001 From: Ram Nadella Date: Sun, 29 Jun 2025 22:23:18 -0400 Subject: [PATCH 1/2] Remove unnecessary workspace validation in extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The workspaceRoot check was preventing the language server from starting when no workspace folder was open. This is overly restrictive since: - LSP servers can operate without a workspace (single file mode) - Workspace information is automatically passed via LSP initialization - The LSP spec allows for null workspace folders This change allows the extension to be more flexible and follow VSCode LSP best practices by letting the server handle workspace scenarios. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- pydance/src/extension.ts | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/pydance/src/extension.ts b/pydance/src/extension.ts index dba3a2f..0c2dbc2 100644 --- a/pydance/src/extension.ts +++ b/pydance/src/extension.ts @@ -16,20 +16,6 @@ export function activate(context: vscode.ExtensionContext) { const serverPath = context.asAbsolutePath(path.join("pylight")); outputChannel.appendLine(`Server path: ${serverPath}`); - // Get the workspace root path - const workspaceRoot = - vscode.workspace.workspaceFolders && - vscode.workspace.workspaceFolders.length > 0 - ? vscode.workspace.workspaceFolders[0].uri.fsPath - : undefined; - - if (!workspaceRoot) { - outputChannel.appendLine("No workspace folder found. Server not starting."); - return; - } - - outputChannel.appendLine(`Workspace root: ${workspaceRoot}`); - // If the extension is launched in debug mode then the debug server options are used const serverOptions: ServerOptions = { run: { command: serverPath, args: [] }, From c5b793d476cf663570eb849c7c6c9452f58ae2e1 Mon Sep 17 00:00:00 2001 From: Ram Nadella Date: Sun, 29 Jun 2025 22:49:36 -0400 Subject: [PATCH 2/2] feat: add parser configuration option to extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add pydance.parser configuration setting with values "ruff" and "tree-sitter" - Set default parser to "ruff" as requested - Update extension to pass --parser flag to pylight server - Log selected parser in output channel for debugging This allows users to choose between the ruff and tree-sitter parser backends in the pylight language server. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- pydance/package.json | 13 ++++++++++++- pydance/src/extension.ts | 9 +++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/pydance/package.json b/pydance/package.json index 59a9e93..f65d9f4 100644 --- a/pydance/package.json +++ b/pydance/package.json @@ -31,7 +31,18 @@ ".py" ] } - ] + ], + "configuration": { + "title": "Pydance", + "properties": { + "pydance.parser": { + "type": "string", + "default": "ruff", + "enum": ["ruff", "tree-sitter"], + "description": "Parser backend to use for Python code analysis" + } + } + } }, "scripts": { "vscode:prepublish": "npm run compile", diff --git a/pydance/src/extension.ts b/pydance/src/extension.ts index 0c2dbc2..777725c 100644 --- a/pydance/src/extension.ts +++ b/pydance/src/extension.ts @@ -16,10 +16,15 @@ export function activate(context: vscode.ExtensionContext) { const serverPath = context.asAbsolutePath(path.join("pylight")); outputChannel.appendLine(`Server path: ${serverPath}`); + // Get the parser configuration + const config = vscode.workspace.getConfiguration("pydance"); + const parser = config.get("parser", "ruff"); + outputChannel.appendLine(`Using parser: ${parser}`); + // If the extension is launched in debug mode then the debug server options are used const serverOptions: ServerOptions = { - run: { command: serverPath, args: [] }, - debug: { command: serverPath, args: [] }, + run: { command: serverPath, args: ["--parser", parser] }, + debug: { command: serverPath, args: ["--parser", parser] }, }; // Options to control the language client