Skip to content

Commit

Permalink
feat(nextls): to-pipe and from-pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
mhanberg committed Mar 2, 2024
1 parent ae2e77a commit 8cb3d1f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 10 deletions.
3 changes: 0 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
Expand Down
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"tasks": [
{
"type": "npm",
"script": "build",
"script": "compile-tests",
"problemMatcher": "$ts-webpack-watch",
"isBackground": true,
"presentation": {
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@
{
"command": "elixir-tools.uninstall-nextls",
"title": "elixir-tools: Uninstall Next LS"
},
{
"command": "foobar.elixir-tools.to-pipe",
"title": "Next LS: Convert from nested function call to piped function call"
}
],
"grammars": [
Expand All @@ -181,7 +185,7 @@
"scripts": {
"vscode:prepublish": "yarn run build-base --minify",
"package": "vsce package",
"compile-tests": "tsc -p . --outDir out",
"compile-tests": "tsc -p . --outDir dist",
"watch-tests": "tsc -p . -w --outDir out",
"lint": "eslint src --ext ts",
"fix": "eslint src --ext ts --fix",
Expand Down
35 changes: 35 additions & 0 deletions src/commands/to-pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as vscode from "vscode";

import {
LanguageClient,
ExecuteCommandRequest,
} from "vscode-languageclient/node";

export const run = async (client: LanguageClient) => {
console.log("hi!");
// const position = vscode.window.activeTextEditor?.selection;

// client.sendRequest(ExecuteCommandRequest.type, {
// command: "to-pipe",
// arguments: [
// {
// uri: vscode.window.activeTextEditor?.document.uri,
// position: position,
// },
// ],
// });
};

function registerToPipeCommand(
client: LanguageClient,
context: vscode.ExtensionContext
) {
console.log("what is happening");
const toPipeCommand = "elixir-tools.toPipe";
const toPipe = async () => run(client);
context.subscriptions.push(
vscode.commands.registerCommand(toPipeCommand, toPipe)
);
}

export default registerToPipeCommand;
7 changes: 4 additions & 3 deletions src/commands/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ export const run = async (cacheDir: string) => {
);
};

const registerUninstallCommand = (
function registerUninstallCommand(
config: vscode.WorkspaceConfiguration,
context: vscode.ExtensionContext
) => {
) {
const uninstallCommand = "elixir-tools.uninstall-nextls";

console.log("registering uninstall command");
const uninstall = async () =>
run(<string>config.get("installationDirectory"));

context.subscriptions.push(
vscode.commands.registerCommand(uninstallCommand, uninstall)
);
};
}

export default registerUninstallCommand;
12 changes: 10 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import {
} from "vscode-languageclient/node";

import registerUninstallCommand from "./commands/uninstall";
import registerToPipeCommand from "./commands/to-pipe.js";

let credoClient: LanguageClient;
let nextLSClient: LanguageClient;

const channel = vscode.window.createOutputChannel("NextLS", { log: true });

async function latestRelease(project: string): Promise<string> {
return fetch(
`https://api.github.com/repos/elixir-tools/${project}/releases/latest`,
Expand Down Expand Up @@ -99,10 +102,9 @@ async function activateNextLS(
context: vscode.ExtensionContext,
_mixfile: vscode.Uri
) {
console.log("hi hi hi the beginning");
let config = vscode.workspace.getConfiguration("elixir-tools.nextLS");

registerUninstallCommand(config, context);

if (config.get("enable")) {
let serverOptions: ServerOptions;

Expand Down Expand Up @@ -161,13 +163,19 @@ async function activateNextLS(
],
};

console.log("hi hi hi");

nextLSClient = new LanguageClient(
"elixir-tools.nextLS",
"NextLS",
serverOptions,
clientOptions
);

channel.error("where does this go");
registerToPipeCommand(nextLSClient, context);
registerUninstallCommand(config, context);

// Start the nextLSClient. This will also launch the server
nextLSClient.start();
}
Expand Down

0 comments on commit 8cb3d1f

Please sign in to comment.