diff --git a/docs/lsp.md b/docs/lsp.md index 64a3af3e8c0..601de15c33b 100644 --- a/docs/lsp.md +++ b/docs/lsp.md @@ -45,8 +45,16 @@ sequenceDiagram npm run package ``` to get the project setup -3. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration -4. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server +3. Enable the lsp experiment: + ``` + "aws.experiments": { + "amazonqLSP": true, + "amazonqLSPInline": true, // optional: enables inline completion from flare + "amazonqLSPChat": true // optional: enables chat from flare + } + ``` +4. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration +5. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server ## Amazon Q Inline Activation diff --git a/packages/amazonq/src/extension.ts b/packages/amazonq/src/extension.ts index ad89a44ed4d..ae9e0c5657d 100644 --- a/packages/amazonq/src/extension.ts +++ b/packages/amazonq/src/extension.ts @@ -120,7 +120,9 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is await activateCodeWhisperer(extContext as ExtContext) if (Experiments.instance.get('amazonqLSP', false)) { await activateAmazonqLsp(context) - } else { + } + + if (!Experiments.instance.get('amazonqLSPInline', false)) { await activateInlineCompletion() } @@ -157,7 +159,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is context.subscriptions.push( Experiments.instance.onDidChange(async (event) => { - if (event.key === 'amazonqLSP' || event.key === 'amazonqChatLSP') { + if (event.key === 'amazonqLSP' || event.key === 'amazonqChatLSP' || event.key === 'amazonqLSPInline') { await vscode.window .showInformationMessage( 'Amazon Q LSP setting has changed. Reload VS Code for the changes to take effect.', diff --git a/packages/amazonq/src/lsp/activation.ts b/packages/amazonq/src/lsp/activation.ts index 6e614412f21..c4855c17970 100644 --- a/packages/amazonq/src/lsp/activation.ts +++ b/packages/amazonq/src/lsp/activation.ts @@ -6,7 +6,7 @@ import vscode from 'vscode' import { startLanguageServer } from './client' import { AmazonQLspInstaller } from './lspInstaller' -import { Commands, lspSetupStage, ToolkitError } from 'aws-core-vscode/shared' +import { lspSetupStage, ToolkitError } from 'aws-core-vscode/shared' export async function activate(ctx: vscode.ExtensionContext): Promise { try { @@ -14,14 +14,6 @@ export async function activate(ctx: vscode.ExtensionContext): Promise { const installResult = await new AmazonQLspInstaller().resolve() await lspSetupStage('launch', async () => await startLanguageServer(ctx, installResult.resourcePaths)) }) - ctx.subscriptions.push( - Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => { - await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger') - }), - vscode.workspace.onDidCloseTextDocument(async () => { - await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion') - }) - ) } catch (err) { const e = err as ToolkitError void vscode.window.showInformationMessage(`Unable to launch amazonq language server: ${e.message}`) diff --git a/packages/amazonq/src/lsp/client.ts b/packages/amazonq/src/lsp/client.ts index d43e78ab42b..31e4e7b7c93 100644 --- a/packages/amazonq/src/lsp/client.ts +++ b/packages/amazonq/src/lsp/client.ts @@ -11,7 +11,15 @@ import { InlineCompletionManager } from '../app/inline/completion' import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth' import { AuthUtil } from 'aws-core-vscode/codewhisperer' import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol' -import { Settings, oidcClientName, createServerOptions, globals, Experiments, getLogger } from 'aws-core-vscode/shared' +import { + Settings, + oidcClientName, + createServerOptions, + globals, + Experiments, + getLogger, + Commands, +} from 'aws-core-vscode/shared' import { activate } from './chat/activation' import { AmazonQResourcePaths } from './lspInstaller' @@ -101,10 +109,22 @@ export async function startLanguageServer( }, } }) - await auth.init() - const inlineManager = new InlineCompletionManager(client) - inlineManager.registerInlineCompletion() + + if (Experiments.instance.get('amazonqLSPInline', false)) { + const inlineManager = new InlineCompletionManager(client) + inlineManager.registerInlineCompletion() + toDispose.push( + inlineManager, + Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => { + await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger') + }), + vscode.workspace.onDidCloseTextDocument(async () => { + await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion') + }) + ) + } + if (Experiments.instance.get('amazonqChatLSP', false)) { activate(client, encryptionKey, resourcePaths.mynahUI) } @@ -125,8 +145,7 @@ export async function startLanguageServer( }), AuthUtil.instance.auth.onDidDeleteConnection(async () => { client.sendNotification(notificationTypes.deleteBearerToken.method) - }), - inlineManager + }) ) }) } diff --git a/packages/core/src/shared/settings-toolkit.gen.ts b/packages/core/src/shared/settings-toolkit.gen.ts index 5cd9854b1fc..59a637a4870 100644 --- a/packages/core/src/shared/settings-toolkit.gen.ts +++ b/packages/core/src/shared/settings-toolkit.gen.ts @@ -43,6 +43,7 @@ export const toolkitSettings = { "aws.experiments": { "jsonResourceModification": {}, "amazonqLSP": {}, + "amazonqLSPInline": {}, "amazonqChatLSP": {} }, "aws.resources.enabledResources": {}, diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index b21c6ef0204..ee842e6fcb4 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -251,6 +251,10 @@ "type": "boolean", "default": false }, + "amazonqLSPInline": { + "type": "boolean", + "default": false + }, "amazonqChatLSP": { "type": "boolean", "default": false