-
-
Notifications
You must be signed in to change notification settings - Fork 390
Improve duration until format is possible #3282
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
Comments
My guess is that we block everything on initializing the cradle, which takes a while. After that so long as the formatter doesn't depend on e.g. the typechecked source it should be fast. Note that many of our formatters rely on knowing the extensions that are in use in a file, which I think we ultimately get from the GHC flags for the file, which does depend on the build tool giving us the build flags. So it may be a genuine dependency. |
Mhm, like this: haskell-language-server/plugins/hls-stylish-haskell-plugin/src/Ide/Plugin/StylishHaskell.hs Line 33 in 2255740
|
Yeah, that's pretty explicitly depending on GHC stuff being done for the module. Interestingly, in that case I think you could rearrange it so we don't even run the rule at all if we get the extensions from the config file... but in general I think this is going to be a pretty common dependency path for formatters. |
Do you think the issue can realistically be improved or should it rather be closed? |
I don't think this can be realistically improved, without sacrificing usability or correctness. E.g., configs might contain language extensions, but who knows whether it lists all? If the behaviour isn't uniform, I think usability suffers. However, maybe we can cache the last known ghc-options for a filepath and use that for formatting on subsequent starts? Might affect correctness, though. |
I guess I would say that there's a big topic which is something like "time until usable". There are probably things we can do there, but they're probably going to be ones that improve things generally, I don't think we can do anything much for formatters specifically 🤷 |
Since formatting doesn't seem to be independent of information we're gathering on initialization, I also think the ticket should be closed. |
Is your enhancement request related to a problem? Please describe.
It takes quite some time until the language server can be used to format a file. This is likely due to the way haskell-language-server loads a session and does multiple things on initialization. But: Especially formatting could be possible early. Especially if a process is forked to do the work (fourmolu). E.g.
purescript-language-server
allows formatting and still shows that initialization is in progress. So in theory it could be possible to format files before HLS has finished initialization.Demo
Here is a demo with a small project (https://github.com/andys8/git-brunch).
screencast-2022-10-11_14.43.53.mp4
Format is possible after 13 seconds. For larger projects or without caches this should take longer.
For comparison
haskell-language-server-wrapper .
takes 16 seconds.Describe the solution you'd like
Allow formatting files earlier (if possible) while the session is still being loaded.
Describe alternatives you've considered
An alternative is to use a separate plugin to use format files. But in that case we wouldn't need any integration of formatters in HLS. So I wouldn't consider this being an alternative solution.
Another alternative would be to focus on general improvements to make the startup time faster.
Additional context
The text was updated successfully, but these errors were encountered: