Skip to content

zed

import "github.com/ananth/codespace-zed/internal/zed"

Package zed reads and updates Zed's settings.json to upsert SSH remote connections. It preserves comments and formatting by operating on the parsed JSONC structure.

Index

func ResolveNickname

func ResolveNickname(zedNickname, targetDisplayName, codespaceDisplayName, targetName string) string

ResolveNickname determines the nickname for a Zed connection. It checks zedNickname, targetDisplayName, codespaceDisplayName, then targetName.

func ResolveSettingsPath

func ResolveSettingsPath() string

ResolveSettingsPath returns the Zed settings.json path for the current platform.

func UpsertConnection

func UpsertConnection(settings map[string]any, conn SSHConnection) map[string]any

UpsertConnection merges a new SSH connection into the settings map.

func UpsertConnectionInFile

func UpsertConnectionInFile(settingsPath string, conn SSHConnection) error

UpsertConnectionInFile reads, updates, and writes the Zed settings file.

type Project

type Project struct {
    Paths []string `json:"paths"`
}

type SSHConnection

type SSHConnection struct {
    Host                string    `json:"host"`
    Nickname            string    `json:"nickname,omitempty"`
    Projects            []Project `json:"projects,omitempty"`
    UploadBinaryOverSSH *bool     `json:"upload_binary_over_ssh,omitempty"`
    Port                int       `json:"port,omitempty"`
    Username            string    `json:"username,omitempty"`
}

func BuildConnection

func BuildConnection(host, workspacePath, nickname string, uploadBinary *bool) SSHConnection

BuildConnection creates an SSHConnection from target config and SSH alias.

Generated by gomarkdoc