Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 4f794aa

Browse files
committed
Use default config on missing configuration section
On serving initialize request, the deserialization of HIE configuration embedded in InitializeParam passed by client will result in an error if during the deserialization process the server cannot find HIE specific configuration key under initializationOptions. This commit changes the initializationOptions deserialization to return the default configuration if configuration key cannot be found under initializationOptions. Here, setting the key with a value of null will also be considered as part of not found condition to accommodate clients that fills missing user options as null.
1 parent e4972ff commit 4f794aa

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

hie-plugin-api/Haskell/Ide/Engine/Config.hs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ instance Default Config where
5555
-- TODO: Add API for plugins to expose their own LSP config options
5656
instance FromJSON Config where
5757
parseJSON = withObject "Config" $ \v -> do
58-
s <- v .: "haskell" <|> v.: "languageServerHaskell"
59-
flip (withObject "Config.settings") s $ \o -> Config
60-
<$> o .:? "hlintOn" .!= hlintOn def
61-
<*> o .:? "diagnosticsOnChange" .!= diagnosticsOnChange def
62-
<*> o .:? "maxNumberOfProblems" .!= maxNumberOfProblems def
63-
<*> o .:? "diagnosticsDebounceDuration" .!= diagnosticsDebounceDuration def
64-
<*> o .:? "liquidOn" .!= liquidOn def
65-
<*> o .:? "completionSnippetsOn" .!= completionSnippetsOn def
66-
<*> o .:? "formatOnImportOn" .!= formatOnImportOn def
67-
<*> o .:? "formattingProvider" .!= formattingProvider def
58+
c <- v .:! "haskell" <|> v.:! "languageServerHaskell"
59+
case c of
60+
Nothing -> return def
61+
Just s -> flip (withObject "Config.settings") s $ \o -> Config
62+
<$> o .:? "hlintOn" .!= hlintOn def
63+
<*> o .:? "diagnosticsOnChange" .!= diagnosticsOnChange def
64+
<*> o .:? "maxNumberOfProblems" .!= maxNumberOfProblems def
65+
<*> o .:? "diagnosticsDebounceDuration" .!= diagnosticsDebounceDuration def
66+
<*> o .:? "liquidOn" .!= liquidOn def
67+
<*> o .:? "completionSnippetsOn" .!= completionSnippetsOn def
68+
<*> o .:? "formatOnImportOn" .!= formatOnImportOn def
69+
<*> o .:? "formattingProvider" .!= formattingProvider def
6870

6971
-- 2017-10-09 23:22:00.710515298 [ThreadId 11] - ---> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"haskell":{"maxNumberOfProblems":100,"hlintOn":true}}}}
7072
-- 2017-10-09 23:22:00.710667381 [ThreadId 15] - reactor:got didChangeConfiguration notification:

0 commit comments

Comments
 (0)