Skip to content

Commit

Permalink
command: restart futhark language server
Browse files Browse the repository at this point in the history
  • Loading branch information
haoranpb committed Mar 29, 2022
1 parent 7836a3f commit 05cafae
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
15 changes: 13 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@
"type": "object",
"title": "Futhark",
"properties": {}
}
},
"commands": [
{
"command": "futhark.commands.restartServer",
"title": "Restart Futhark Language Server",
"category": "Futhark"
}
]
},
"scripts": {
"vscode:prepublish": "rm -rf ./out && npm run esbuild -- --minify",
Expand All @@ -63,6 +70,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@types/which": "^2.0.1",
"vscode-languageclient": "^7.0.0",
"which": "^2.0.2"
}
Expand Down
15 changes: 13 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import which from 'which'
import { window } from 'vscode'
import { window, commands, ExtensionContext } from 'vscode'
import {
LanguageClient,
LanguageClientOptions,
Expand All @@ -10,7 +10,7 @@ import {
let client: LanguageClient

// entry point of the extension
export async function activate() {
export async function activate(context: ExtensionContext) {
which('futhark')
.then((resolvedPath) => {
// run `futhark lsp` to fire up the language server
Expand All @@ -35,6 +35,17 @@ export async function activate() {
clientOptions
)

const restartCommand = commands.registerCommand(
'futhark.commands.restartServer',
async () => {
client.info('Restarting server...')
await client.stop()
client.info('Starting server...')
client.start()
}
)
context.subscriptions.push(restartCommand)

client.start()
})
.catch((err) => {
Expand Down

0 comments on commit 05cafae

Please sign in to comment.