Skip to content

editor

import "github.com/linuskendall/cosmonaut/internal/editor"

Package editor abstracts editor-specific operations for launching and configuring remote connections to codespaces. Implementations exist for Zed and Neovim.

Index

func ResolveNickname

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

ResolveNickname determines the nickname for a connection. Checks zedNickname, targetDisplayName, codespaceDisplayName, then targetName.

type Editor

Editor abstracts editor-specific operations.

type Editor interface {
    // Name returns the editor identifier (e.g. "zed", "neovim").
    Name() string
    // FindBinary locates the editor's CLI binary on PATH.
    FindBinary() (string, error)
    // ConfigureConnection sets up editor-specific config for the SSH
    // connection (e.g. Zed's settings.json). No-op for editors that
    // don't need it.
    ConfigureConnection(sshAlias, workspacePath, nickname string, uploadBinary *bool) error
    // LaunchRemote opens the editor connected to the remote codespace.
    LaunchRemote(sshAlias, workspacePath string) error
}

func ForName

func ForName(name string) (Editor, error)

ForName returns an Editor implementation for the given name. An empty name defaults to "zed".

type NeovimEditor

NeovimEditor implements Editor for Neovim via SSH.

type NeovimEditor struct {
    // Terminal is the terminal app to use for launching Neovim.
    // Empty string means auto-detect.
    Terminal string
}

func (*NeovimEditor) ConfigureConnection

func (n *NeovimEditor) ConfigureConnection(sshAlias, workspacePath, nickname string, uploadBinary *bool) error

func (*NeovimEditor) FindBinary

func (n *NeovimEditor) FindBinary() (string, error)

func (*NeovimEditor) LaunchRemote

func (n *NeovimEditor) LaunchRemote(sshAlias, workspacePath string) error

func (*NeovimEditor) Name

func (n *NeovimEditor) Name() string

type ZedEditor

ZedEditor implements Editor for the Zed text editor.

type ZedEditor struct{}

func (*ZedEditor) ConfigureConnection

func (z *ZedEditor) ConfigureConnection(sshAlias, workspacePath, nickname string, uploadBinary *bool) error

func (*ZedEditor) FindBinary

func (z *ZedEditor) FindBinary() (string, error)

func (*ZedEditor) LaunchRemote

func (z *ZedEditor) LaunchRemote(sshAlias, workspacePath string) error

func (*ZedEditor) Name

func (z *ZedEditor) Name() string

Generated by gomarkdoc