Skip to content
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
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@
"command": "extension.expandMacro",
"title": "ElixirLS: Expand macro"
},
{
"command": "extension.restart",
"title": "ElixirLS: Restart language server"
},
{
"command": "extension.toPipe",
"title": "ElixirLS: Convert function call to pipe operator"
Expand All @@ -452,6 +456,10 @@
"command": "extension.expandMacro",
"when": "editorLangId == elixir || editorLangId == eex || editorLangId == html-eex"
},
{
"command": "extension.restart",
"when": "editorLangId == elixir || editorLangId == eex || editorLangId == html-eex"
},
{
"command": "extension.toPipe",
"when": "editorLangId == elixir || editorLangId == eex || editorLangId == html-eex"
Expand Down
34 changes: 34 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,39 @@ function configureExpandMacro(context: ExtensionContext) {
context.subscriptions.push(disposable);
}

function configureRestart(context: ExtensionContext) {
const disposable = vscode.commands.registerCommand("extension.restart", async () => {
const extension = vscode.extensions.getExtension("jakebecker.elixir-ls");
const editor = vscode.window.activeTextEditor;

if (!extension || !editor) {
return;
}

const client = getClient(editor.document);
if (!client) {
return;
}

const command = client.initializeResult!.capabilities.executeCommandProvider!.commands
.find(c => c.startsWith("restart:"))!;

const params: ExecuteCommandParams = {
command: command,
arguments: []
};

try {
await client.sendRequest("workspace/executeCommand", params);
} catch {
// this command will throw Connection got disposed
// client reference remains valid as VS will restart server process and the connection
}
});

context.subscriptions.push(disposable);
}

function configureManipulatePipes(context: ExtensionContext, operation: "toPipe" | "fromPipe") {
const commandName = `extension.${operation}`;

Expand Down Expand Up @@ -375,6 +408,7 @@ export function activate(context: ExtensionContext): void {
configureRunTestFromCodeLens()
configureCopyDebugInfo(context);
configureExpandMacro(context);
configureRestart(context);
configureManipulatePipes(context, "fromPipe");
configureManipulatePipes(context, "toPipe");
configureDebugger(context);
Expand Down