Can sourcekit-lsp change language mode on the fly?

I'm working on integrating sourcekit-lsp into my editor, and here is the problem: If a user of my editor changes Swift language mode, strict concurrency checking, c++ interoperability or any other project setting that affect compiler diagnostic, is there a way to notify sourcekit-lsp of the changes?

I know there is the workspace/didChangeConfiguration notification, but I was unable to figure out what the correct value for its settings parameter should be, or if this notification is able to change language mode and other such settings at all.

For now I resort to restarting the whole sourcekit-lsp process with new command-line parameters, which is suboptimal.

How are the settings generated for your use case today? Is it just using the integrated SwiftPM/compile commands support + setting extra on the command line? If so, this isn’t possible today, though we could possibly start watching eg. .sourcekit-lsp/config.json for changes and reload in that case. We don’t handle workspace/didChangeConfiguration request at all at the moment.

If you’re instead providing your own BSP, then the expectation would be that it sends a buildTarget/didChange to have sourcekit-lsp re-request settings for those targets (or all if none are provided).

1 Like

I use just command-line options for the sourcekit-lsp executable (and for swiftc when building). SwiftPM and configuration files are not used (a rudimentary Package.swift is used though, just to enable swiftPM workspace type for sourcekit-lsp).

Good to know, thank you for the information.

I would prefer if a client (editor) could send a request or notification to the lsp server.

No, I don't provide a BSP. To be honest I am not yet familiar with BSP.