Introduce the `StatusBarItem`
The primary motivation for this PR is to make the vscode-haskell extension much friendlier for newcomers.
My idea to improve this is a StatusBarItem that looks like this:
The StatusBarItem offers the following actions:
- Print the extension version
- Open the Logs for HLS
- Restart HLS
- Restart the extension (this is useful for reloading configs, e.g.
serverExecutablePathis not picked up byRestart HLS)
My goal would be for the future to extend the features presented here, for example:
- If no server was successfully launched, the Status Bar Item should be
redand display options to help the user understand what went wrong. For example, it could offer to re-display the error message, or some kind of "debug this error" functionality. - Display the version and location of launched HLS binaries
- Set the debug level for debugging
- Display more information when downloading, etc...
That's the main motivation.
Initially, I felt it was tricky to do the kinds of changes I wanted to implement, so I went on a complete tangent and started refactoring the extension to avoid side effects, ad-hoc logic, non-uniform accesses to configuration and similar. Thus, large parts of this PR are about improving the extension to make it easier to maintain and extend. The main refactorings are:
- Proper parsing and validation of configuration
- Updating typescript code to be warnings free
- Avoid global state modification in functions and prefer return values
- Introduce more types
- Add more documentation
- Extract code into functions which are documented
- Extract
ghcupprocess management into dedicated class - and even more...
I am still unhappy with the code path for finding HLS binaries using GHCup. This is rather complicated logic, for which I couldn't extract or find a pattern, yet. Even without it, I think I am overall improving the readability of most of the extension.
I don't know how to review this huge patch, the best way is probably to check it out and trying to understand how the extension is now structured. The commits themselves are somewhat self containing, at least I tried to make sure they are.
Happy for any feedback, otherwise I will just merge it in a couple of weeks and deal with any fallout.
I just skimmed over it. I have no idea what's going on. What did you do to the code? :sob:
Can we at least make a prerelease/alpha for this before hitting users with a brick?
What did you do to the code?
It is more or less a rewrite :) It is less a rewrite, as I am not re-implementing new functionality, except for the config parsing, but I am fixing a couple of lints, removing unused functions, introducing some abstractions, more functions and move them to separate files. It is probably impossible to review from the GitHub page, you'd have to check it out, but I believe it is easier to read now.
@hasufell FYI, after the next stable release, I intend to merge this and publish it as a pre-release.