editor

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package editor detects installed editors/IDEs and opens repositories in them. The chosen default is remembered in a small state file so the picker only appears until the user settles on one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultID

func DefaultID() string

DefaultID returns the saved default editor id, or "".

func SaveDefault

func SaveDefault(id string) error

SaveDefault persists the chosen default editor id.

Types

type Editor

type Editor struct {
	ID       string   // stable id used for the saved default
	Name     string   // display name
	Cmd      string   // CLI launcher on PATH
	Args     []string // args before the path (e.g. nvim none, idea none)
	Apps     []string // macOS .app bundle names, for the `open -a` fallback
	Terminal bool     // true for TUI editors that must run in the foreground
}

Editor describes a launchable editor.

func Available

func Available() []Editor

Available returns the editors actually installed on this machine.

func ByID

func ByID(id string) (Editor, bool)

ByID looks up an editor in the catalog.

func Catalog

func Catalog() []Editor

Catalog is every editor orchard knows how to launch.

func (Editor) Command

func (e Editor) Command(path string) (*exec.Cmd, bool)

Command builds the command to open path. The bool reports whether it must run in the foreground (a terminal editor). Returns nil if it can't be launched.

func (Editor) CommandAt

func (e Editor) CommandAt(file string, line int) (*exec.Cmd, bool)

CommandAt opens a specific file at a line number, using each editor's syntax.

func (Editor) Installed

func (e Editor) Installed() bool

Installed reports whether the editor can be launched: CLI on PATH, or (macOS) an installed .app bundle.

Jump to

Keyboard shortcuts

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