Skip to content
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

Refactor LSP logger and log via window/logMessage also #2758

Merged
merged 3 commits into from Mar 8, 2022

Conversation

michaelpj
Copy link
Collaborator

@michaelpj michaelpj commented Mar 6, 2022

Also adds a logger that forwards on messages via window/logMessage.

Comment on lines 294 to 299
-> Maybe (MVar (LSP.LanguageContextEnv Config))
-- ^ Variable to be filled with the LSP environment, useful for tools that need this outside
-- the scope of runLanguageServer
-> Arguments
-> IO ()
defaultMain recorder lspEnvVar Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats recorder) fun
Copy link
Collaborator

@pepeiborra pepeiborra Mar 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MVar is an implementation detail, better hide it behind a callback, or a hook to run an Lsp action on initialisation.

And please move it to the Arguments record, to keep the API simple and minimise the breakage

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure about whether to put it in Arguments, in some places there seems to be an assumption that it reflects CLI arguments. But yeah, it seems better in there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up putting it in the Arguments record for ghcide but not HLS: the HLS Arguments are very tightly coupled to argument parsing, expect to be Show-able etc, so it really didn't fit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the Arguments datatype passed to defaultMain, that is Development.IDE.Main.Arguments.
Sorry I wasn't more specific.

@wz1000
Copy link
Collaborator

wz1000 commented Mar 6, 2022

Please keep in mind what happens with the command line interface, where there is no LSP environment.

@michaelpj
Copy link
Collaborator Author

Please keep in mind what happens with the command line interface, where there is no LSP environment.

That should be fine, although it does suggest to me that we should use a bounded queue for the backlog: otherwise it will just accumulate logs forever because it can never send them.

@michaelpj michaelpj changed the title Refactor LSP logger to pass environment via an MVar Refactor LSP logger and log via window/logMessage also Mar 8, 2022
@michaelpj
Copy link
Collaborator Author

Okay, this is now a much more modest refactoring that still uses the plugin technique to install the handler, and adds logging via window/logMessage.

Also I officially give @pepeiborra 1 I-told-you-so point ;)

@michaelpj michaelpj merged commit 82a3cd5 into haskell:master Mar 8, 2022
July541 pushed a commit to July541/haskell-language-server that referenced this pull request Mar 30, 2022
* Refactor LSP logger and log via `window/logMessage`

* Skip logging notifications in tests

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants