haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 368 forks source link

Config available to ghcide Main is always default #1980

Closed isovector closed 3 years ago

isovector commented 3 years ago

While working on a fix for #1873, I noticed that my plugin's configuration wasn't available when building the IdeOptions. But that's odd, because it's obviously getting pulled:

https://github.com/haskell/haskell-language-server/blob/dee021657619c8e89174a99be63651d2fca977a5/ghcide/src/Development/IDE/Main.hs#L220

Tracing this, however, gives the following object:

Config {checkParents = CheckOnSaveAndClose, checkProject = True, hlintOn = True, diagnosticsOnChange = True, diagnosticsDebounceDuration = 350000, liquidOn = False, formatOnImportOn = True, formattingProvider = "ormolu", maxCompletions = 40, plugins = fromList []}

which correspond exactly with the Default instance:

https://github.com/haskell/haskell-language-server/blob/dee021657619c8e89174a99be63651d2fca977a5/hls-plugin-api/src/Ide/Plugin/Config.hs#L63-L78

What's going on here? Do we expect the config to be initialized by this point?

pepeiborra commented 3 years ago

Is it possible that you are being bitten by the bug below?

https://github.com/haskell/lsp/pull/337

pepeiborra commented 3 years ago

We looked further into this and the problem is that some editors, including VSCode, may refuse to include the config in the initialisation notification and instead only send it later via a WorkspaceDidChangeConfiguration notification. So we can never rely on the initialisation time config, and instead must always call Ide.PluginUtils.getClientConfig to retrieve the current config dynamically

isovector commented 3 years ago

Closing this, since it's a client-side problem.