Skip to content

Add restart command. #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 54 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
"engines": {
"vscode": "^1.33.0"
},
"keywords": ["language", "haskell", "lsp", "multi-root ready"],
"keywords": [
"language",
"haskell",
"lsp",
"multi-root ready"
],
"homepage": "https://github.com/alanz/vscode-hie-server",
"repository": {
"type": "git",
Expand All @@ -17,25 +22,43 @@
"bugs": {
"url": "https://github.com/alanz/vscode-hie-server/issues"
},
"categories": ["Programming Languages", "Formatters", "Linters", "Other"],
"categories": [
"Programming Languages",
"Formatters",
"Linters",
"Other"
],
"icon": "images/HIE_logo_128.png",
"galleryBanner": {
"color": "#22172A",
"theme": "dark"
},
"activationEvents": ["onLanguage:haskell", "onLanguage:literate haskell"],
"activationEvents": [
"onLanguage:haskell",
"onLanguage:literate haskell"
],
"main": "./dist/extension",
"contributes": {
"languages": [
{
"id": "haskell",
"aliases": ["Haskell", "haskell"],
"extensions": [".hs"]
"aliases": [
"Haskell",
"haskell"
],
"extensions": [
".hs"
]
},
{
"id": "literate haskell",
"aliases": ["Literate Haskell", "literate Haskell"],
"extensions": [".lhs"]
"aliases": [
"Literate Haskell",
"literate Haskell"
],
"extensions": [
".lhs"
]
}
],
"configuration": {
Expand All @@ -59,8 +82,7 @@
"scope": "resource",
"type": "boolean",
"default": true,
"description":
"Compute diagnostics continuously as you type. Turn off to only generate diagnostics on file save."
"description": "Compute diagnostics continuously as you type. Turn off to only generate diagnostics on file save."
},
"languageServerHaskell.liquidOn": {
"scope": "resource",
Expand Down Expand Up @@ -92,22 +114,19 @@
"scope": "resource",
"type": "string",
"default": "",
"description":
"Set the path to your hie executable, if it's not already on your $PATH. Works with ~, ${HOME} and ${workspaceFolder}."
"description": "Set the path to your hie executable, if it's not already on your $PATH. Works with ~, ${HOME} and ${workspaceFolder}."
},
"languageServerHaskell.useCustomHieWrapper": {
"scope": "resource",
"type": "boolean",
"default": false,
"description":
"Use your own custom wrapper for hie (remember to specify the path!). This will take precedence over useHieWrapper and hieExecutablePath."
"description": "Use your own custom wrapper for hie (remember to specify the path!). This will take precedence over useHieWrapper and hieExecutablePath."
},
"languageServerHaskell.useCustomHieWrapperPath": {
"scope": "resource",
"type": "string",
"default": "",
"description":
"Specify the full path to your own custom hie wrapper (e.g. ${HOME}/.hie-wrapper.sh). Works with ~, ${HOME} and ${workspaceFolder}."
"description": "Specify the full path to your own custom hie wrapper (e.g. ${HOME}/.hie-wrapper.sh). Works with ~, ${HOME} and ${workspaceFolder}."
},
"languageServerHaskell.noLspParam": {
"scope": "resource",
Expand All @@ -119,21 +138,26 @@
"scope": "resource",
"type": "boolean",
"default": true,
"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."
"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."
},
"languageServerHaskell.showTypeForSelection.command.location": {
"scope": "resource",
"type": "string",
"enum": ["dropdown", "channel"],
"enum": [
"dropdown",
"channel"
],
"default": "dropdown",
"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"
"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"
},
"languageServerHaskell.trace.server": {
"scope": "resource",
"type": "string",
"enum": ["off", "messages", "verbose"],
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Traces the communication between VSCode and the languageServerHaskell service."
},
Expand Down Expand Up @@ -196,6 +220,11 @@
"command": "hie.commands.importIdentifier",
"title": "Haskell: Import identifier",
"description": "Imports a function or type based on a Hoogle search"
},
{
"command": "hie.commands.restartHie",
"title": "Haskell: Restart HIE",
"description": "Restart the Hie LSP server"
}
],
"keybindings": [
Expand Down Expand Up @@ -231,8 +260,7 @@
"tslint": "tslint -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
"tslint-fix": "tslint --fix -p tsconfig.json -c tslint.json --format stylish 'src/**/*.ts'",
"precommit": "pretty-quick --staged",
"push-tag":
"git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version"
"push-tag": "git tag -a $npm_package_version -m \"Version $npm_package_version\" && git push origin $npm_package_version"
},
"devDependencies": {
"@types/cheerio": "^0.22.13",
Expand All @@ -253,7 +281,9 @@
"webpack": "^4.38.0",
"webpack-cli": "^3.3.6"
},
"extensionDependencies": ["justusadam.language-haskell"],
"extensionDependencies": [
"justusadam.language-haskell"
],
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"extend": ">=3.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/commands/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export namespace CommandNames {
export const InsertTypeCommandName = 'hie.commands.insertType';
export const ShowTypeCommandName = 'hie.commands.showType';
export const ImportIdentifierCommandName = 'hie.commands.importIdentifier';
export const RestartHieCommandName = 'hie.commands.restartHie';
}
16 changes: 16 additions & 0 deletions src/commands/restartHie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as vscode from 'vscode';
import { LanguageClient } from 'vscode-languageclient';
import { CommandNames } from './constants';

export namespace RestartHie {
'use strict';

export function registerCommand(langClients: Map<string, LanguageClient>): vscode.Disposable {
return vscode.commands.registerCommand(CommandNames.RestartHieCommandName, async () => {
for (const langClient of langClients.values()) {
await langClient.stop();
langClient.start();
}
});
}
}
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from 'vscode-languageclient';
import { ImportIdentifier } from './commands/importIdentifier';
import { InsertType } from './commands/insertType';
import { RestartHie } from './commands/restartHie';
import { ShowTypeCommand, ShowTypeHover } from './commands/showType';
import { DocsBrowser } from './docsBrowser';

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