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

editor

package
v0.54.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package editor provides IDE integration for worktree environments. It generates per-worktree settings for VS Code/Cursor and JetBrains, including window titles, color theming, and workspace file detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorForBranch

func ColorForBranch(branch string) string

ColorForBranch returns a deterministic hex color for the given branch name. The same branch always maps to the same color across sessions.

func DarkenHex

func DarkenHex(hex string) string

DarkenHex returns a slightly darker version of a hex color, for inactive states.

func DetectEditor

func DetectEditor() string

DetectEditor tries to identify which editor is running this terminal. Returns the canonical name or empty string if detection fails.

func DetectJetBrains

func DetectJetBrains(worktreePath string) bool

DetectJetBrains returns true if the worktree has a .idea directory.

func ForegroundForHex

func ForegroundForHex(hex string) string

ForegroundForHex returns white or dark text depending on background luminance.

func WriteJetBrains

func WriteJetBrains(worktreePath, color string) (string, error)

WriteJetBrains sets the project header color in .idea/workspace.xml. JetBrains IDEs (2023.2+) support a colored header bar per project.

func WriteVSCode

func WriteVSCode(worktreePath string, s VSCodeSettings) (string, error)

WriteVSCode writes editor settings to the appropriate location. If a .code-workspace file references the worktree, settings go there. Otherwise, settings go to .vscode/settings.json in the worktree.

Types

type EditorInfo

type EditorInfo struct {
	Name    string // canonical key: "cursor", "vscode", "zed", "goland", etc.
	Display string // human label: "Cursor", "VS Code", "Zed", "GoLand"
	CLI     string // command to open a path: "cursor", "code", "zed", "goland"
}

EditorInfo describes a detected or configured editor.

func LookupEditor

func LookupEditor(name string) *EditorInfo

LookupEditor returns info for a known editor name, or nil if unknown.

type VSCodeSettings

type VSCodeSettings struct {
	Title string // window.title value
	Color string // hex color for title/activity/status bars (empty = no color)
	Theme string // workbench.colorTheme override (empty = no override)
}

VSCodeSettings holds the settings to write for a VS Code/Cursor workspace.

Jump to

Keyboard shortcuts

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