Skip to content

Commit add2aea

Browse files
authored
Merge pull request #66 from alanz/prettify
Prettify/reformat all code, add stronger TS config and lint requirements
2 parents 2317272 + 4cc0c39 commit add2aea

File tree

14 files changed

+3606
-3318
lines changed

14 files changed

+3606
-3318
lines changed

.prettierrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
printWidth: 120
2+
singleQuote: true

.vscode/settings.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// Place your settings in this file to overwrite default and user settings.
22
{
3-
"files.exclude": {
4-
"out": true, // set this to true to hide the "out" folder with the compiled JS files
5-
".vscode-test": true,
6-
"node_modules": true
7-
},
8-
"search.exclude": {
9-
"out": true // set this to false to include "out" folder in search results
10-
},
11-
"typescript.tsdk": "./node_modules/typescript/lib",
12-
"editor.tabSize": 2 // we want to use the TS server from our node_modules folder to control its version
3+
"files.exclude": {
4+
"out": true, // set this to true to hide the "out" folder with the compiled JS files
5+
".vscode-test": true,
6+
"node_modules": true
7+
},
8+
"search.exclude": {
9+
"out": true // set this to false to include "out" folder in search results
10+
},
11+
"typescript.tsdk": "./node_modules/typescript/lib",
12+
"editor.tabSize": 2, // we want to use the TS server from our node_modules folder to control its version,
13+
"editor.formatOnSave": true,
14+
"files.associations": {
15+
".prettierrc": "yaml"
16+
}
1317
}

.vscode/tasks.json

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
// See https://go.microsoft.com/fwlink/?LinkId=733558
22
// for the documentation about the tasks.json format
33
{
4-
"version": "2.0.0",
5-
"tasks": [
6-
{
7-
"type": "npm",
8-
"script": "watch",
9-
"problemMatcher": "$tsc-watch",
10-
"isBackground": true,
11-
"presentation": {
12-
"reveal": "never"
13-
},
14-
"group": {
15-
"kind": "build",
16-
"isDefault": true
17-
}
18-
}
19-
]
20-
}
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "npm",
8+
"script": "watch",
9+
"problemMatcher": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
},
19+
{
20+
"type": "npm",
21+
"script": "test",
22+
"group": {
23+
"kind": "test",
24+
"isDefault": true
25+
}
26+
}
27+
]
28+
}

Contributing.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# Contributing
2+
23
This document will briefly outline how to get started contributing to the `vscode-hie-server` Haskell language client for the [Haskell-IDE-Engine](https://github.com/haskell/haskell-ide-engine) language server.
34

45
## Dependencies and Building
6+
57
For development, all you need is to,
68

7-
- run `npm install -g typescript` to get TypeScript,
8-
- then run `npm install` in the project root to install development dependencies.
9+
* run `npm install -g typescript` to get TypeScript,
10+
* then run `npm install` in the project root to install development dependencies.
911

1012
You can now also package up the extension with,
1113

12-
- `vsce package`
14+
* `vsce package`
1315

1416
which creates an extension package at `vscode-hie-server-<version>.vsix`.
1517

1618
_Note:_ that if you get errors running `vsce package`, it might help running `tsc -p ./` directly, since that gives the actual error output of the TypeScript compilation.
1719

1820
## Developing
21+
1922
* Launch VS Code, press `File` > `Open Folder`, open the `vscode-hie-server` folder;
2023
* press `F5` to open a new window with the `vscode-hie-server` loaded (this will overwrite existing ones, e.g. from the marketplace);
21-
* open a Haskell file with the __new__ editor to test the LSP client;
24+
* open a Haskell file with the **new** editor to test the LSP client;
2225

2326
You are now ready to make changes and debug. You can,
2427

@@ -29,8 +32,18 @@ You are now ready to make changes and debug. You can,
2932

3033
_Note_: you can also reload (`Ctrl+R` or `Cmd+R` on macOS) the VS Code window with your extension to load your changes
3134

35+
#### Formatting
36+
37+
To keep a consistent style, it's best to run [prettier](https://prettier.io) on each save. If you are using VSCode, the settings are set to auto format on save.
38+
39+
There is usually an extension for your editor for prettier, e.g. [`esbenp.prettier-vscode`](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode), which you can install through the marketplace or via `ext install prettier-vscode`.
40+
41+
The configurations for prettier are located in `.prettierrc`.
42+
3243
## Navigating the Files
44+
3345
A brief overview of the files,
46+
3447
* `package.json` contains the basic information about the package, see [the full manifest for more](https://code.visualstudio.com/docs/extensionAPI/extension-manifest), such as telling VS Code which scope the LSP works on (Haskell and Literate Haskell in our case), and possible configuration
3548
* `src/extension.ts` handles activating and deactivating the HIE language server, along with checking if HIE is installed
3649
* `src/docsBrowser.ts` contains the logic for displaying the documentation browser (e.g. hover over a type like `mapM_` and click `Documentation` or `Source`)
@@ -39,12 +52,20 @@ A brief overview of the files,
3952
* `src/commands/insertType.ts` handles inserting a type using the output of `ghcmod:type`
4053

4154
## Helpful Reading Material
55+
4256
We recommend checking out [Your First VS Code Extension](https://code.visualstudio.com/docs/extensions/example-hello-world) and [Creating a Language Server](https://code.visualstudio.com/docs/extensions/example-language-server) for some introduction to VS Code extensions.
4357

4458
## Running tests
59+
60+
There are two ways to run (the same) tests, you can either
61+
62+
* press `F8` to run the tests using `npm test`
63+
64+
or
65+
4566
* open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
4667
* press `F5` to run the tests in a new window with your extension loaded
4768
* see the output of the test result in the debug console
4869
* make changes to `test/extension.test.ts` or create new test files inside the `test` folder
49-
* by convention, the test runner will only consider files matching the name pattern `**.test.ts`
50-
* you can create folders inside the `test` folder to structure your tests any way you want
70+
* by convention, the test runner will only consider files matching the name pattern `**.test.ts`
71+
* you can create folders inside the `test` folder to structure your tests any way you want

0 commit comments

Comments
 (0)