Skip to content

Commit 85beafe

Browse files
authored
Merge pull request #566 from fendor/polish/add-prettier-script
Add prettier script
2 parents b80f636 + 9912fdb commit 85beafe

File tree

12 files changed

+79
-60
lines changed

12 files changed

+79
-60
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Create a report to help us improve
44
title: ''
55
labels: 'status: needs triage'
66
assignees: ''
7-
87
---
98

109
<!--
@@ -16,18 +15,23 @@ When filing an issue, please fill out as much of the information below as you ca
1615
### Your environment
1716

1817
Which OS do you use:
18+
1919
<!-- Windows, MacOS, Ubuntu, ArchLinux, etc... -->
2020

2121
### Steps to reproduce
22+
2223
<!-- Tell us how to reproduce this issue, including screenshots if you think they can be useful -->
2324

2425
### Expected behaviour
26+
2527
<!-- Tell us what should happen. -->
2628

2729
### Actual behaviour
30+
2831
<!-- Tell us what happens instead. -->
2932

3033
### Include debug information
34+
3135
Execute in the root of your project the command `haskell-language-server-wrapper --debug .` and paste the logs here (you can find the executable location [here](https://github.com/haskell/vscode-haskell#downloaded-binaries)):
3236

3337
<details>
@@ -38,6 +42,7 @@ Debug output:
3842
```
3943
<paste your logs here>
4044
```
45+
4146
</details>
4247

4348
Paste the contents of extension specific log, you can check instructions about how to find it [here](https://github.com/haskell/vscode-haskell#troubleshooting)
@@ -50,4 +55,5 @@ Extension log:
5055
```
5156
<paste your logs here>
5257
```
58+
5359
</details>

.github/ISSUE_TEMPLATE/feature_request.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
uses: haskell/actions/setup@v1
3030
with:
3131
ghc-version: ${{ matrix.ghc }}
32-
- name: "Install `tree` for MacOs"
32+
- name: 'Install `tree` for MacOs'
3333
run: |
3434
brew update
3535
brew install tree
3636
if: runner.os == 'macOS'
37-
- name: "Install `tree` for Windows"
37+
- name: 'Install `tree` for Windows'
3838
run: |
3939
choco install tree
4040
if: runner.os == 'Windows'

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
test-workspace/
3+
.vscode/
4+
.vscode-test/
5+
out/
6+
dist/
7+
webpack.config.js

README.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ either globally or per project. E.g.:
112112

113113
```json
114114
{
115-
"haskell.toolchain": {
116-
"hls": "1.6.1.1",
117-
"cabal": "recommended",
118-
"stack": null
119-
}
115+
"haskell.toolchain": {
116+
"hls": "1.6.1.1",
117+
"cabal": "recommended",
118+
"stack": null
119+
}
120120
}
121121
```
122122

@@ -131,11 +131,11 @@ Another config could be:
131131

132132
```json
133133
{
134-
"haskell.toolchain": {
135-
"ghc": "9.2.2",
136-
"hls": "latest"
137-
"cabal": "recommended"
138-
}
134+
"haskell.toolchain": {
135+
"ghc": "9.2.2",
136+
"hls": "latest",
137+
"cabal": "recommended"
138+
}
139139
}
140140
```
141141

@@ -151,11 +151,10 @@ The defaults (when omitted) are as follows:
151151
1. install the project required `ghc` (corresponding to `with-compiler` setting in `cabal.project` for example)
152152
2. install the latest `hls` version that supports the project required ghc version
153153
3. install latest `cabal`
154-
3. install latest `stack`
154+
4. install latest `stack`
155155

156156
When a the value is `null`, the extension will refrain from installing it.
157157

158-
159158
### Supported GHC versions
160159

161160
These are the versions of GHC that there are binaries of `haskell-language-server-1.6.1` for. Building from source may support more versions!
@@ -204,18 +203,16 @@ Please include the output when filing any issues on the [haskell-language-server
204203

205204
- Sometimes the language server might get stuck in a rut and stop responding to your latest changes.
206205
Should this occur you can try restarting the language server with <kbd>Ctrl</kbd> <kbd>shift</kbd> <kbd>P</kbd>/<kbd>⌘</kbd> <kbd>shift</kbd> <kbd>P</kbd> > Restart Haskell LSP Server.
207-
206+
208207
#### `Cradle requires ghc/cabal/stack but it isn't installed`
209208

210209
- In Linux/MacOS systems, opening vscode in the windows system could not use the `$PATH` set in the shell
211210
so it will not see required tools as ghc, cabal or stack. This usually happens if you have installed them
212-
via ghcup.
213-
- It could be fixed changing the `$PATH` variable in the init config file used by the windows system
211+
via ghcup.
212+
- It could be fixed changing the `$PATH` variable in the init config file used by the windows system
214213
(f.e. `~/.profile`, but i can vary depending on your system setup).
215214
- See [this stackoverflow question](https://stackoverflow.com/questions/43983718/set-global-path-environment-variable-in-vs-code) for more tricks.
216215

217-
218-
219216
## Contributing
220217

221218
If you want to help, get started by reading [Contributing](https://github.com/haskell/vscode-haskell/blob/master/Contributing.md) for more details.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@
421421
"tslint-fix": "tslint --fix -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
422422
"push-tag": "git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version",
423423
"pretest": "tsc -p ./",
424+
"format": "prettier . --write",
424425
"test": "node ./out/test/runTest.js"
425426
},
426427
"husky": {
@@ -447,7 +448,7 @@
447448
"glob": "^7.1.4",
448449
"husky": "^7.0.2",
449450
"mocha": "^9.2.1",
450-
"prettier": "^2.5.1",
451+
"prettier": "^2.6.2",
451452
"pretty-quick": "^3.1.2",
452453
"set-value": ">=4.0.1",
453454
"ts-loader": "^9.2.8",

src/commands/importIdentifier.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
import * as bent from 'bent';
12
import * as cheerio from 'cheerio';
23
import * as yaml from 'js-yaml';
34
import escapeRegExp from 'lodash-es/escapeRegExp';
45
import * as LRUCache from 'lru-cache';
5-
import * as bent from 'bent';
66
import * as vscode from 'vscode';
77
import { CommandNames } from './constants';
88

99
const getJson = bent('json');
1010

1111
const askHoogle = async (variable: string): Promise<any> => {
12-
return await getJson(
13-
`https://hoogle.haskell.org/?hoogle=${variable}&scope=set%3Astackage&mode=json`
14-
);
12+
return await getJson(`https://hoogle.haskell.org/?hoogle=${variable}&scope=set%3Astackage&mode=json`);
1513
};
1614

1715
const withCache =

src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
276276
* Deactivate each of the LSP servers.
277277
*/
278278
export async function deactivate() {
279-
const promises: Array<Thenable<void>> = [];
279+
const promises: Thenable<void>[] = [];
280280
for (const client of clients.values()) {
281281
if (client) {
282282
promises.push(client.stop());

src/hlsBinaries.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,12 @@ export async function findHaskellLanguageServer(
280280
await upgradeGHCup(context, logger);
281281

282282
// boring init
283-
let latestHLS: string | undefined | null = undefined;
284-
let latestCabal: string | undefined | null = undefined;
285-
let latestStack: string | undefined | null = undefined;
283+
let latestHLS: string | undefined | null;
284+
let latestCabal: string | undefined | null;
285+
let latestStack: string | undefined | null;
286286
let recGHC: string | undefined | null = 'recommended';
287-
let projectHls: string | undefined | null = undefined;
288-
let projectGhc: string | undefined | null = undefined;
287+
let projectHls: string | undefined | null;
288+
let projectGhc: string | undefined | null;
289289

290290
// support explicit toolchain config
291291
const toolchainConfig: ToolConfig = new Map(

test/runTest.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ function installExtension(vscodeExePath: string, extId: string) {
1515

1616
async function main() {
1717
try {
18-
const vscodeExecutablePath = await downloadAndUnzipVSCode('stable'
19-
, process.platform === 'win32' ? 'win32-x64-archive' : undefined);
18+
const vscodeExecutablePath = await downloadAndUnzipVSCode(
19+
'stable',
20+
process.platform === 'win32' ? 'win32-x64-archive' : undefined
21+
);
2022

2123
// We have to install this dependant extension
2224
installExtension(vscodeExecutablePath, 'justusadam.language-haskell');

test/suite/extension.test.ts

+33-24
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ async function withTimeout(seconds: number, f: Promise<any>) {
1818
return Promise.race([f, delay(seconds)]);
1919
}
2020

21-
const wait = (ms: number) => new Promise(r => setTimeout(r, ms));
22-
23-
const retryOperation = (operation: () => Promise<any>, delay: number, retries: number) => new Promise((resolve, reject): Promise<any> => {
24-
return operation()
25-
.then(resolve)
26-
.catch((reason) => {
27-
if (retries > 0) {
28-
return wait(delay)
29-
.then(retryOperation.bind(null, operation, delay, retries - 1))
30-
.then(resolve)
31-
.catch(reject);
32-
}
33-
return reject(reason);
34-
});
35-
});
36-
21+
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
22+
23+
const retryOperation = (operation: () => Promise<any>, delay: number, retries: number) =>
24+
new Promise((resolve, reject): Promise<any> => {
25+
return operation()
26+
.then(resolve)
27+
.catch((reason) => {
28+
if (retries > 0) {
29+
return wait(delay)
30+
.then(retryOperation.bind(null, operation, delay, retries - 1))
31+
.then(resolve)
32+
.catch(reject);
33+
}
34+
return reject(reason);
35+
});
36+
});
3737

3838
function getHaskellConfig() {
3939
return vscode.workspace.getConfiguration('haskell');
@@ -89,7 +89,8 @@ async function deleteFiles(dir: vscode.Uri, keepDirs: vscode.Uri[], pred?: (file
8989
await deleteFiles(subDirectory, keepDirs, pred);
9090

9191
// remove directory if it is empty now
92-
const isEmptyNow = await vscode.workspace.fs.readDirectory(subDirectory)
92+
const isEmptyNow = await vscode.workspace.fs
93+
.readDirectory(subDirectory)
9394
.then((contents) => Promise.resolve(contents.length === 0));
9495
if (isEmptyNow) {
9596
console.log(`Deleting ${subDirectory}`);
@@ -125,11 +126,10 @@ suite('Extension Test Suite', () => {
125126

126127
suiteSetup(async () => {
127128
const tmpdir = path.join(getWorkspaceRoot().uri.fsPath, 'tmp');
128-
await deleteWorkspaceFiles(
129-
[ joinUri(getWorkspaceRoot().uri, '.vscode')
130-
, joinUri(getWorkspaceRoot().uri, 'bin', process.platform === 'win32' ? 'ghcup' : '.ghcup', 'cache')
131-
]
132-
);
129+
await deleteWorkspaceFiles([
130+
joinUri(getWorkspaceRoot().uri, '.vscode'),
131+
joinUri(getWorkspaceRoot().uri, 'bin', process.platform === 'win32' ? 'ghcup' : '.ghcup', 'cache'),
132+
]);
133133
await getHaskellConfig().update('promptBeforeDownloads', false, vscode.ConfigurationTarget.Global);
134134
await getHaskellConfig().update('manageHLS', 'GHCup');
135135
await getHaskellConfig().update('logFile', 'hls.log');
@@ -185,8 +185,17 @@ suite('Extension Test Suite', () => {
185185
await delay(20);
186186
const logContents = getExtensionLogContent();
187187
assert.ok(logContents, 'Extension log file does not exist');
188-
assert.ok(retryOperation(() => new Promise((resolve, reject) => (logContents.match(/INFO hls:\s+Registering ide configuration/) !== null) ? resolve : reject), 1000 * 5, 20),
189-
'Extension log file has no hls output');
188+
assert.ok(
189+
retryOperation(
190+
() =>
191+
new Promise((resolve, reject) =>
192+
logContents.match(/INFO hls:\s+Registering ide configuration/) !== null ? resolve : reject
193+
),
194+
1000 * 5,
195+
20
196+
),
197+
'Extension log file has no hls output'
198+
);
190199
});
191200

192201
test('Server should inherit environment variables defined in the settings', async () => {

yarn.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1926,9 +1926,9 @@ prelude-ls@^1.2.1:
19261926
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz"
19271927
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==
19281928

1929-
prettier@^2.5.1:
1929+
prettier@^2.6.2:
19301930
version "2.6.2"
1931-
resolved "https://registry.npmjs.org/prettier/-/prettier-2.6.2.tgz"
1931+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
19321932
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==
19331933

19341934
pretty-quick@^3.1.2:

0 commit comments

Comments
 (0)