Help us shape the future of Go! Take the 2026 Go Developer Survey

editor

package
v1.65.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package editor centralizes default-editor detection and resolution.

It mirrors the `ide()` shell helper precedence (agy-ide > code > nano) while honoring an explicit `git.editor` config value and the $VISUAL/$EDITOR environment variables. Both the dashboard open logic and the `eng config git-editor` setter consume this package so the available-editor list stays in one place.

Index

Constants

This section is empty.

Variables

View Source
var (
	// LookPath resolves a CLI binary on PATH.
	LookPath = execx.LookPath
	// Stat checks for macOS .app bundles.
	Stat = os.Stat
)

Mockable entry points for tests.

View Source
var Potential = []Option{
	{Name: "agy-ide (CLI)", Command: "agy-ide", IsApp: false},
	{Name: "antigravity-ide (CLI)", Command: "antigravity-ide", IsApp: false},
	{Name: "Antigravity IDE", Command: "Antigravity IDE", IsApp: true},
	{Name: "Antigravity VS Code", Command: "Antigravity", IsApp: true},
	{Name: "Visual Studio Code (CLI)", Command: "code", IsApp: false},
	{Name: "Visual Studio Code (App)", Command: "Visual Studio Code", IsApp: true},
	{Name: "Cursor (CLI)", Command: "cursor", IsApp: false},
	{Name: "Cursor (App)", Command: "Cursor", IsApp: true},
	{Name: "Neovim", Command: "nvim", IsApp: false},
	{Name: "Vim", Command: "vim", IsApp: false},
	{Name: "Nano", Command: "nano", IsApp: false},
	{Name: "Emacs", Command: "emacs", IsApp: false},
	{Name: "Sublime Text (CLI)", Command: "subl", IsApp: false},
	{Name: "Sublime Text (App)", Command: "Sublime Text", IsApp: true},
	{Name: "Xcode", Command: "Xcode", IsApp: true},
	{Name: "Android Studio", Command: "Android Studio", IsApp: true},
}

Potential lists known editors in `ide()` precedence order.

Functions

func Commands

func Commands() []string

Commands returns the executable command for each available editor.

func DefaultCommand

func DefaultCommand(editorConfig string) string

DefaultCommand resolves the editor command without a target path. Precedence: explicit config > $VISUAL/$EDITOR > agy-ide > code > nano.

func Resolve

func Resolve(editorConfig, targetPath string) *execx.Cmd

Resolve builds the exec command for opening targetPath. It splits a configured multi-word command (e.g. "code --wait") and appends the target path.

Types

type Option

type Option struct {
	Name    string
	Command string
	IsApp   bool
}

Option describes a single editor candidate.

func Available

func Available() []Option

Available returns the subset of Potential installed on this machine, preserving precedence order. CLI entries use PATH lookup; app entries check /Applications and ~/Applications.

func FindByName

func FindByName(available []Option, name string) (Option, bool)

FindByName returns the option matching a display name or command.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL