Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/lsp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions packages/amazonq/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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.',
Expand Down
10 changes: 1 addition & 9 deletions packages/amazonq/src/lsp/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@
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<void> {
try {
await lspSetupStage('all', async () => {
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}`)
Expand Down
31 changes: 25 additions & 6 deletions packages/amazonq/src/lsp/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
}
Expand All @@ -125,8 +145,7 @@ export async function startLanguageServer(
}),
AuthUtil.instance.auth.onDidDeleteConnection(async () => {
client.sendNotification(notificationTypes.deleteBearerToken.method)
}),
inlineManager
})
)
})
}
1 change: 1 addition & 0 deletions packages/core/src/shared/settings-toolkit.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const toolkitSettings = {
"aws.experiments": {
"jsonResourceModification": {},
"amazonqLSP": {},
"amazonqLSPInline": {},
"amazonqChatLSP": {}
},
"aws.resources.enabledResources": {},
Expand Down
4 changes: 4 additions & 0 deletions packages/toolkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@
"type": "boolean",
"default": false
},
"amazonqLSPInline": {
"type": "boolean",
"default": false
},
"amazonqChatLSP": {
"type": "boolean",
"default": false
Expand Down
Loading