Skip to content

Commit

Permalink
feat(workspace)!: remove custom workspace logic
Browse files Browse the repository at this point in the history
BREAKING CHANGE: this requires helm-ls v0.0.10 or later
helm-ls now supports editing multiple charts, and also having a
different workspace directory that the chart directory so the custom
logic for finding the chart directory is not needed anymore
  • Loading branch information
qvalentin committed Feb 5, 2024
1 parent d4b110c commit 571bfd5
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import {
LanguageClientOptions,
ServerOptions,
TransportKind,
WorkspaceFolder,
} from "vscode-languageclient/node";
import { getHelmLsExecutable } from "./util/executable";
import path from "path";
import fs from "fs";
import url from "url";

let client: LanguageClient;

Expand All @@ -25,27 +21,10 @@ export async function activate(_: vscode.ExtensionContext) {

console.log("Launching " + helmLsExecutable);

const workSpacePath = vscode.workspace.workspaceFolders?.[0].uri.path;
const filePath = vscode.window.activeTextEditor?.document.fileName;
var cwd: string = workSpacePath ?? "";

console.log("Workspace path: " + workSpacePath, "File path: " + filePath);
if (workSpacePath && fs.existsSync(path.join(workSpacePath, "Chart.yaml"))) {
console.log("Setting cwd to " + workSpacePath);
cwd = workSpacePath
}
else if (filePath) {
console.log("Setting cwd to " + traversePathUpToChartYaml(filePath));
cwd = traversePathUpToChartYaml(filePath)
}

const executable: Executable = {
command: helmLsExecutable,
args: ["serve"],
transport: TransportKind.stdio,
options: {
cwd: cwd
}
};

const serverOptions: ServerOptions = {
Expand All @@ -55,12 +34,7 @@ export async function activate(_: vscode.ExtensionContext) {

const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: "file", language: "helm" }],
synchronize: {},
workspaceFolder: {
uri: vscode.Uri.file(cwd),
name: vscode.workspace.workspaceFolders?.[0].name ?? "",
index: 0
}
synchronize: {}
};

client = new LanguageClient(
Expand All @@ -80,14 +54,3 @@ export function deactivate(): Thenable<void> | undefined {
}
return client.stop();
}

function traversePathUpToChartYaml(directory: string): string {
if (fs.existsSync(path.join(directory, "Chart.yaml"))) {
return directory
}
const parent = path.dirname(directory)
if (parent === "/") {
return ""
}
return traversePathUpToChartYaml(parent)
}

0 comments on commit 571bfd5

Please sign in to comment.