Skip to content

Commit

Permalink
feat: add zed ide support (#1311)
Browse files Browse the repository at this point in the history
Signed-off-by: tarunrajput <[email protected]>
  • Loading branch information
tarunrajput authored Nov 5, 2024
1 parent 389fcdd commit 52be5d1
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/daytona/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func GetIdeList() []Ide {
{"ssh", "Terminal SSH"},
{"jupyter", "Jupyter"},
{"fleet", "Fleet"},
{"zed", "Zed"},
}

sortedJbIdes := []Ide{}
Expand Down
2 changes: 1 addition & 1 deletion docs/daytona_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ daytona code [WORKSPACE] [PROJECT] [flags]
### Options

```
-i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
-i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
-y, --yes Automatically confirm any prompts
```

Expand Down
2 changes: 1 addition & 1 deletion docs/daytona_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ daytona create [REPOSITORY_URL | PROJECT_CONFIG_NAME]... [flags]
--devcontainer-path string Automatically assign the devcontainer builder with the path passed as the flag value
--env stringArray Specify environment variables (e.g. --env 'KEY1=VALUE1' --env 'KEY2=VALUE2' ...')
--git-provider-config string Specify the Git provider configuration ID or alias
-i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
-i, --ide string Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
--manual Manually enter the Git repository
--multi-project Workspace with multiple projects/repos
--name string Specify the workspace name
Expand Down
2 changes: 1 addition & 1 deletion hack/docs/daytona_code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ options:
- name: ide
shorthand: i
usage: |
Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
- name: "yes"
shorthand: "y"
default_value: "false"
Expand Down
2 changes: 1 addition & 1 deletion hack/docs/daytona_create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ options:
- name: ide
shorthand: i
usage: |
Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
Specify the IDE (vscode, browser, cursor, ssh, jupyter, fleet, zed, clion, goland, intellij, phpstorm, pycharm, rider, rubymine, webstorm)
- name: manual
default_value: "false"
usage: Manually enter the Git repository
Expand Down
5 changes: 5 additions & 0 deletions pkg/cmd/ide.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ var ideCmd = &cobra.Command{
if err := ide_util.CheckFleetInstallation(); err != nil {
log.Error(err)
}
case "zed":
_, err := ide_util.GetZedBinaryPath()
if err != nil {
log.Error(err)
}
}

jetbrainsIdes := jetbrains.GetIdes()
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/workspace/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ func openIDE(ideId string, activeProfile config.Profile, workspaceId string, pro
return ide.OpenJupyterIDE(activeProfile, workspaceId, projectName, projectProviderMetadata, yesFlag, gpgKey)
case "fleet":
return ide.OpenFleet(activeProfile, workspaceId, projectName, gpgKey)
case "zed":
return ide.OpenZed(activeProfile, workspaceId, projectName, gpgKey)
default:
_, ok := jetbrains.GetIdes()[jetbrains.Id(ideId)]
if ok {
Expand Down
60 changes: 60 additions & 0 deletions pkg/ide/zed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2024 Daytona Platforms Inc.
// SPDX-License-Identifier: Apache-2.0

package ide

import (
"errors"
"fmt"
"os/exec"
"strings"

"github.com/daytonaio/daytona/cmd/daytona/config"
"github.com/daytonaio/daytona/internal/util"
"github.com/daytonaio/daytona/pkg/views"
)

func OpenZed(activeProfile config.Profile, workspaceId, projectName, gpgKey string) error {
path, err := GetZedBinaryPath()
if err != nil {
return err
}

projectHostname := config.GetProjectHostname(activeProfile.Id, workspaceId, projectName)
projectDir, err := util.GetProjectDir(activeProfile, workspaceId, projectName, gpgKey)
if err != nil {
return err
}
printDisclaimer()
zedCmd := exec.Command(path, fmt.Sprintf("ssh://%s%s", projectHostname, projectDir))

err = zedCmd.Run()
if err != nil {
return err
}

return nil
}

func GetZedBinaryPath() (string, error) {
path, err := exec.LookPath("zed")
if err == nil {
return path, err
}

redBold := "\033[1;31m" // ANSI escape code for red and bold
reset := "\033[0m" // ANSI escape code to reset text formatting

errorMessage := "Please install Zed and ensure it's in your PATH.\n\n"
moreInfo := []string{
"More information: \n",
"1) Install Zed by following: https://zed.dev/docs/getting-started or download from https://zed.dev/download\n",
"2) To install the zed command line tool, select Zed > Install CLI from the application menu\n\n",
}

return "", errors.New(redBold + errorMessage + reset + strings.Join(moreInfo, ""))
}

func printDisclaimer() {
views.RenderTip("Note: Zed remote development is not yet stable. Issues like opening terminals and using extensions are expected.")
}

0 comments on commit 52be5d1

Please sign in to comment.