vyakarana व्याकरण
key grammar

vyakarana

व्याकरण · “grammar”

The key grammar every Vayu terminal tool shares: vim modes, Space as the leader, a which-key box, the help sheet and the palette, as a Go module for Bubble Tea.

येनाक्षरसमाम्नायमधिगम्य महेश्वरात् ।
कृत्स्नं व्याकरणं प्रोक्तं तस्मै पाणिनये नमः ॥

Salutation to Pāṇini, who received the list of sounds from Maheśvara and set out the whole of grammar. Pāṇinīya Śikṣā 57 (as numbered on sanskritdocuments.org)
v0.2.0 latest2 releases1 decisions recordedMIT license

#vyakarana

vyākaraṇa (व्याकरण) is Sanskrit for grammar, literally "taking apart, setting out". This module is the key grammar every Vayu terminal tool shares, so that knowing one tool's keys means knowing the next one's.

It is a Go module for Bubble Tea screens: the tools that use it are pattan, nauka, vaikhari and darshan.

vaikhari's Queue with vyakarana's which-key box open after Space: the groups that can follow, t tabs, r reload, e edit, y copy, p post, comma settings, ? every key, q quit, o open, d delete

The help sheet (Space ?): every key of the view, grouped by where it works, the Space sequences beside the direct keys The palette (Space Space): every action of the view, searched, with its keys on the right

In vaikhari's demo mode: made-up accounts and posts.

#The grammar

KeysGroup
Space Spacethe palette: every action of this view, searched
Space ?every key of this view
Space qclose
Space ttabs
Space utoggles: u f fullscreen, u p preview, u h hidden, u s secrets
Space ycopy
Space ffind and filter
Space ssort
Space rrefresh
Space aadd, new
Space ddelete (always asks first)
Space eedit
Space oopen outside: o b browser, o e $EDITOR, o t terminal
Space ggo to a place
Space mmark: star, pin, read
Space ,settings
Space kask the AI

The letters b c h i j l n p v w x z are free for a tool's own nouns (Space c a container in nauka, Space p a post in vaikhari).

#Packages

PackageWhat it is
keymapBinding (keys, action, verb-first description, view, modes), Keymap, the Engine (counts, sequences, the leader), the reserved groups, the help sheet's sections, and generators for Vayu's keybinding search (scripts/keybindings, scope <tool> <view>:<mode>) and the README's key tables
modeNORMAL, INSERT, VISUAL, COMMAND
popupthe which-key box (WhichAfter, WhichKey), the help sheet (Help), the palette (Palette), the confirm (Confirm, y only), the tmux popup's own key (IsPopupKey), Keys (splits keys typed fast into one at a time)
uithe drawing kit: rounded boxes, tabs, key caps, footer, table, colours from varna's theme
textkitty's row and column diacritics, for image placeholders
keymaptesttest helpers: VerbFirst, Reserved, NoPrefixClash, NoDuplicate, All, FileUpToDate, SectionUpToDate

#Using it

A tool keeps its keys as data and switches on the action names the engine gives back (Bubble Tea models are values, so a binding names its action instead of holding a closure over a stale copy):

var Keys = keymap.New("pattan",
	keymap.Common{Noun: "port", Tabs: true, Search: "Search the ports", Refresh: "Rescan the ports"}.Binds(),
	[]keymap.Binding{
		{Seq: "d d", Alt: []string{"Space d s"}, Act: "stop", Desc: "Stop the server (asks first)", Where: "ports"},
		{Seq: "Space a t", Act: "share", Desc: "Start a tunnel to the port", Where: "ports"},
		{Seq: "t", Moved: "Space a t", Where: "ports"},
	}).Where("ports", "On a port")

// in the model
r := m.eng.Feed(msg.String(), m.where()) // per key of popup.Keys(msg)
switch {
case !r.Handled: // INSERT: the key is the text field's
case r.Pending:
	return m, popup.WhichAfter(r.Gen)
case r.Message() != "":
	m.say(r.Message())
case r.Act != "":
	return m.run(r.Act, r.Count, r.Counted)
}

and in its tests:

func TestKeys(t *testing.T) {
	keymaptest.All(t, Keys)
	keymaptest.FileUpToDate(t, "../../scripts/keybindings", Keys.KeybindingsFile("Tmux", "go test ./internal/tui -update"), *update)
	keymaptest.SectionUpToDate(t, "../../README.md", Keys.Markdown(), *update)
}

#License

MIT