kit

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package kit holds the shared vocabulary for declaring default command modules: key-sequence builders, signature helpers, option and completion constructors. Module packages import it to keep their bindings terse

Index

Constants

This section is empty.

Variables

View Source
var (
	LeaderBinding = Or(Char(' '), Ctrl('\\'))

	// LeaderPrefix enters the shared leader menu, reachable by Space or Ctrl-\
	LeaderPrefix = Prefixed(LeaderBinding)
)

Terse bindings for the plain special keys, named by their keycap form

Functions

func Alt

func Alt(r rune) command.KeyBinding

Alt is the binding for Alt held with a rune

func AltSpecial

func AltSpecial(s command.Special) command.KeyBinding

AltSpecial is the binding for Alt held with a special key

func BoolOr

func BoolOr(p *bool, def bool) bool

BoolOr dereferences p, falling back to def when p is nil

func Char

func Char(r rune) command.KeyBinding

Char is the single-key binding for a rune, adding Shift for an uppercase

func Continuation

func Continuation(fn command.KeyAction) command.Run

Continuation wraps a KeyAction into a command Run

func Ctrl

func Ctrl(r rune) command.KeyBinding

Ctrl is the binding for Ctrl held with a rune

func EditorBoolOption

func EditorBoolOption(
	key string, get EditorGetter[bool], set EditorSetter[bool],
) command.Option

EditorBoolOption builds a toggleable option over a bool editor value

func EditorNullableIntOption

func EditorNullableIntOption(
	key string, dflt int, get EditorGetter[*int], set EditorSetter[*int],
) command.Option

EditorNullableIntOption builds an option over a nullable int editor value, reporting dflt when unset

func FileCompleter

func FileCompleter(
	e *view.Editor, _ *command.Args, input string,
) []command.Completion

FileCompleter completes a positional argument against filesystem entries under the editor's working directory

func FileSig

func FileSig(sig command.Signature) command.Signature

FileSig attaches file-path expansion and completion to positionals

func IntOr

func IntOr(p *int, def int) int

IntOr dereferences p, falling back to def when p is nil

func KeyBinding

func KeyBinding(alts ...command.KeyBinding) []command.KeyBinding

KeyBinding unions alternatives into the one-element binding list a mode maps to, for building a per-mode Keys map by hand

func Keys

func Keys(alts ...command.KeyBinding) map[string][]command.KeyBinding

Keys builds the all-modes ("*") binding map from the given alternatives

func Label

func Label(
	label string, prefix command.KeyBinding, modes ...string,
) command.PrefixLabel

Label names a prefix key sequence for the pending-key hint popup

func Leader

func Leader(ch rune) map[string][]command.KeyBinding

Leader binds ch under the shared leader (see LeaderPrefix)

func MinArgs

func MinArgs(n int) command.Signature

MinArgs is a signature requiring at least n positional arguments

func OptionalArg

func OptionalArg() command.Signature

OptionalArg is a signature accepting zero or one positional argument

func Or

Or unions its arguments into a single binding of alternative sequences, so any one of them triggers the command or enters the shared prefix state

func Prefixed

func Prefixed(
	prefix command.KeyBinding,
) func(...command.KeyBinding) command.KeyBinding

Prefixed returns a builder that joins prefix ahead of any of the sub-bindings

func Runner

func Runner(fn command.Action) command.Run

Runner wraps a view Action into a command Run

func Seq

func Seq(parts ...command.KeyBinding) command.KeyBinding

Seq concatenates parts into sequences, expanding an Or at any position into the cross-product of the alternatives around it

func Shift

Shift is the binding for Shift held with a special key

func Sig

func Sig() command.Signature

Sig is the default command signature

func Special

func Special(s command.Special) command.KeyBinding

Special is the binding for a special key

func StaticSig

func StaticSig(sig command.Signature, items ...string) command.Signature

StaticSig attaches fixed-choice completion to a signature's positionals

func Window

func Window(subs ...command.KeyBinding) map[string][]command.KeyBinding

Window binds each sub under the Ctrl-w window chord or the leader's w menu, so window management shares the leader wherever the leader is reachable

Types

type EditorGetter

type EditorGetter[T any] func(*view.Editor) T

EditorGetter reads a typed value from the editor

type EditorSetter

type EditorSetter[T any] func(*view.Editor, T)

EditorSetter writes a typed value to the editor

Jump to

Keyboard shortcuts

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