Description
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
haskell-language-server-wrapper --probe-tools
haskell-language-server version: 1.8.0.0 (GHC: 9.2.4) (PATH: /home/andreas/.ghcup/bin/haskell-language-server-wrapper-1.8.0.0)
Tool versions found on the $PATH
cabal: 3.8.1.0
stack: 2.9.1
ghc: 9.2.4
Tool versions in your project
ghc: 9.2.4