Skip to content

Commit a56274c

Browse files
committed
Add restart command.
1 parent 1667459 commit a56274c

File tree

4 files changed

+79
-26
lines changed

4 files changed

+79
-26
lines changed

package.json

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
"engines": {
99
"vscode": "^1.33.0"
1010
},
11-
"keywords": ["language", "haskell", "lsp", "multi-root ready"],
11+
"keywords": [
12+
"language",
13+
"haskell",
14+
"lsp",
15+
"multi-root ready"
16+
],
1217
"homepage": "https://github.com/alanz/vscode-hie-server",
1318
"repository": {
1419
"type": "git",
@@ -17,25 +22,43 @@
1722
"bugs": {
1823
"url": "https://github.com/alanz/vscode-hie-server/issues"
1924
},
20-
"categories": ["Programming Languages", "Formatters", "Linters", "Other"],
25+
"categories": [
26+
"Programming Languages",
27+
"Formatters",
28+
"Linters",
29+
"Other"
30+
],
2131
"icon": "images/HIE_logo_128.png",
2232
"galleryBanner": {
2333
"color": "#22172A",
2434
"theme": "dark"
2535
},
26-
"activationEvents": ["onLanguage:haskell", "onLanguage:literate haskell"],
36+
"activationEvents": [
37+
"onLanguage:haskell",
38+
"onLanguage:literate haskell"
39+
],
2740
"main": "./dist/extension",
2841
"contributes": {
2942
"languages": [
3043
{
3144
"id": "haskell",
32-
"aliases": ["Haskell", "haskell"],
33-
"extensions": [".hs"]
45+
"aliases": [
46+
"Haskell",
47+
"haskell"
48+
],
49+
"extensions": [
50+
".hs"
51+
]
3452
},
3553
{
3654
"id": "literate haskell",
37-
"aliases": ["Literate Haskell", "literate Haskell"],
38-
"extensions": [".lhs"]
55+
"aliases": [
56+
"Literate Haskell",
57+
"literate Haskell"
58+
],
59+
"extensions": [
60+
".lhs"
61+
]
3962
}
4063
],
4164
"configuration": {
@@ -59,8 +82,7 @@
5982
"scope": "resource",
6083
"type": "boolean",
6184
"default": true,
62-
"description":
63-
"Compute diagnostics continuously as you type. Turn off to only generate diagnostics on file save."
85+
"description": "Compute diagnostics continuously as you type. Turn off to only generate diagnostics on file save."
6486
},
6587
"languageServerHaskell.liquidOn": {
6688
"scope": "resource",
@@ -84,30 +106,31 @@
84106
"languageServerHaskell.formattingProvider": {
85107
"scope": "resource",
86108
"type": "string",
87-
"enum": ["brittany", "floskell", "none"],
109+
"enum": [
110+
"brittany",
111+
"floskell",
112+
"none"
113+
],
88114
"default": "brittany",
89115
"description": "The tool to use for formatting requests."
90116
},
91117
"languageServerHaskell.hieExecutablePath": {
92118
"scope": "resource",
93119
"type": "string",
94120
"default": "",
95-
"description":
96-
"Set the path to your hie executable, if it's not already on your $PATH. Works with ~, ${HOME} and ${workspaceFolder}."
121+
"description": "Set the path to your hie executable, if it's not already on your $PATH. Works with ~, ${HOME} and ${workspaceFolder}."
97122
},
98123
"languageServerHaskell.useCustomHieWrapper": {
99124
"scope": "resource",
100125
"type": "boolean",
101126
"default": false,
102-
"description":
103-
"Use your own custom wrapper for hie (remember to specify the path!). This will take precedence over useHieWrapper and hieExecutablePath."
127+
"description": "Use your own custom wrapper for hie (remember to specify the path!). This will take precedence over useHieWrapper and hieExecutablePath."
104128
},
105129
"languageServerHaskell.useCustomHieWrapperPath": {
106130
"scope": "resource",
107131
"type": "string",
108132
"default": "",
109-
"description":
110-
"Specify the full path to your own custom hie wrapper (e.g. ${HOME}/.hie-wrapper.sh). Works with ~, ${HOME} and ${workspaceFolder}."
133+
"description": "Specify the full path to your own custom hie wrapper (e.g. ${HOME}/.hie-wrapper.sh). Works with ~, ${HOME} and ${workspaceFolder}."
111134
},
112135
"languageServerHaskell.noLspParam": {
113136
"scope": "resource",
@@ -119,21 +142,26 @@
119142
"scope": "resource",
120143
"type": "boolean",
121144
"default": true,
122-
"description":
123-
"If true, when an expression is selected, the hover tooltip will attempt to display the type of the entire expression - rather than just the term under the cursor."
145+
"description": "If true, when an expression is selected, the hover tooltip will attempt to display the type of the entire expression - rather than just the term under the cursor."
124146
},
125147
"languageServerHaskell.showTypeForSelection.command.location": {
126148
"scope": "resource",
127149
"type": "string",
128-
"enum": ["dropdown", "channel"],
150+
"enum": [
151+
"dropdown",
152+
"channel"
153+
],
129154
"default": "dropdown",
130-
"description":
131-
"Determines where the type information for selected text will be shown when the `showType` command is triggered (distinct from automatically showing this information when hover is triggered).\ndropdown: in a dropdown\nchannel: will be revealed in an output channel"
155+
"description": "Determines where the type information for selected text will be shown when the `showType` command is triggered (distinct from automatically showing this information when hover is triggered).\ndropdown: in a dropdown\nchannel: will be revealed in an output channel"
132156
},
133157
"languageServerHaskell.trace.server": {
134158
"scope": "resource",
135159
"type": "string",
136-
"enum": ["off", "messages", "verbose"],
160+
"enum": [
161+
"off",
162+
"messages",
163+
"verbose"
164+
],
137165
"default": "off",
138166
"description": "Traces the communication between VSCode and the languageServerHaskell service."
139167
},
@@ -196,6 +224,11 @@
196224
"command": "hie.commands.importIdentifier",
197225
"title": "Haskell: Import identifier",
198226
"description": "Imports a function or type based on a Hoogle search"
227+
},
228+
{
229+
"command": "hie.commands.restartHie",
230+
"title": "Haskell: Restart HIE",
231+
"description": "Restart the Hie LPS server"
199232
}
200233
],
201234
"keybindings": [
@@ -231,8 +264,7 @@
231264
"tslint": "tslint -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
232265
"tslint-fix": "tslint --fix -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
233266
"precommit": "pretty-quick --staged",
234-
"push-tag":
235-
"git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version"
267+
"push-tag": "git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version"
236268
},
237269
"devDependencies": {
238270
"@types/cheerio": "^0.22.13",
@@ -253,7 +285,9 @@
253285
"webpack": "^4.38.0",
254286
"webpack-cli": "^3.3.6"
255287
},
256-
"extensionDependencies": ["justusadam.language-haskell"],
288+
"extensionDependencies": [
289+
"justusadam.language-haskell"
290+
],
257291
"dependencies": {
258292
"cheerio": "^1.0.0-rc.3",
259293
"extend": ">=3.0.2",

src/commands/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export namespace CommandNames {
22
export const InsertTypeCommandName = 'hie.commands.insertType';
33
export const ShowTypeCommandName = 'hie.commands.showType';
44
export const ImportIdentifierCommandName = 'hie.commands.importIdentifier';
5+
export const RestartHieCommandName = 'hie.commands.restartHie';
56
}

src/commands/restartHie.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as vscode from 'vscode';
2+
import { LanguageClient } from 'vscode-languageclient';
3+
import { CommandNames } from './constants';
4+
5+
export namespace RestartHie {
6+
'use strict';
7+
8+
export function registerCommand(langClients: Map<string, LanguageClient>): vscode.Disposable {
9+
return vscode.commands.registerCommand(CommandNames.RestartHieCommandName, async () => {
10+
for (const langClient of langClients.values()) {
11+
await langClient.stop();
12+
langClient.start();
13+
}
14+
});
15+
}
16+
}

src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from 'vscode-languageclient';
2222
import { ImportIdentifier } from './commands/importIdentifier';
2323
import { InsertType } from './commands/insertType';
24+
import { RestartHie } from './commands/restartHie';
2425
import { ShowTypeCommand, ShowTypeHover } from './commands/showType';
2526
import { DocsBrowser } from './docsBrowser';
2627

@@ -71,7 +72,7 @@ async function activateHie(context: ExtensionContext, document: TextDocument) {
7172
const useCustomWrapper = workspace.getConfiguration('languageServerHaskell', uri).useCustomHieWrapper;
7273
const hieExecutablePath = workspace.getConfiguration('languageServerHaskell', uri).hieExecutablePath;
7374
// Check if hie is installed.
74-
if (!await isHieInstalled() && !useCustomWrapper && hieExecutablePath === '') {
75+
if (!(await isHieInstalled()) && !useCustomWrapper && hieExecutablePath === '') {
7576
// TODO: Once haskell-ide-engine is on hackage/stackage, enable an option to install it via cabal/stack.
7677
const notInstalledMsg: string =
7778
'hie executable missing, please make sure it is installed, see github.com/haskell/haskell-ide-engine.';
@@ -203,6 +204,7 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
203204
// Register editor commands for HIE, but only register the commands once.
204205
if (!hieCommandsRegistered) {
205206
context.subscriptions.push(InsertType.registerCommand(clients));
207+
context.subscriptions.push(RestartHie.registerCommand(clients));
206208
const showTypeCmd = ShowTypeCommand.registerCommand(clients);
207209
if (showTypeCmd !== null) {
208210
showTypeCmd.forEach(x => context.subscriptions.push(x));

0 commit comments

Comments
 (0)