lug

# Keys and commands

The screen has a transcript above and a prompt below. Lug has one mode at a time, Vim's normal, insert or visual, and it is the focused window's: the prompt edits like vim and starts in insert mode (the start_mode option), and the transcript, like any feed, is in normal mode, or visual while it selects. The transcript and the prompt are windows, linked so that neither fades while the other has the focus, and closing either closes both. <Esc> moves between them: from insert mode to normal, then from the prompt to the transcript, and from the transcript back to the prompt. <C-w> with a direction moves between any windows. i, a or o on the transcript, which takes no text, enters insert mode in the prompt. <leader> is <Space> by default.

## Default mappings

A mapping marked with a kind holds only while that kind of window has the focus: feed for the transcript and other feeds, prompt for an editor.

Mode Keys Does
normal, visual : Open the : line
normal <CR>, <C-y> Send the prompt
insert <C-y> Send the prompt
insert <CR> Break the line
insert; normal (prompt) <Up>, <Down> Recall an older, newer prompt
insert <C-c> Cancel the run
normal <C-c> Close a floating window; elsewhere, cancel the run
normal, insert <C-s> Steer the run with the prompt's text: it reaches the model after the tool it waits on, or is the next message
normal, insert <S-Tab> Toggle auto mode
normal, visual <C-w>h, <C-w>j, <C-w>k, <C-w>l Focus the window to the left, below, above, right
normal, visual <C-w>w Focus the next window
normal <C-w>s, <C-w>v Show the window's view again below, or to the right
normal <C-w>c, <C-w>o Close the window; close the others
normal <C-w>H, <C-w>J, <C-w>K, <C-w>L Move the window to the left, bottom, top or right edge
normal <C-w>+, <C-w>-, <C-w>>, <C-w>< A row taller or shorter, a column wider or narrower, times the count
normal <C-w>= Share the room evenly again
normal <Esc> Close a floating window; elsewhere, focus the window this one is linked with, the transcript from the prompt and back, or else the prompt
normal, insert <PageDown>, <PageUp> Scroll the focused feed, or else the transcript, half a page
normal, insert, visual <ScrollDown>, <ScrollUp> (the mouse wheel) Scroll the focused feed, or else the transcript, three lines
normal, visual (feed) ]m, [m The next, previous item
normal, visual (feed) ]u, [u The next, previous message of yours
normal, visual (feed) ]t, [t The next, previous tool card
normal (feed) za, zo, zc Toggle, open, close the fold under the cursor
normal (feed) zR, zM Open, close every fold
normal, visual (feed) q Quote the selection, or the cursor row, into the prompt
normal, visual gf Open the path under the cursor in your editor
insert @ Reference a file, with completion
normal <leader>am, <leader>aM Pick a model; switch to the next one
normal <leader>at Set the thinking level
normal <leader>ac Compact the conversation
normal <leader>ap Toggle plan mode
normal <leader>aa Pick from the live agents
normal <leader>ss, <leader>sr Pick a session; rename this one
normal <leader>ut Pick a theme

:map [MODE] lists the mappings in force.

## The prompt editor

Insert mode takes the usual keys, plus <C-a> and <C-e> for the line's start and end, and <C-w> and <C-u> to delete the word, or everything, before the cursor.

Normal mode supports:

There is one register. With the clipboard option on, yanks also go to the system clipboard.

## Feeds

The transcript, and any other feed, reads the keys no mapping takes as Vim reads a buffer that cannot change:

## Commands

Command Does
:quit, :q, :q! Close the focused window, and the windows linked with it; closing the last ones quits, which is refused during a run unless !
:qall, :qa, :qa! Quit; refused during a run unless !
:cancel End the run and drop queued messages
:model [NAME], :model! Switch model, or pick one; switch to the next
:model @ROLE [NAME] Set the model a plugin's @ROLE means, or pick one
:plan Toggle plan mode: the model may only read, until you approve the plan it submits
:agents Pick from the live agents: <CR> opens one's conversation, <C-x> cancels its run
:thinking [LEVEL] Set the thinking level, or pick one
:login PROVIDER KEY Save a provider's API key in ~/.lug/auth.json
:sessions Pick a session of this project to switch to
:rename [TITLE] Retitle the session
:compact [INSTRUCTIONS] Replace the conversation so far with a summary
:approvals [clear] Show the approval mode and tools allowed always; clear revokes them
:auto Toggle auto mode: tool calls run without asking
:set [NAME[=VALUE]] List, show or set options
:theme [NAME] Switch palette, or pick one
:hi GROUP [ATTR...] Show or change a highlight group
:edit [PATH] Open a file, or the path under the cursor, in your editor
:map [MODE] List mappings
:lua CODE Run Lua
:close, :only Close the focused window, and those linked with it, but not the last; close the others
:resize N Give the focused window N rows or columns, as its split runs
:haul, :haul update [NAME] Open the plugins panel; update every plugin, or one
:reload Reload the configuration

## The : line, dialogs and the popup

The : line, the dialogs and the completion popup have keymap modes of their own, so their keys can be mapped like any other:

Mode Keys Does
command <CR> Run the : line; under the slug style, the command selected on the bar unless the line names one or holds a space
command <Esc>, <C-c> Close it
command <BS> Delete a character, or close an empty line
command <Tab> Complete a command's name or argument; under the slug style, select the next command on the bar
command <S-Tab> Under the slug style, select the previous command on the bar
command <Up>, <Down> An older, newer line
input, picker <CR> Accept
input, confirm, picker <Esc> Cancel
confirm y, n Yes, no
picker <Down>, <C-n>, <Up>, <C-p> The next, previous item
popup <C-n>, <Down>, <C-p>, <Up> The next, previous candidate
popup <Tab>, <C-y> Take the candidate
popup <Esc> Close the popup

Other keys edit the line, as the prompt's insert mode does. While the popup is open, its keys come before those of the editor it completes.

## Approval dialog

When a tool call needs approval, a dialog shows what it will do, with the exact diff for an edit computed from the file on disk. While it is open, keys go to the approval mode and nowhere else; the dialog lists what they do:

Key Does
a Run the call
A Run it, and allow this tool from now on
e Edit the arguments in your editor first
d, <Esc> Skip the call; the run continues
D, <C-c> Skip it and end the run

## Mapping keys

lug.keymap.set("normal", "<leader>q", ":q")
lug.keymap.set("normal", "<C-j>", function(count) lug.feed.scroll(count) end,
  { desc = "scroll down", kind = "feed" })
lug.keymap.del("insert", "@")

A mapping to other keys, as vim's inoremap jk <Esc>, types them with lug.prompt.keys, which the prompt editor takes past every mapping:

lug.keymap.set("insert", "jk", function() lug.prompt.keys("<Esc>") end)
lug.keymap.set("normal", "H", function() lug.prompt.keys("^") end)

Keys are written as in vim: a, <CR>, <Esc>, <Tab>, <Space>, <C-a>, <A-CR>, <S-Tab>, <F1>, <ScrollUp> and <ScrollDown> for the mouse wheel, and sequences such as gg or <C-w>k. A mapping shadows the prompt editor's own key until it is removed. A mapping made on <Char> receives the text typed in that mode.