-
-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use default config on missing configuration section #459
Use default config on missing configuration section #459
Conversation
993f4a8
to
c3c0499
Compare
src/Ide/Main.hs
Outdated
t <- t | ||
hPutStrLn stderr $ "Started LSP server in " ++ showDuration t | ||
sessionLoader <- loadSession dir | ||
-- config <- fromMaybe defaultLspConfig <$> getConfig | ||
config <- fromMaybe def <$> getConfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about dont add the DefaultConfig constructor, keeping the actual definition and only check here that there is no client config doing a pattern matching on Maybe
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we make the parsing always successful, I believe getConfig
will never return Nothing
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to think that to add alert message that we fallback to default config will require a change in haskell-lsp
instead around these lines here. There should be a way for us to specify the default config when parsing error occurs.
* Suggest missing imports via package exports map At the expense of some space and initialization time, suggest imports now is able to find suggestions in all the packages available to the project. * BadDependency - include the key in the error message * remove the assumption that the GhcSession is always available * fix bad spacing Co-Authored-By: Moritz Kiefer <moritz.kiefer@purelyfunctional.org> * Add type annotation to clarify rule being defined * Remove file dependency from PackageExports rule * Guess patterns Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
66ada8c
to
d4f5d43
Compare
Hi, there is a recent open issue about that (#1196) and the fix is already here so i think we have to unblock this. |
How do we know that this fix works? I see no test |
data Config | ||
= DefaultConfig | ||
| UserConfig Bool Bool Int Int Bool Bool Bool T.Text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not good enough. Please restore the field names or use Haddock comments to label the fields
The parser should be able to handle the empty object, since that's a valid configuration as all the configuration flags are optional. On the other hand, if a field is the wrong type, the parser should fail and HLS should error out. The approach taken by this PR is reasonable, but the implementation is a bit convoluted. I would handle this by making all the configuration fields optional, which is equivalent but easier to understand. |
Sorry I haven't write the test because I wasn't sure if it should be done like this. I'll add the tests soon. |
I actually have a question for the suggested approach here. I'm quite new to Haskell so I'm not familiar how we do things in Haskell. So one of the comment I received above asked to make it so if user typed a wrong configuration key, we should print a message. If we make the configuration fields all optional, how do we determine if a value of I also have question regarding potential code duplication if we resolve |
If a user makes a typo in the configuration key, this will not result in an error with the current implementation. Is that what you are asking?
What do you mean by resolve here? Perhaps this blog post is helpful: https://reasonablypolymorphic.com/blog/higher-kinded-data/ |
Yes, and it also does not log any error message. The reason I introduced a new constructor for
Ah this seems to be what I need here. Thanks! I suppose I can also use it to check if the |
I would prefer to keep this PR focused, and just fix the issue with |
Actually if it's just fixing the issue with |
Looks good to me |
c3c0499
to
f875fe6
Compare
Sorry for the delay, took me quite a while to understand lenses for implementing the test. I keep the record definition but it doesn't print any message if the key is not detected for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
e39c054
to
20de9be
Compare
Hmm, not sure why my test always timed out on (8.10.3, ubuntu-latest) |
20de9be
to
9b21da1
Compare
It seems the server does not always send log notification after config change. I updated the test code to throw dummy response so it'll not block waiting for response. |
@Ailrun Were you about to merge this to master? I see that you make a merge commit to merge master to this branch instead. |
I'm actually waiting for @jneira's approval. I made the merge commit to check that it still works with many other recent changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm too, thanks for the pr and the patience!
It looks like some formatter tests fail. Could you check it? |
On serving initialize request, deserializing HIE configuration embedded in InitializeParam passed by client will result in an error if during 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.
d1b5b71
to
4fa8c8f
Compare
Hi, I've made a change to make default configuration to be used if
initializationOptions
doesn't havehaskell
orlanguageServerHaskell
key in it. There are some issue where the server returnshaskell-lsp: configuration parse error.
. This change shouldn't break any existing configuration because it adds safety net instead of straight failing.Also, I actually made the same change to haskell/haskell-ide-engine#1802 first before realizing there's a new project. I'm not sure if this can be considered as bug fix, so I'll keep it open there.