Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement experimental support for zed #1341

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/config/ide.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ const (
IDEJupyterNotebook IDE = "jupyternotebook"
IDECursor IDE = "cursor"
IDEPositron IDE = "positron"
IDEZed IDE = "zed"
)
7 changes: 7 additions & 0 deletions pkg/ide/ideparse/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/zed.svg",
Experimental: true,
},
}

func RefreshIDEOptions(devPodConfig *config.Config, workspace *provider.Workspace, ide string, options []string) (*provider.Workspace, error) {
Expand Down
35 changes: 35 additions & 0 deletions pkg/ide/zed/zed.go
Original file line number Diff line number Diff line change
@@ -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
}
Loading