From 073498eb67c3d57d07c4663e26eb3c47f65e661c Mon Sep 17 00:00:00 2001 From: Bryan Kneis Date: Wed, 30 Oct 2024 10:19:47 +0000 Subject: [PATCH 1/2] Implement experimental support for zed --- cmd/up.go | 3 +++ pkg/config/ide.go | 1 + pkg/ide/ideparse/parse.go | 7 +++++++ pkg/ide/zed/zed.go | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 pkg/ide/zed/zed.go diff --git a/cmd/up.go b/cmd/up.go index ba22f3f33..0f68243b3 100644 --- a/cmd/up.go +++ b/cmd/up.go @@ -29,6 +29,7 @@ import ( "github.com/loft-sh/devpod/pkg/ide/jupyter" "github.com/loft-sh/devpod/pkg/ide/openvscode" "github.com/loft-sh/devpod/pkg/ide/vscode" + "github.com/loft-sh/devpod/pkg/ide/zed" "github.com/loft-sh/devpod/pkg/loft" open2 "github.com/loft-sh/devpod/pkg/open" "github.com/loft-sh/devpod/pkg/port" @@ -354,6 +355,8 @@ func (cmd *UpCmd) Run( cmd.GitToken, log, ) + case string(config.IDEZed): + return zed.Open(ctx, ideConfig.Options, config2.GetRemoteUser(result), result.SubstitutionContext.ContainerWorkspaceFolder, client.Workspace(), log) } } diff --git a/pkg/config/ide.go b/pkg/config/ide.go index baa4a207f..27ba4f37a 100644 --- a/pkg/config/ide.go +++ b/pkg/config/ide.go @@ -20,4 +20,5 @@ const ( IDEJupyterNotebook IDE = "jupyternotebook" IDECursor IDE = "cursor" IDEPositron IDE = "positron" + IDEZed IDE = "zed" ) diff --git a/pkg/ide/ideparse/parse.go b/pkg/ide/ideparse/parse.go index a2fd217f5..6b091e8b6 100644 --- a/pkg/ide/ideparse/parse.go +++ b/pkg/ide/ideparse/parse.go @@ -143,6 +143,13 @@ var AllowedIDEs = []AllowedIDE{ Icon: "https://devpod.sh/assets/positron.svg", Experimental: true, }, + { + Name: config.IDEZed, + DisplayName: "Zed", + Options: ide.Options{}, + Icon: "https://devpod.sh/assets/positron.svg", + Experimental: true, + }, } func RefreshIDEOptions(devPodConfig *config.Config, workspace *provider.Workspace, ide string, options []string) (*provider.Workspace, error) { diff --git a/pkg/ide/zed/zed.go b/pkg/ide/zed/zed.go new file mode 100644 index 000000000..2e7cf4b64 --- /dev/null +++ b/pkg/ide/zed/zed.go @@ -0,0 +1,35 @@ +package zed + +import ( + "context" + "fmt" + "os/exec" + "runtime" + + "github.com/loft-sh/devpod/pkg/command" + "github.com/loft-sh/log" + + "github.com/loft-sh/devpod/pkg/config" +) + +// Open first finds the zed binary for the local platform and then opens the zed editor with the given workspace folder +func Open(ctx context.Context, values map[string]config.OptionValue, userName, workspaceFolder, workspaceID string, log log.Logger) error { + log.Info("Opening Zed editor ...") + // Find the zed binary for the local platform + zedCmd := "zed" + if runtime.GOOS == "darwin" && command.Exists("/Applications/Zed.app/Contents/Resources/app/bin/zed") { + zedCmd = "/Applications/Zed.app/Contents/Resources/app/bin/zed" + } + // Check if zed is installed and in the PATH + if !command.Exists(zedCmd) { + return fmt.Errorf("seems like you don't have zed installed on your computer locally") + } + // Open the zed editor with the given workspace ID as the SSH host and workspace folder as path + sshHost := fmt.Sprintf("ssh://%s.devpod/%s", workspaceID, workspaceFolder) + out, err := exec.CommandContext(ctx, zedCmd, sshHost).CombinedOutput() + if err != nil { + return command.WrapCommandError(out, err) + } + + return nil +} From 7f988e917d30473980e065777c133e3592870207 Mon Sep 17 00:00:00 2001 From: Bryan Kneis Date: Thu, 31 Oct 2024 09:36:06 +0000 Subject: [PATCH 2/2] Update logo --- pkg/ide/ideparse/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ide/ideparse/parse.go b/pkg/ide/ideparse/parse.go index 6b091e8b6..2670486f1 100644 --- a/pkg/ide/ideparse/parse.go +++ b/pkg/ide/ideparse/parse.go @@ -147,7 +147,7 @@ var AllowedIDEs = []AllowedIDE{ Name: config.IDEZed, DisplayName: "Zed", Options: ide.Options{}, - Icon: "https://devpod.sh/assets/positron.svg", + Icon: "https://devpod.sh/assets/zed.svg", Experimental: true, }, }