editor¶
Package editor abstracts editor-specific operations for launching and configuring remote connections to codespaces. Zed is built in as the default since cosmonaut writes Zed-flavored config files when it detects Zed; every other editor is launched as a plain external command and is expected to understand the `ssh://alias/path` URI.
Index¶
- func ResolveNickname(zedNickname, targetDisplayName, codespaceDisplayName, targetName string) string
- type Editor
- func ForName(name string) (Editor, error)
- type GenericEditor
- func (g *GenericEditor) ConfigureConnection(_, _, _ string, _ *bool) error
- func (g *GenericEditor) FindBinary() (string, error)
- func (g *GenericEditor) LaunchRemote(sshAlias, workspacePath string) error
- func (g *GenericEditor) Name() string
- type ZedEditor
- func (z *ZedEditor) ConfigureConnection(sshAlias, workspacePath, nickname string, uploadBinary *bool) error
- func (z *ZedEditor) FindBinary() (string, error)
- func (z *ZedEditor) LaunchRemote(sshAlias, workspacePath string) error
- func (z *ZedEditor) Name() string
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", or the user's
// custom binary name).
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). Generic editors return nil.
ConfigureConnection(sshAlias, workspacePath, nickname string, uploadBinary *bool) error
// LaunchRemote opens the editor connected to the remote workspace.
LaunchRemote(sshAlias, workspacePath string) error
}
func ForName¶
ForName returns an Editor implementation for the given name. An empty name (or "zed" / "zeditor") returns the Zed editor with its settings.json plumbing; any other name is wired through GenericEditor — which just runs `\<name> ssh://\<alias>/\<path>` and lets the caller's editor handle the URI.
type GenericEditor¶
GenericEditor wraps any user-supplied editor binary. It runs the binary against an `ssh://\<alias>/\<path>` URI and lets the editor's own remote handler take it from there. Suitable for Zed-likes that understand the URI (Cursor, etc.), or for user wrapper scripts that translate it to whatever their editor wants.
type GenericEditor struct {
// Command is the binary or wrapper script to execute. May be a bare
// name (looked up on PATH) or an absolute path.
Command string
}
func (*GenericEditor) ConfigureConnection¶
ConfigureConnection is a no-op for generic editors: we don't know how their settings file is shaped, and the caller's editor / wrapper is expected to handle whatever it needs from the URI alone.
func (*GenericEditor) FindBinary¶
FindBinary resolves the command on PATH, or returns it as-is when it's already absolute (since the user pointed straight at a wrapper script).
func (*GenericEditor) LaunchRemote¶
LaunchRemote invokes the editor with the SSH URI. The URI form (ssh://\<alias>/\<path>) is what Zed-compatible editors expect; wrapper scripts can parse it apart if they need to call a non-URI-aware editor.
func (*GenericEditor) Name¶
Name returns the user-supplied binary name so settings UI can display it back to the user verbatim.
type ZedEditor¶
ZedEditor implements Editor for the Zed text editor.
func (*ZedEditor) ConfigureConnection¶
func (z *ZedEditor) ConfigureConnection(sshAlias, workspacePath, nickname string, uploadBinary *bool) error
func (*ZedEditor) FindBinary¶
func (*ZedEditor) LaunchRemote¶
func (*ZedEditor) Name¶
Generated by gomarkdoc