diff --git a/packages/generator-langium/langium-template/src/extension.ts b/packages/generator-langium/langium-template/src/extension.ts index 375126c5a..001de7a7f 100644 --- a/packages/generator-langium/langium-template/src/extension.ts +++ b/packages/generator-langium/langium-template/src/extension.ts @@ -23,8 +23,9 @@ export function deactivate(): Thenable | undefined { function startLanguageClient(context: vscode.ExtensionContext): LanguageClient { const serverModule = context.asAbsolutePath(path.join('out', 'language-server', 'main')); // The debug options for the server - // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging - const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }; + // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging. + // By setting `process.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached. + const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used diff --git a/packages/langium-vscode/src/extension.ts b/packages/langium-vscode/src/extension.ts index 3afcb8898..c292e6e7b 100644 --- a/packages/langium-vscode/src/extension.ts +++ b/packages/langium-vscode/src/extension.ts @@ -29,8 +29,9 @@ export function deactivate(): Thenable | undefined { function startLanguageClient(context: vscode.ExtensionContext): LanguageClient { const serverModule = context.asAbsolutePath(path.join('out', 'language-server', 'main')); // The debug options for the server - // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging - const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] }; + // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging. + // By setting `process.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached. + const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used