diff --git a/package.json b/package.json index 89ce4b3..8b4ddf6 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,47 @@ "markdownDescription": "Optional path to a .config.luau file containing lute lint configuration." } } - } + }, + "breakpoints": [{ "language": "luau" }], + "debuggers": [ + { + "type": "lute", + "label": "Lute Debugger", + "languages": ["luau"], + "configurationAttributes": { + "launch": { + "required": ["program"], + "properties": { + "program": { + "type": "string", + "description": "Absolute path to the Luau file to debug.", + "default": "${file}" + } + } + } + }, + "initialConfigurations": [ + { + "type": "lute", + "request": "launch", + "name": "Debug Luau File", + "program": "${file}" + } + ], + "configurationSnippets": [ + { + "label": "Lute Debug: Launch", + "description": "A new configuration for debugging a Luau file", + "body": { + "type": "lute", + "request": "launch", + "name": "Debug Luau File", + "program": "^\"\\${file}\"" + } + } + ] + } + ] }, "repository": { "type": "git", diff --git a/src/extension.ts b/src/extension.ts index 06a5785..cb284b3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -321,6 +321,35 @@ export async function activate(context: vscode.ExtensionContext) { vscode.workspace.textDocuments.forEach(lint); + context.subscriptions.push( + vscode.debug.registerDebugAdapterDescriptorFactory("lute", { + createDebugAdapterDescriptor(_session) { + const bundledLutePath = vscode.Uri.joinPath( + context.extensionUri, + "bin", + "lute" + ).fsPath; + const lutePath = + vscode.workspace + .getConfiguration("mandolin") + .get("luteExecPath", "") || + lutePathResult?.lutePath || + bundledLutePath; + const debugCwd = lutePathResult?.foremanToml + ? path.dirname(lutePathResult.foremanToml) + : _session.workspaceFolder?.uri.fsPath; + log( + `Starting debug adapter: ${lutePath} debug serve (cwd: ${debugCwd ?? `process default (${process.cwd()})`})` + ); + return new vscode.DebugAdapterExecutable( + lutePath, + ["debug", "serve"], + debugCwd ? { cwd: debugCwd } : undefined + ); + }, + }) + ); + log("Mandolin !"); }