Skip to content

Commit d1d7ce0

Browse files
jneirajhrcekmergify[bot]
authored
Complete contributing guide (#2165)
* Complete contributing guide With the contents of ./CONTRIBUTING.md (mainly the pre commit hook to format) * Delete CONTRIBUTING.md Included in the main documentation * Move style guidelines As building and testing are more important imo * Correct grammar Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com> * Note cabal run behaviour Co-Authored-By: jhrcek Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent baaee98 commit d1d7ce0

File tree

2 files changed

+97
-96
lines changed

2 files changed

+97
-96
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 86 deletions
This file was deleted.

docs/contributing/contributing.md

Lines changed: 97 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ The Haskell tooling dream is near, we need your help!
66
- Follow the [Haskell IDE team twitter account](https://twitter.com/IdeHaskell) for updates and help.
77
- 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).
88

9-
## Style guidelines
10-
11-
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.
12-
However, most editors will need some action to honour those settings automatically.
13-
For example vscode needs to have installed a specific [extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig).
14-
Please, try to follow those basic settings to keep the codebase as uniform as possible.
15-
169
## Building haskell-language-server
1710

1811
The project can be built with both `cabal build` and `stack build`.
@@ -72,11 +65,52 @@ To create binaries:
7265

7366
GHC 8.6.5 is not supported here because `nixpkgs-unstable` no longer maintains the corresponding packages set.
7467

75-
## Introduction tutorial
68+
## Testing
7669

77-
See the [tutorial](./plugin-tutorial.md) on writing a plugin in HLS.
70+
The tests make use of the [Tasty](https://github.com/feuerbach/tasty) test framework.
71+
72+
There are two test suites in the main haskell-language-server package, functional tests, and wrapper tests.
73+
Other project packages, like the core library or plugins, can have their own test suite.
74+
75+
### Testing with Cabal
76+
77+
Running all the tests
78+
79+
```bash
80+
$ cabal test
81+
```
82+
83+
Running just the functional tests
84+
85+
```bash
86+
$ cabal test func-test
87+
```
88+
89+
Running just the wrapper tests
90+
91+
```bash
92+
$ cabal test wrapper-test
93+
```
94+
95+
Running a subset of tests
96+
97+
Tasty supports providing
98+
[Patterns](https://github.com/feuerbach/tasty#patterns) as command
99+
line arguments, to select the specific tests to run.
100+
101+
```bash
102+
$ cabal test func-test --test-option "-p hlint"
103+
```
78104

79-
## Test your hacked HLS in your editor
105+
The above recompiles everything every time you use a different test option though.
106+
107+
An alternative, which only recompiles when tests (or dependencies) change:
108+
109+
```bash
110+
$ cabal run haskell-language-server:func-test -- -p "hlint enables"
111+
```
112+
113+
### Test your hacked HLS in your editor
80114

81115
If you want to test HLS while hacking on it, follow the steps below.
82116

@@ -97,6 +131,59 @@ To do every time you changed code and want to test it:
97131
- Restart HLS
98132
- With VS Code: `Haskell: Restart Haskell LSP Server`
99133

134+
## Style guidelines
135+
136+
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.
137+
However, most editors will need some action to honour those settings automatically.
138+
For example vscode needs to have installed a specific [extension](https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig).
139+
Please, try to follow those basic settings to keep the codebase as uniform as possible.
140+
141+
### Formatter pre-commit hook
142+
143+
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.
144+
145+
You can configure the pre-commit-hook by running
146+
147+
``` bash
148+
nix-shell
149+
```
150+
151+
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.
152+
153+
```json
154+
{
155+
"repos": [
156+
{
157+
"hooks": [
158+
{
159+
"entry": "stylish-haskell --inplace",
160+
"exclude": "(^Setup.hs$|test/testdata/.*$|test/data/.*$|^hie-compat/.*$|^plugins/hls-tactics-plugin/.*$)",
161+
"files": "\\.l?hs$",
162+
"id": "stylish-haskell",
163+
"language": "system",
164+
"name": "stylish-haskell",
165+
"pass_filenames": true,
166+
"types": [
167+
"file"
168+
]
169+
}
170+
],
171+
"repo": "local"
172+
}
173+
]
174+
}
175+
```
176+
177+
#### Why some components are excluded from automatic formatting?
178+
179+
- `test/testdata` and `test/data` are there as we want to test formatting plugins.
180+
- `hie-compat` is there as we want to keep its code as close to GHC as possible.
181+
- `hls-tactics-plugin` is there as the main contributor of the plugin (@isovector) does not want auto-formatting.
182+
183+
## Introduction tutorial
184+
185+
See the [tutorial](./plugin-tutorial.md) on writing a plugin in HLS.
186+
100187
## Adding support for a new editor
101188

102189
Adding support for new editors is fairly easy if the editor already has good support for generic LSP-based extensions.

0 commit comments

Comments
 (0)