Skip to content

Commit ab36b7b

Browse files
Merge master into feature/q-utg
2 parents ee9199a + dc9b623 commit ab36b7b

File tree

6 files changed

+45
-19
lines changed

6 files changed

+45
-19
lines changed

docs/lsp.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,16 @@ sequenceDiagram
4545
npm run package
4646
```
4747
to get the project setup
48-
3. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration
49-
4. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
48+
3. Enable the lsp experiment:
49+
```
50+
"aws.experiments": {
51+
"amazonqLSP": true,
52+
"amazonqLSPInline": true, // optional: enables inline completion from flare
53+
"amazonqLSPChat": true // optional: enables chat from flare
54+
}
55+
```
56+
4. Uncomment the `__AMAZONQLSP_PATH` variable in `amazonq/.vscode/launch.json` Extension configuration
57+
5. Use the `Launch LSP with Debugging` configuration and set breakpoints in VSCode or the language server
5058
5159
## Amazon Q Inline Activation
5260

packages/amazonq/src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
120120
await activateCodeWhisperer(extContext as ExtContext)
121121
if (Experiments.instance.get('amazonqLSP', false)) {
122122
await activateAmazonqLsp(context)
123-
} else {
123+
}
124+
125+
if (!Experiments.instance.get('amazonqLSPInline', false)) {
124126
await activateInlineCompletion()
125127
}
126128

@@ -157,7 +159,7 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
157159

158160
context.subscriptions.push(
159161
Experiments.instance.onDidChange(async (event) => {
160-
if (event.key === 'amazonqLSP' || event.key === 'amazonqChatLSP') {
162+
if (event.key === 'amazonqLSP' || event.key === 'amazonqChatLSP' || event.key === 'amazonqLSPInline') {
161163
await vscode.window
162164
.showInformationMessage(
163165
'Amazon Q LSP setting has changed. Reload VS Code for the changes to take effect.',

packages/amazonq/src/lsp/activation.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,14 @@
66
import vscode from 'vscode'
77
import { startLanguageServer } from './client'
88
import { AmazonQLspInstaller } from './lspInstaller'
9-
import { Commands, lspSetupStage, ToolkitError } from 'aws-core-vscode/shared'
9+
import { lspSetupStage, ToolkitError } from 'aws-core-vscode/shared'
1010

1111
export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
1212
try {
1313
await lspSetupStage('all', async () => {
1414
const installResult = await new AmazonQLspInstaller().resolve()
1515
await lspSetupStage('launch', async () => await startLanguageServer(ctx, installResult.resourcePaths))
1616
})
17-
ctx.subscriptions.push(
18-
Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
19-
await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')
20-
}),
21-
vscode.workspace.onDidCloseTextDocument(async () => {
22-
await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion')
23-
})
24-
)
2517
} catch (err) {
2618
const e = err as ToolkitError
2719
void vscode.window.showInformationMessage(`Unable to launch amazonq language server: ${e.message}`)

packages/amazonq/src/lsp/client.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ import { InlineCompletionManager } from '../app/inline/completion'
1111
import { AmazonQLspAuth, encryptionKey, notificationTypes } from './auth'
1212
import { AuthUtil } from 'aws-core-vscode/codewhisperer'
1313
import { ConnectionMetadata } from '@aws/language-server-runtimes/protocol'
14-
import { Settings, oidcClientName, createServerOptions, globals, Experiments, getLogger } from 'aws-core-vscode/shared'
14+
import {
15+
Settings,
16+
oidcClientName,
17+
createServerOptions,
18+
globals,
19+
Experiments,
20+
getLogger,
21+
Commands,
22+
} from 'aws-core-vscode/shared'
1523
import { activate } from './chat/activation'
1624
import { AmazonQResourcePaths } from './lspInstaller'
1725

@@ -101,10 +109,22 @@ export async function startLanguageServer(
101109
},
102110
}
103111
})
104-
105112
await auth.init()
106-
const inlineManager = new InlineCompletionManager(client)
107-
inlineManager.registerInlineCompletion()
113+
114+
if (Experiments.instance.get('amazonqLSPInline', false)) {
115+
const inlineManager = new InlineCompletionManager(client)
116+
inlineManager.registerInlineCompletion()
117+
toDispose.push(
118+
inlineManager,
119+
Commands.register({ id: 'aws.amazonq.invokeInlineCompletion', autoconnect: true }, async () => {
120+
await vscode.commands.executeCommand('editor.action.inlineSuggest.trigger')
121+
}),
122+
vscode.workspace.onDidCloseTextDocument(async () => {
123+
await vscode.commands.executeCommand('aws.amazonq.rejectCodeSuggestion')
124+
})
125+
)
126+
}
127+
108128
if (Experiments.instance.get('amazonqChatLSP', false)) {
109129
activate(client, encryptionKey, resourcePaths.mynahUI)
110130
}
@@ -125,8 +145,7 @@ export async function startLanguageServer(
125145
}),
126146
AuthUtil.instance.auth.onDidDeleteConnection(async () => {
127147
client.sendNotification(notificationTypes.deleteBearerToken.method)
128-
}),
129-
inlineManager
148+
})
130149
)
131150
})
132151
}

packages/core/src/shared/settings-toolkit.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const toolkitSettings = {
4343
"aws.experiments": {
4444
"jsonResourceModification": {},
4545
"amazonqLSP": {},
46+
"amazonqLSPInline": {},
4647
"amazonqChatLSP": {}
4748
},
4849
"aws.resources.enabledResources": {},

packages/toolkit/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@
251251
"type": "boolean",
252252
"default": false
253253
},
254+
"amazonqLSPInline": {
255+
"type": "boolean",
256+
"default": false
257+
},
254258
"amazonqChatLSP": {
255259
"type": "boolean",
256260
"default": false

0 commit comments

Comments
 (0)