Skip to content

Config available to ghcide Main is always default #1980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
isovector opened this issue Jun 25, 2021 · 3 comments
Closed

Config available to ghcide Main is always default #1980

isovector opened this issue Jun 25, 2021 · 3 comments
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@isovector
Copy link
Collaborator

isovector commented Jun 25, 2021

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:

config <- LSP.runLspT env LSP.getConfig

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:

instance Default Config where
def = Config
{ checkParents = CheckOnSaveAndClose
, checkProject = True
, hlintOn = True
, diagnosticsOnChange = True
, diagnosticsDebounceDuration = 350000
, liquidOn = False
, formatOnImportOn = True
-- , formattingProvider = "brittany"
, formattingProvider = "ormolu"
-- , formattingProvider = "floskell"
-- , formattingProvider = "stylish-haskell"
, maxCompletions = 40
, plugins = Map.empty
}

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

@isovector isovector changed the title Config available to ghcide session-loader is always default Config available to ghcide Main is always default Jun 25, 2021
@pepeiborra
Copy link
Collaborator

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

haskell/lsp#337

@jneira jneira added the type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. label Jun 26, 2021
@pepeiborra
Copy link
Collaborator

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
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants