@@ -36,6 +36,7 @@ import {
3636} from 'aws-core-vscode/shared'
3737import { activate } from './chat/activation'
3838import { AmazonQResourcePaths } from './lspInstaller'
39+ import { ConfigSection , isValidConfigSection , toAmazonQLSPLogLevel } from './config'
3940
4041const localize = nls . loadMessageBundle ( )
4142const logger = getLogger ( 'amazonqLsp.lspClient' )
@@ -80,42 +81,11 @@ export async function startLanguageServer(
8081 */
8182 configuration : async ( params , token , next ) => {
8283 const config = await next ( params , token )
83- if ( params . items [ 0 ] . section === 'aws.q' ) {
84- const customization = undefinedIfEmpty ( getSelectedCustomization ( ) . arn )
85- /**
86- * IMPORTANT: This object is parsed by the following code in the language server, **so
87- * it must match that expected shape**.
88- * https://github.com/aws/language-servers/blob/1d2ca018f2248106690438b860d40a7ee67ac728/server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/configurationUtils.ts#L114
89- */
90- return [
91- {
92- customization,
93- optOutTelemetry : getOptOutPreference ( ) === 'OPTOUT' ,
94- projectContext : {
95- // TODO: we might need another setting to control the actual indexing
96- enableLocalIndexing : true ,
97- enableGpuAcceleration : CodeWhispererSettings . instance . isLocalIndexGPUEnabled ( ) ,
98- indexWorkerThreads : CodeWhispererSettings . instance . getIndexWorkerThreads ( ) ,
99- localIndexing : {
100- ignoreFilePatterns : CodeWhispererSettings . instance . getIndexIgnoreFilePatterns ( ) ,
101- maxFileSizeMB : CodeWhispererSettings . instance . getMaxIndexFileSize ( ) ,
102- maxIndexSizeMB : CodeWhispererSettings . instance . getMaxIndexSize ( ) ,
103- indexCacheDirPath : CodeWhispererSettings . instance . getIndexCacheDirPath ( ) ,
104- } ,
105- } ,
106- } ,
107- ]
84+ const section = params . items [ 0 ] . section
85+ if ( ! isValidConfigSection ( section ) ) {
86+ return config
10887 }
109- if ( params . items [ 0 ] . section === 'aws.codeWhisperer' ) {
110- return [
111- {
112- includeSuggestionsWithCodeReferences :
113- CodeWhispererSettings . instance . isSuggestionsWithCodeReferencesEnabled ( ) ,
114- shareCodeWhispererContentWithAWS : ! CodeWhispererSettings . instance . isOptoutEnabled ( ) ,
115- } ,
116- ]
117- }
118- return config
88+ return getConfigSection ( section )
11989 } ,
12090 } ,
12191 } ,
@@ -139,6 +109,7 @@ export async function startLanguageServer(
139109 showSaveFileDialog : true ,
140110 } ,
141111 } ,
112+ logLevel : toAmazonQLSPLogLevel ( globals . logOutputChannel . logLevel ) ,
142113 } ,
143114 credentials : {
144115 providesBearerToken : true ,
@@ -296,3 +267,42 @@ function onServerRestartHandler(client: LanguageClient, auth: AmazonQLspAuth) {
296267 await auth . refreshConnection ( true )
297268 } )
298269}
270+
271+ function getConfigSection ( section : ConfigSection ) {
272+ switch ( section ) {
273+ case 'aws.q' :
274+ /**
275+ * IMPORTANT: This object is parsed by the following code in the language server, **so
276+ * it must match that expected shape**.
277+ * https://github.com/aws/language-servers/blob/1d2ca018f2248106690438b860d40a7ee67ac728/server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/configurationUtils.ts#L114
278+ */
279+ return [
280+ {
281+ customization : undefinedIfEmpty ( getSelectedCustomization ( ) . arn ) ,
282+ optOutTelemetry : getOptOutPreference ( ) === 'OPTOUT' ,
283+ projectContext : {
284+ // TODO: we might need another setting to control the actual indexing
285+ enableLocalIndexing : true ,
286+ enableGpuAcceleration : CodeWhispererSettings . instance . isLocalIndexGPUEnabled ( ) ,
287+ indexWorkerThreads : CodeWhispererSettings . instance . getIndexWorkerThreads ( ) ,
288+ localIndexing : {
289+ ignoreFilePatterns : CodeWhispererSettings . instance . getIndexIgnoreFilePatterns ( ) ,
290+ maxFileSizeMB : CodeWhispererSettings . instance . getMaxIndexFileSize ( ) ,
291+ maxIndexSizeMB : CodeWhispererSettings . instance . getMaxIndexSize ( ) ,
292+ indexCacheDirPath : CodeWhispererSettings . instance . getIndexCacheDirPath ( ) ,
293+ } ,
294+ } ,
295+ } ,
296+ ]
297+ case 'aws.codeWhisperer' :
298+ return [
299+ {
300+ includeSuggestionsWithCodeReferences :
301+ CodeWhispererSettings . instance . isSuggestionsWithCodeReferencesEnabled ( ) ,
302+ shareCodeWhispererContentWithAWS : ! CodeWhispererSettings . instance . isOptoutEnabled ( ) ,
303+ } ,
304+ ]
305+ case 'aws.logLevel' :
306+ return [ toAmazonQLSPLogLevel ( globals . logOutputChannel . logLevel ) ]
307+ }
308+ }
0 commit comments