Skip to content

Commit 002c399

Browse files
authored
Merge pull request #191 from gdziadkiewicz/Add_restart
Add restart command.
2 parents a6fdf00 + 283de6f commit 002c399

File tree

4 files changed

+74
-25
lines changed

4 files changed

+74
-25
lines changed

package.json

Lines changed: 54 additions & 24 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",
@@ -92,22 +114,19 @@
92114
"scope": "resource",
93115
"type": "string",
94116
"default": "",
95-
"description":
96-
"Set the path to your hie executable, if it's not already on your $PATH. Works with ~, ${HOME} and ${workspaceFolder}."
117+
"description": "Set the path to your hie executable, if it's not already on your $PATH. Works with ~, ${HOME} and ${workspaceFolder}."
97118
},
98119
"languageServerHaskell.useCustomHieWrapper": {
99120
"scope": "resource",
100121
"type": "boolean",
101122
"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."
123+
"description": "Use your own custom wrapper for hie (remember to specify the path!). This will take precedence over useHieWrapper and hieExecutablePath."
104124
},
105125
"languageServerHaskell.useCustomHieWrapperPath": {
106126
"scope": "resource",
107127
"type": "string",
108128
"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}."
129+
"description": "Specify the full path to your own custom hie wrapper (e.g. ${HOME}/.hie-wrapper.sh). Works with ~, ${HOME} and ${workspaceFolder}."
111130
},
112131
"languageServerHaskell.noLspParam": {
113132
"scope": "resource",
@@ -119,21 +138,26 @@
119138
"scope": "resource",
120139
"type": "boolean",
121140
"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."
141+
"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."
124142
},
125143
"languageServerHaskell.showTypeForSelection.command.location": {
126144
"scope": "resource",
127145
"type": "string",
128-
"enum": ["dropdown", "channel"],
146+
"enum": [
147+
"dropdown",
148+
"channel"
149+
],
129150
"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"
151+
"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"
132152
},
133153
"languageServerHaskell.trace.server": {
134154
"scope": "resource",
135155
"type": "string",
136-
"enum": ["off", "messages", "verbose"],
156+
"enum": [
157+
"off",
158+
"messages",
159+
"verbose"
160+
],
137161
"default": "off",
138162
"description": "Traces the communication between VSCode and the languageServerHaskell service."
139163
},
@@ -196,6 +220,11 @@
196220
"command": "hie.commands.importIdentifier",
197221
"title": "Haskell: Import identifier",
198222
"description": "Imports a function or type based on a Hoogle search"
223+
},
224+
{
225+
"command": "hie.commands.restartHie",
226+
"title": "Haskell: Restart HIE",
227+
"description": "Restart the Hie LSP server"
199228
}
200229
],
201230
"keybindings": [
@@ -231,8 +260,7 @@
231260
"tslint": "tslint -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
232261
"tslint-fix": "tslint --fix -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
233262
"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"
263+
"push-tag": "git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version"
236264
},
237265
"devDependencies": {
238266
"@types/cheerio": "^0.22.13",
@@ -253,7 +281,9 @@
253281
"webpack": "^4.38.0",
254282
"webpack-cli": "^3.3.6"
255283
},
256-
"extensionDependencies": ["justusadam.language-haskell"],
284+
"extensionDependencies": [
285+
"justusadam.language-haskell"
286+
],
257287
"dependencies": {
258288
"cheerio": "^1.0.0-rc.3",
259289
"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)