Documentation
¶
Overview ¶
Package editor resolves the command that opens a path in the user's editor, shared by the dashboard's "open in editor" links and the `lerd code` command.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Editors = []Editor{ {"vscode", "Visual Studio Code", "code", gotoArgs, "vscode://file/{file}:{line}", []string{"Visual Studio Code.app"}, []string{"com.visualstudio.code"}}, {"cursor", "Cursor", "cursor", gotoArgs, "cursor://file/{file}:{line}", []string{"Cursor.app"}, nil}, {"vscodium", "VSCodium", "codium", gotoArgs, "vscodium://file/{file}:{line}", []string{"VSCodium.app"}, []string{"com.vscodium.codium"}}, {"windsurf", "Windsurf", "windsurf", gotoArgs, "windsurf://file/{file}:{line}", []string{"Windsurf.app"}, nil}, {"sublime", "Sublime Text", "subl", locArgs, "subl://open?url=file://{file}&line={line}", []string{"Sublime Text.app"}, []string{"com.sublimetext.three"}}, {"zed", "Zed", "zed", locArgs, "zed://file/{file}:{line}", []string{"Zed.app"}, []string{"dev.zed.Zed"}}, {"phpstorm", "PhpStorm", "phpstorm", jetbrainsArgs, "phpstorm://open?file={file}&line={line}", []string{"PhpStorm.app"}, []string{"com.jetbrains.PhpStorm"}}, {"idea", "IntelliJ IDEA", "idea", jetbrainsArgs, "idea://open?file={file}&line={line}", []string{"IntelliJ IDEA.app", "IntelliJ IDEA Ultimate.app", "IntelliJ IDEA CE.app"}, []string{"com.jetbrains.IntelliJ-IDEA-Ultimate", "com.jetbrains.IntelliJ-IDEA-Community"}}, {"webstorm", "WebStorm", "webstorm", jetbrainsArgs, "webstorm://open?file={file}&line={line}", []string{"WebStorm.app"}, []string{"com.jetbrains.WebStorm"}}, }
Editors is the curated list, probed on PATH in this order when nothing is configured. They open a directory as a bare argument, which DirCommand uses.
Functions ¶
func Command ¶
Command resolves the argv to open file at line. A configured `editor` template wins (with {file}/{line} substitution, or the file appended when it has neither placeholder); otherwise the first GUI editor found on PATH is used, falling back to the platform opener.
func DirCommand ¶
DirCommand resolves the argv to open a directory, the project-shaped variant of Command. A configured template is reused with {file} as the directory and {line} dropped, since a directory has no line to jump to. There is no platform-opener fallback: xdg-open would hand the directory to the file manager rather than an editor, so nil means "no editor found" and the caller should say so.
func For ¶
For resolves how to open file at line in the chosen editor: a listed one by its binary when that is on PATH, otherwise by its URL, for the dashboard to hand to the desktop. A URL template is filled in the same way; anything else, including no choice at all, resolves as Command does.
func IsTemplate ¶
IsTemplate reports whether a choice is a custom editor rather than a listed one: a command or a URL naming where the file goes with {file}.
func IsURLTemplate ¶
IsURLTemplate reports whether a custom editor is reached by its URL scheme.
Types ¶
type Editor ¶
type Editor struct {
ID string `json:"id"`
Label string `json:"label"`
// contains filtered or unexported fields
}
Editor is one editor lerd knows how to open a file in: the binary that jumps to file:line, and the URL scheme the editor registers with the desktop, which is how it is reached when its binary is not on PATH (a JetBrains IDE installed through Toolbox, say). The ID is what a site's `editor` names.