kit

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 AltKey added in v0.3.2

AltKey is the binding for Alt held with the keys of another binding

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 Keys

func Keys(alts ...command.KeyBinding) map[view.Mode]command.KeyBinding

Keys builds the any-mode binding map from the given alternatives

func Label

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

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

func Leader

func Leader(ch rune) map[view.Mode]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 RegisterHints added in v0.3.0

func RegisterHints(e *view.Editor) []command.KeyHint

RegisterHints offers the registers currently holding a value

func RequiredArg added in v0.3.0

func RequiredArg() command.Signature

RequiredArg is a signature accepting exactly one positional argument

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 the keys of another binding

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[view.Mode]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