*llembas.txt*    LLeMbas in Neovim

The agent is the LLeMbas CLI. This plugin starts `lembas serve --stdio` and is its
client; the sign-in, the models, the tools and the permissions are the CLI's.

It needs LLeMbas CLI 2.0.0-beta.16 or newer; an older one is said once, with how
to update it. A `lembas` that is not on Neovim's PATH is also looked for in
~/.local/bin; anywhere else, set `cmd` (|llembas-setup|).

The CLI keeps ONE sign-in for the whole computer: the terminal and the linked
service use it too. |:LLeMbasLogin| is that same sign-in, made from here.

==============================================================================
COMMANDS                                                    *llembas-commands*

:LLeMbas                                                            *:LLeMbas*
    Open or close the chat panel: the transcript, and the prompt under it.
    In the prompt, <CR> in normal mode or <C-s> sends (or steers while busy),
    <C-c> stops the turn, <C-x><C-f> inserts @file, <C-x><C-o> inserts a
    /command, q closes the panel, g? opens help.
    In the transcript, <CR> or gf opens file:line under the cursor, K inspects
    tool output in a float, y yanks the fenced code block under the cursor, i
    jumps into the prompt, q closes.

:[range]LLeMbasAsk [question]                                    *:LLeMbasAsk*
    Ask about the lines of [range]. They are sent as the buffer has them,
    saved or not, with the file, the line numbers and the diagnostics on them.
    Without a question the lines are attached to the next message you type.

:[range]LLeMbasExplain                                       *:LLeMbasExplain*
    Ask the agent to explain the selected lines concisely.

:LLeMbasFix                                                      *:LLeMbasFix*
    Send the current buffer's reported diagnostics to the agent to fix.

:[range]LLeMbasEdit [instruction]                               *:LLeMbasEdit*
    Have the lines of [range] rewritten. The result is shown in place as
    changes: old lines marked, new lines beside them. Nothing is written
    until you accept. ga accepts the change under the cursor, gr rejects it,
    gA and gR do all, ]h and [h jump between changes.

:LLeMbasGenerate [instruction]                             *:LLeMbasGenerate*
    Generate code at the cursor line and show it as inline proposed hunks.

:LLeMbasCancelEdit                                       *:LLeMbasCancelEdit*
    Cancel an in-flight rewrite or generation in the current buffer.

:LLeMbasAccept[!]  :LLeMbasReject[!]            *:LLeMbasAccept* *:LLeMbasReject*
    Accept or reject the change under the cursor; with ! all of them.

:LLeMbasNextHunk  :LLeMbasPrevHunk            *:LLeMbasNextHunk* *:LLeMbasPrevHunk*
    Jump to the next or previous proposed change in the current buffer.

:LLeMbasAutocomplete [on|off]                           *:LLeMbasAutocomplete*
    Suggestions as you type. While typing, <Tab> accepts a shown suggestion,
    <M-Right> accepts the next word, and <M-\> asks for one now.

:LLeMbasAutocompleteTokens [N|auto|words|line|block|file] *:LLeMbasAutocompleteTokens*
    Configure how much autocomplete predicts (max tokens up to 4096 and/or a
    length preset: auto, words, line, block, file). Without an argument, opens
    a picker with presets and a custom token count input.

:LLeMbasAutocompleteInstructions [text|-]         *:LLeMbasAutocompleteInstructions*
    Set custom instructions sent with autocomplete requests ("-" clears them).

:LLeMbasAutocompleteModel[!] [model]               *:LLeMbasAutocompleteModel*
    The model that writes suggestions, saved in your account; without a name,
    pick from the list. With ! it is switched for this editor only. "-" goes
    back to the default.

:LLeMbasMainModel [model]                                  *:LLeMbasMainModel*
    The model for chat and rewriting, saved in your account. "?" shows both
    settings.

:LLeMbasFiles[!] [name]                                        *:LLeMbasFiles*
    Find a file or folder of the project by part of its name and insert @path
    into the prompt (! opens the chosen file in the editing window). Without
    a name it asks for one. Needs no session and no sign-in.

:LLeMbasOpenFile [name]                                     *:LLeMbasOpenFile*
    Open a file of the project, found the same way.

:LLeMbasCommands                                            *:LLeMbasCommands*
    Pick an available /command or skill and insert it into the prompt.

:LLeMbasSessions                                            *:LLeMbasSessions*
    List previous sessions in this directory and resume one with its history.

:LLeMbasCompact                                              *:LLeMbasCompact*
    Compact the active session's conversation context.

:LLeMbasToggleThoughts                                *:LLeMbasToggleThoughts*
    Toggle showing model thinking in the transcript.

:LLeMbasOpen                                                    *:LLeMbasOpen*
    Open the file the agent showed last with the system's viewer.

:LLeMbasStop                                                    *:LLeMbasStop*
    Stop the running turn.

:LLeMbasNew[!]                                                   *:LLeMbasNew*
    Start a new session (! ends a hung turn). Old sessions stay in the CLI.

:LLeMbasMode [mode]                                             *:LLeMbasMode*
    Change the session's mode (works live mid-turn); without an arg, pick.

:LLeMbasModel [model]                                          *:LLeMbasModel*
    Pick or change the session's model.

:LLeMbasStatus  :LLeMbasHelp                     *:LLeMbasStatus* *:LLeMbasHelp*
    Open floating status overview or commands & keymaps reference. The status
    says the CLI's version, the folder the agent works in, and why no
    suggestion came when none did.

:LLeMbasLogin [address] [--ca {file}]                         *:LLeMbasLogin*
    Sign this computer in to a LLeMbas server (the address is asked for when
    not given; nothing is predefined). The CLI's own sign-in is run
    (`lembas login --json`): the code to approve is shown in the chat and the
    approval page is opened in your browser. When it is approved the agent is
    started anew, so the open panel works at once.
    When the computer is signed in to another server already, the plugin says
    which and asks first: the new sign-in replaces it, for the terminal and
    the linked service too. --ca names the certificate authority of a server
    that has a private one (also `login.ca` in |llembas-setup|); with it the
    CLI always makes a new sign-in.

:LLeMbasLoginCancel                                     *:LLeMbasLoginCancel*
    Stop a sign-in that waits to be approved.

:LLeMbasLogout                                               *:LLeMbasLogout*
    Sign this computer out, after asking: the terminal and the linked service
    are signed out with it.

:LLeMbasRestart                                             *:LLeMbasRestart*
    Stop the agent. The transcript stays; the next message, suggestion or
    rewrite starts a new agent and a new session.

:LLeMbasLog                                                     *:LLeMbasLog*
    Show what the agent wrote on stderr: the running one's, or the last
    one's — where to look when it stopped.

==============================================================================
WHEN SOMETHING IS WRONG                                     *llembas-trouble*

The CLI is not found       the chat says so; install it or set `cmd`.
The CLI is too old         said once, with both versions: `lembas update`.
Not signed in              every way in says so: |:LLeMbasLogin|.
The agent stopped          the chat says why (its last words); the next
                           message starts it again. |:LLeMbasLog| has more.
The agent does not answer  the start is given up after 10 seconds and said;
                           a turn has no limit (<C-c> or |:LLeMbasStop| stops
                           it, |:LLeMbasNew|! ends the agent).
A turn failed              the reason is in the transcript, in red.
The plugin is too old      a server may ask for a newer plugin: said once.

==============================================================================
SETUP                                                          *llembas-setup*
>lua
    require("llembas").setup({
      cmd = { "lembas", "serve", "--stdio" },  -- the agent
      position = "right",      -- "right" | "left" | "bottom" | "float"
      width = 64,              -- the panel's columns
      prompt_height = 5,       -- the prompt window's rows
      border = "rounded",      -- border style for floating windows
      mode = nil,              -- the mode a session starts in
      model = nil,             -- the model a session starts on
      show_thoughts = false,   -- the model's thinking in the transcript
      send_open_file = true,   -- a typed message names the file you are in
      login = {
        ca = nil,              -- the CA file of a server with a private one
      },
      complete = {
        auto = true,           -- suggest as you type
        debounce_ms = 250,     -- the pause before a suggestion is asked for
        model = nil,           -- a model for this editor only
        max_tokens = nil,      -- max tokens to predict (nil: server default)
        length = "auto",       -- "auto" | "words" | "line" | "block" | "file"
        instructions = "",     -- custom autocomplete instructions
        accept = "<Tab>",      -- accepts a shown suggestion
        accept_word = "<M-Right>", -- accepts next word of suggestion
        trigger = "<M-\\>",    -- asks for a suggestion now
      },
    })
<
Statusline component: `require("llembas").statusline()`.
Highlights: `LLeMbasBrand`, `LLeMbasUserHeader`, `LLeMbasAgentHeader`,
`LLeMbasThought`, `LLeMbasToolPending`, `LLeMbasToolDone`, `LLeMbasToolFail`,
`LLeMbasToolDenied`, `LLeMbasPlanHeader`, `LLeMbasDiffAdd`, `LLeMbasDiffDelete`,
`LLeMbasDiffHint`, `LLeMbasGhost`, `LLeMbasSeparator` (all `default = true`).

What the model writes is shown as text. It is never run, and the panel's
buffers read no modeline.

 vim:tw=78:ts=8:ft=help:norl:
