diff --git a/elixir-ls b/elixir-ls index fe11910..c3b73d8 160000 --- a/elixir-ls +++ b/elixir-ls @@ -1 +1 @@ -Subproject commit fe1191031874bf0d05afa18d1886e8ac705fd94d +Subproject commit c3b73d82e91a591544f67a3dd6c880cc7aa40c12 diff --git a/package.json b/package.json index b87f007..e29f0a3 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/extension.ts b/src/extension.ts index ad611b4..4a8d20f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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, @@ -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}`; @@ -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);