Skip to content

Commit 43b49a9

Browse files
committed
Update prettier config, and reformat code, along with making npm test the default test command
1 parent feb828b commit 43b49a9

File tree

10 files changed

+68
-48
lines changed

10 files changed

+68
-48
lines changed

.prettierrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
printWidth: 120
22
singleQuote: true
3-
trailingComma: true

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
"editor.tabSize": 2, // we want to use the TS server from our node_modules folder to control its version,
1313
"[typescript]": {
1414
"editor.formatOnSave": true
15+
},
16+
"files.associations": {
17+
".prettierrc": "yaml"
1518
}
1619
}

.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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ We recommend checking out [Your First VS Code Extension](https://code.visualstud
5757

5858
## Running tests
5959

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+
6066
* open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Launch Tests`
6167
* press `F5` to run the tests in a new window with your extension loaded
6268
* see the output of the test result in the debug console

src/commands/insertType.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export namespace InsertType {
1414
{
1515
file: editor.document.uri.toString(),
1616
pos: editor.selections[0].active,
17-
include_constraints: true,
18-
},
19-
],
17+
include_constraints: true
18+
}
19+
]
2020
};
2121

2222
// Get the current file and workspace folder.
@@ -25,7 +25,7 @@ export namespace InsertType {
2525
// If there is a client registered for this workspace, use that client.
2626
if (folder !== undefined && clients.has(folder.uri.toString())) {
2727
const client = clients.get(folder.uri.toString());
28-
client !== undefined &&
28+
if (client !== undefined) {
2929
client.sendRequest('workspace/executeCommand', ghcCmd).then(
3030
hints => {
3131
const arr = hints as Array<[Range, string]>;
@@ -52,6 +52,7 @@ export namespace InsertType {
5252
console.error(e);
5353
}
5454
);
55+
}
5556
}
5657
});
5758

src/commands/showType.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
TextDocument,
1414
TextEditor,
1515
window,
16-
workspace,
16+
workspace
1717
} from 'vscode';
1818
import { LanguageClient, Range as VLCRange } from 'vscode-languageclient';
1919

@@ -24,7 +24,7 @@ const formatExpressionType = (document: TextDocument, r: Range, typ: string): st
2424

2525
const HASKELL_MODE: DocumentFilter = {
2626
language: 'haskell',
27-
scheme: 'file',
27+
scheme: 'file'
2828
};
2929

3030
// Cache same selections...
@@ -75,9 +75,9 @@ const getCmd = (editor: TextEditor) => ({
7575
{
7676
file: editor.document.uri.toString(),
7777
pos: editor.selections[0].start,
78-
include_constraints: true,
79-
},
80-
],
78+
include_constraints: true
79+
}
80+
]
8181
});
8282

8383
export namespace ShowTypeCommand {
@@ -208,7 +208,7 @@ export namespace ShowTypeHover {
208208
private makeHover(document: TextDocument, r: Range, typ: string): Hover {
209209
return new Hover({
210210
language: 'haskell',
211-
value: formatExpressionType(document, r, typ),
211+
value: formatExpressionType(document, r, typ)
212212
});
213213
}
214214
}

src/docsBrowser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
Uri,
1313
ViewColumn,
1414
window,
15-
workspace,
15+
workspace
1616
} from 'vscode';
1717
import { ProvideHoverSignature } from 'vscode-languageclient';
1818

src/extension.ts

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import {
1010
Uri,
1111
window,
1212
workspace,
13-
WorkspaceFolder,
13+
WorkspaceFolder
1414
} from 'vscode';
1515
import {
1616
LanguageClient,
1717
LanguageClientOptions,
1818
RevealOutputChannelOn,
1919
ServerOptions,
20-
TransportKind,
20+
TransportKind
2121
} from 'vscode-languageclient';
2222
import { InsertType } from './commands/insertType';
2323
import { ShowTypeCommand, ShowTypeHover } from './commands/showType';
@@ -152,10 +152,10 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
152152
debugArgs.unshift('--lsp');
153153
}
154154
// If the extension is launched in debug mode then the debug server options are used,
155-
// otherwise the run options are used
155+
// otherwise the run options are used.
156156
const serverOptions: ServerOptions = {
157157
run: { command: serverPath, transport: TransportKind.stdio, args: runArgs },
158-
debug: { command: serverPath, transport: TransportKind.stdio, args: debugArgs },
158+
debug: { command: serverPath, transport: TransportKind.stdio, args: debugArgs }
159159
};
160160

161161
// Set a unique name per workspace folder (useful for multi-root workspaces).
@@ -166,27 +166,27 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
166166
// path for the specific workspace.
167167
documentSelector: [
168168
{ scheme: 'file', language: 'haskell', pattern: `${folder.uri.fsPath}/**/*` },
169-
{ scheme: 'file', language: 'literate haskell', pattern: `${folder.uri.fsPath}/**/*` },
169+
{ scheme: 'file', language: 'literate haskell', pattern: `${folder.uri.fsPath}/**/*` }
170170
],
171171
synchronize: {
172-
// Synchronize the setting section 'languageServerHaskell' to the server
172+
// Synchronize the setting section 'languageServerHaskell' to the server.
173173
configurationSection: 'languageServerHaskell',
174-
// Notify the server about file changes to '.clientrc files contain in the workspace
175-
fileEvents: workspace.createFileSystemWatcher('**/.clientrc'),
174+
// Notify the server about file changes to '.clientrc files contain in the workspace.
175+
fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
176176
},
177177
diagnosticCollectionName: langName,
178178
revealOutputChannelOn: RevealOutputChannelOn.Never,
179179
outputChannel,
180180
outputChannelName: langName,
181181
middleware: {
182-
provideHover: DocsBrowser.hoverLinksMiddlewareHook,
182+
provideHover: DocsBrowser.hoverLinksMiddlewareHook
183183
},
184184
// Set the current working directory, for HIE, to be the workspace folder.
185-
workspaceFolder: folder,
185+
workspaceFolder: folder
186186
};
187187

188188
// Create the LSP client.
189-
const langClient = new LanguageClient(langName, langName, serverOptions, clientOptions);
189+
const langClient = new LanguageClient(langName, langName, serverOptions, clientOptions, true);
190190

191191
if (workspace.getConfiguration('languageServerHaskell', uri).showTypeForSelection.onHover) {
192192
context.subscriptions.push(ShowTypeHover.registerTypeHover(clients));
@@ -195,7 +195,9 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
195195
if (!hieCommandsRegistered) {
196196
context.subscriptions.push(InsertType.registerCommand(clients));
197197
const showTypeCmd = ShowTypeCommand.registerCommand(clients);
198-
showTypeCmd !== null && showTypeCmd.forEach(x => context.subscriptions.push(x));
198+
if (showTypeCmd !== null) {
199+
showTypeCmd.forEach(x => context.subscriptions.push(x));
200+
}
199201
registerHiePointCommand('hie.commands.demoteDef', 'hare:demote', context);
200202
registerHiePointCommand('hie.commands.liftOneLevel', 'hare:liftonelevel', context);
201203
registerHiePointCommand('hie.commands.liftTopLevel', 'hare:lifttotoplevel', context);
@@ -210,7 +212,7 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
210212
}
211213

212214
/*
213-
* Deactivate each of the LSP servers..
215+
* Deactivate each of the LSP servers.
214216
*/
215217
export function deactivate(): Thenable<void> {
216218
const promises: Array<Thenable<void>> = [];
@@ -240,17 +242,17 @@ async function registerHiePointCommand(name: string, command: string, context: E
240242
arguments: [
241243
{
242244
file: editor.document.uri.toString(),
243-
pos: editor.selections[0].active,
244-
},
245-
],
245+
pos: editor.selections[0].active
246+
}
247+
]
246248
};
247249
// Get the current file and workspace folder.
248250
const uri = editor.document.uri;
249251
const folder = workspace.getWorkspaceFolder(uri);
250252
// If there is a client registered for this workspace, use that client.
251253
if (folder !== undefined && clients.has(folder.uri.toString())) {
252254
const client = clients.get(folder.uri.toString());
253-
client !== undefined &&
255+
if (client !== undefined) {
254256
client.sendRequest('workspace/executeCommand', cmd).then(
255257
hints => {
256258
return true;
@@ -259,6 +261,7 @@ async function registerHiePointCommand(name: string, command: string, context: E
259261
console.error(e);
260262
}
261263
);
264+
}
262265
}
263266
});
264267
context.subscriptions.push(editorCmd);

test/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as testRunner from 'vscode/lib/testrunner';
1616
// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info
1717
testRunner.configure({
1818
ui: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
19-
useColors: true, // colored output from test results
19+
useColors: true // colored output from test results
2020
});
2121

2222
module.exports = testRunner;

tslint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"promise-function-async": true,
1616
"quotemark": [true, "single", "avoid-template"],
1717
"trailing-comma": [
18-
true,
18+
false,
1919
{
2020
"multiline": {
2121
"objects": "always",

0 commit comments

Comments
 (0)