Skip to content

Commit

Permalink
Chore: Use synchronize option to sync settings
Browse files Browse the repository at this point in the history
Though this option is marked as deprecated, we can't fully embrach the recommended pull-model for syncing configuration
as the logger's logging level can't be synced in the same way like others. It needs to be updated immediately
instead of being fetched from the client when needed.
More info: https://code.visualstudio.com/api/language-extensions/language-server-extension-guide#explaining-the-language-server
  • Loading branch information
WilsonZiweiWang authored and deribaucourt committed Jul 17, 2024
1 parent 97b5555 commit 904fe79
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions client/src/language/languageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import * as path from 'path'

import {
workspace,
type ExtensionContext,
window,
languages,
Expand Down Expand Up @@ -49,22 +48,14 @@ export async function activateLanguageServer (context: ExtensionContext, bitBake
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
}

const sendSettings = async (): Promise<void> => {
const settings = workspace.getConfiguration()
try {
await client.sendNotification('workspace/didChangeConfiguration', { settings })
} catch (error) {
logger.error('Failed to send settings to language server: ' + String(error))
}
}

workspace.onDidChangeConfiguration(sendSettings)

// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for bitbake documents
// TODO: check new documentSelector
documentSelector: [{ scheme: 'file', language: 'bitbake' }],
// TODO: Use the new pull-model for configuration settings
synchronize: {
configurationSection: 'bitbake'
},
middleware: {
provideCompletionItem: middlewareProvideCompletion,
provideDefinition: middlewareProvideDefinition,
Expand Down Expand Up @@ -146,7 +137,6 @@ export async function activateLanguageServer (context: ExtensionContext, bitBake

// Start the client and launch the server
await client.start()
await sendSettings()

return client
}
Expand Down

0 comments on commit 904fe79

Please sign in to comment.