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
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,16 @@
"command": "extension.restart",
"title": "Restart language server"
},
{
"category": "Elixir",
"command": "extension.mixClean",
"title": "Trigger mix clean in language server"
},
{
"category": "Elixir",
"command": "extension.mixCleanIncludeDeps",
"title": "Trigger mix clean --deps in language server"
},
{
"category": "Elixir",
"command": "extension.toPipe",
Expand Down Expand Up @@ -483,6 +493,16 @@
"command": "extension.restart",
"when": "editorLangId == elixir || editorLangId == eex || editorLangId == html-eex"
},
{
"category": "Elixir",
"command": "extension.mixClean",
"when": "editorLangId == elixir || editorLangId == eex || editorLangId == html-eex"
},
{
"category": "Elixir",
"command": "extension.mixCleanIncludeDeps",
"when": "editorLangId == elixir || editorLangId == eex || editorLangId == html-eex"
},
{
"category": "Elixir",
"command": "extension.toPipe",
Expand Down
33 changes: 32 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { execSync } from "child_process";
import * as shell from "shelljs";
import * as path from "path";

import { workspace, ExtensionContext, WorkspaceFolder, Uri, Disposable } from "vscode";
import { workspace, ExtensionContext, WorkspaceFolder, Uri } from "vscode";
import {
ExecuteCommandParams,
LanguageClient,
Expand Down Expand Up @@ -238,6 +238,35 @@ function configureRestart(context: ExtensionContext) {
context.subscriptions.push(disposable);
}

function configureMixClean(context: ExtensionContext, cleanDeps: boolean) {
const commandName = "extension." + (cleanDeps ? "mixCleanIncludeDeps" : "mixClean");
const disposable = vscode.commands.registerCommand(commandName, 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("mixClean:"))!;

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

await client.sendRequest("workspace/executeCommand", params);
});

context.subscriptions.push(disposable);
}

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

Expand Down Expand Up @@ -412,6 +441,8 @@ export function activate(context: ExtensionContext): void {
configureCopyDebugInfo(context);
configureExpandMacro(context);
configureRestart(context);
configureMixClean(context, false);
configureMixClean(context, true);
configureManipulatePipes(context, "fromPipe");
configureManipulatePipes(context, "toPipe");
configureDebugger(context);
Expand Down