-
-
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
Add docs on how to choose a formatter #432
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ This is *very* early stage software. | |
- [Building](#building) | ||
- [Install via cabal](#install-via-cabal) | ||
- [Install specific GHC Version](#install-specific-ghc-version) | ||
- [HLS LSP Configuration](#hls-lsp-configuration) | ||
- [Project Configuration](#project-configuration) | ||
- [Editor Integration](#editor-integration) | ||
- [VS Code](#using-haskell-language-server-with-vs-code) | ||
|
@@ -207,7 +208,7 @@ The script will install the executables `haskell-language-server-wrapper` and `h | |
It will copy the latter appending the used ghc version, needed by the wrapper to choose the suitable version | ||
for the project at hand. | ||
|
||
So installing the executables directly with `stack install` or `cabal v2-install` may not be enough | ||
So installing the executables directly with `stack install` or `cabal v2-install` may not be enough | ||
for it to work properly. | ||
|
||
Install haskell-language-server for the latest available and supported GHC version (and hoogle docs): | ||
|
@@ -253,6 +254,40 @@ If your desired ghc has been found, you use it to install haskell-language-serve | |
./cabal-hls-install data | ||
``` | ||
|
||
## HLS LSP Configuration | ||
|
||
haskell-language-server supports some forms of configuration. | ||
|
||
This configuration is done via the LSP settings you provide with your editor and/or LSP client. | ||
Some examples include: | ||
* in VSCode/VSCodium this is done via the `Settings` tab | ||
* with `LanguageClient-neovim` you can point the [`g:LanguageClient_settingsPath`](https://github.com/autozimu/LanguageClient-neovim/blob/0e5c9546bfddbaa2b01e5056389c25aefc8bf989/doc/LanguageClient.txt#L221) | ||
variable to the file in which you want to keep your LSP settings | ||
|
||
### Formatting providers | ||
By default, haskell-language-server is compiled with support for several different formatters. | ||
|
||
These include | ||
* `floskell` | ||
* `fourmolu` | ||
* `ormolu` | ||
* `stylish-haskell` | ||
* `brittany` (if compiled with AGPL) | ||
|
||
To choose one of them, you need to include the name of the one you want to use | ||
as the value for the `formattingProvider` key in your LSP configuration like so: | ||
```json | ||
{ | ||
... | ||
"haskell": { | ||
... | ||
"formattingProvider": "fourmolu" | ||
... | ||
} | ||
... | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this lsp configuration? I have never seen that one. What should be the name of this file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm assuming it is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is specific to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assumed it is generic, because I couldn't find another way of choosing a formatter. How do you do so in your editor+client? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VSCode / VSCodium has a settings Tab where you can choose the formatter out of a dropbox menu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok makes sense, so this configuration's location is still editor dependent. We should make this clear and maybe refer to the documentation of the respective lsp-client. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed some "clarification", is it ok? I'm also not sure how good an idea being this specific as I was is, because while it's helpful for someone who has never used their respective LSP client before, it might get outdated and is in a way "redundant" information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite client-specific. For example, in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But there should still be some mention that you can put such a field into your client's configuration, whatever that may be. If it didn't exist in the changelog you would have to read through source code to learn about this. Besides, there is already precedent for descriptions on how to configure different clients for use with HLS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think I'm the only one who found it took effort to find this out either: |
||
``` | ||
|
||
## Project Configuration | ||
|
||
**For a full explanation of possible configurations, refer to [hie-bios/README](https://github.com/mpickering/hie-bios/blob/master/README.md).** | ||
|
@@ -575,7 +610,7 @@ This returns an error in HLS if 'tasty-discover' is not in the path: `could not | |
### Style guidelines | ||
|
||
The project includes a [`.editorconfig`](https://editorconfig.org) [file](https://github.com/haskell/haskell-language-server/blob/master/.editorconfig) with the editor basic settings used by the project. | ||
However, most editors will need some action to honour those settings automatically. | ||
However, most editors will need some action to honour those settings automatically. | ||
For example vscode needs to have installed a specific [extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig). | ||
Please, try to follow those basic settings to keep the codebase as uniform as possible. | ||
|
||
|
@@ -616,7 +651,7 @@ If you want to test HLS while hacking on it, follow the steps below. | |
To do once: | ||
- Open some codebase on which you want to test your hacked HLS in your favorite editor | ||
- Configure this editor to use your custom HLS executable | ||
- With Cabal: | ||
- With Cabal: | ||
- On Unix systems: `cabal exec which haskell-language-server` | ||
- On Windows: `cabal exec where haskell-language-server` | ||
- With Stack: `$(stack path --dist-dir)/build/haskell-language-server/haskell-language-server` | ||
|
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.
For what editor? For all? Is that a HLS configuration I was not aware of?
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.
Apparently so, I took this information from the changelog