-
-
Notifications
You must be signed in to change notification settings - Fork 390
Complete contributing guide #2165
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
Changes from all commits
8724c83
2be4ee3
43456b2
adbd955
b4166d2
64490cc
2c2db81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,13 +6,6 @@ The Haskell tooling dream is near, we need your help! | |||||
- Follow the [Haskell IDE team twitter account](https://twitter.com/IdeHaskell) for updates and help. | ||||||
- Join the [#haskell-tooling channel](https://discord.com/channels/280033776820813825/505370075402862594/808027763868827659) in the Functional Programming discord server. You can join the server via [this invitation](https://discord.gg/9spEdTNGrD). | ||||||
|
||||||
## 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. | ||||||
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. | ||||||
|
||||||
## Building haskell-language-server | ||||||
|
||||||
The project can be built with both `cabal build` and `stack build`. | ||||||
|
@@ -72,11 +65,52 @@ To create binaries: | |||||
|
||||||
GHC 8.6.5 is not supported here because `nixpkgs-unstable` no longer maintains the corresponding packages set. | ||||||
|
||||||
## Introduction tutorial | ||||||
## Testing | ||||||
|
||||||
See the [tutorial](./plugin-tutorial.md) on writing a plugin in HLS. | ||||||
The tests make use of the [Tasty](https://github.com/feuerbach/tasty) test framework. | ||||||
|
||||||
There are two test suites in the main haskell-language-server package, functional tests, and wrapper tests. | ||||||
Other project packages, like the core library or plugins, can have their own test suite. | ||||||
|
||||||
### Testing with Cabal | ||||||
|
||||||
Running all the tests | ||||||
|
||||||
```bash | ||||||
$ cabal test | ||||||
``` | ||||||
|
||||||
Running just the functional tests | ||||||
|
||||||
```bash | ||||||
$ cabal test func-test | ||||||
``` | ||||||
|
||||||
Running just the wrapper tests | ||||||
|
||||||
```bash | ||||||
$ cabal test wrapper-test | ||||||
``` | ||||||
|
||||||
Running a subset of tests | ||||||
|
||||||
Tasty supports providing | ||||||
[Patterns](https://github.com/feuerbach/tasty#patterns) as command | ||||||
line arguments, to select the specific tests to run. | ||||||
|
||||||
```bash | ||||||
$ cabal test func-test --test-option "-p hlint" | ||||||
``` | ||||||
|
||||||
## Test your hacked HLS in your editor | ||||||
The above recompiles everything every time you use a different test option though. | ||||||
|
||||||
An alternative, which only recompiles when tests (or dependencies) change: | ||||||
|
||||||
```bash | ||||||
$ cabal run haskell-language-server:func-test -- -p "hlint enables" | ||||||
``` | ||||||
|
||||||
### Test your hacked HLS in your editor | ||||||
|
||||||
If you want to test HLS while hacking on it, follow the steps below. | ||||||
|
||||||
|
@@ -97,6 +131,59 @@ To do every time you changed code and want to test it: | |||||
- Restart HLS | ||||||
- With VS Code: `Haskell: Restart Haskell LSP Server` | ||||||
|
||||||
## 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. | ||||||
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. | ||||||
|
||||||
### Formatter pre-commit hook | ||||||
|
||||||
We are using [pre-commit-hook.nix](https://github.com/cachix/pre-commit-hooks.nix) to configure git pre-commit hook for formatting. Although it is possible to run formatting manually, we recommend you to use it to set pre-commit hook as our CI checks pre-commit hook is applied or not. | ||||||
|
||||||
You can configure the pre-commit-hook by running | ||||||
|
||||||
``` bash | ||||||
nix-shell | ||||||
``` | ||||||
|
||||||
If you don't want to use [nix](https://nixos.org/guides/install-nix.html), you can instead use [pre-commit](https://pre-commit.com) with the following config. | ||||||
|
||||||
```json | ||||||
{ | ||||||
"repos": [ | ||||||
{ | ||||||
"hooks": [ | ||||||
{ | ||||||
"entry": "stylish-haskell --inplace", | ||||||
"exclude": "(^Setup.hs$|test/testdata/.*$|test/data/.*$|^hie-compat/.*$|^plugins/hls-tactics-plugin/.*$)", | ||||||
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. Note: we need to update this regex to include up-to-date "excludes" setting in nix config. The current Nix config ignores more files than these. 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.
Suggested change
that would be correct? 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. wow i did not apply this commit 🤦 |
||||||
"files": "\\.l?hs$", | ||||||
"id": "stylish-haskell", | ||||||
"language": "system", | ||||||
"name": "stylish-haskell", | ||||||
"pass_filenames": true, | ||||||
"types": [ | ||||||
"file" | ||||||
] | ||||||
} | ||||||
], | ||||||
"repo": "local" | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
|
||||||
#### Why some components are excluded from automatic formatting? | ||||||
|
||||||
- `test/testdata` and `test/data` are there as we want to test formatting plugins. | ||||||
- `hie-compat` is there as we want to keep its code as close to GHC as possible. | ||||||
- `hls-tactics-plugin` is there as the main contributor of the plugin (@isovector) does not want auto-formatting. | ||||||
|
||||||
## Introduction tutorial | ||||||
|
||||||
See the [tutorial](./plugin-tutorial.md) on writing a plugin in HLS. | ||||||
|
||||||
## Adding support for a new editor | ||||||
|
||||||
Adding support for new editors is fairly easy if the editor already has good support for generic LSP-based extensions. | ||||||
|
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.
I don't think this works. It will use the HLS binary in your path, not the development build
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.
it seems this can make it not use the PATH one:
haskell-language-server/haskell-language-server.cabal
Lines 417 to 419 in 155023f
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.
No, that won't help.
cabal run
does not change the environment, as far as I know.You can do
cabal exec cabal run h-l-s:func-test -- -- -p ...
and it will work sometimesThere 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.
It seems so: haskell/cabal#5411 (comment). It works for
cabal test
but no forcabal run
iiuic that commentIt works enough times to update the instructions? are you are referring to the fact
cabal exec
will not rebuild the executable and you could end using a older version?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.
Moreover with cabal-install-3.8, test arguments will not trigger a rebuild
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.
I believe
cabal exec
does trigger a rebuild, but it fails with weird errors in some cases.