LLeMbas IDE: the four bars are its screen; its keys for LLeMbas are the plugin's one table
The IDE starts with the tree open on the left and LLeMbas's settings, chat and prompt on the right, the state on top and the keys for where the focus is at the bottom. Its cheat sheet and README read LLeMbas's keys from the plugin's key table; the statusline and the line of buffers stand in when a bar is switched off; a session saves the code's windows only. Tests at 160x45, 100x30 and 80x24 on the installed IDE's own screen. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
20 files changed
+1208
-90
No files matched your search
@@ -2,6 +2,70 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added (Neovim plugin and LLeMbas IDE)
|
||||
|
||||
- **Four bars around the code.** LLeMbas IDE starts with them; in the plugin alone one option
|
||||
turns them on (`bars = true`), and each can be switched off.
|
||||
- **Top bar**: what LLeMbas is doing (idle, thinking, tools, writing, waiting for you, not signed
|
||||
in, no CLI, AI off), the conversation's title, model · mode · effort, how full the context is,
|
||||
suggestions on or off, and the git branch and the file's problems when there is room.
|
||||
- **Bottom bar**: the keys you need most for the bar that has the focus — the code, the tree,
|
||||
the prompt, the settings lines, the transcript, a proposed change — and Neovim's own state at
|
||||
its right end (mode, modified, macro, search count, line and column, pending operator).
|
||||
- **The tree** on the left, open by default: the file you are in is followed; `Enter` opens,
|
||||
`a` new (a `/` at the end makes a directory), `r` rename or move, `d` delete after asking (to
|
||||
the trash where there is one), `/` filter as you type, `.` hidden files; one git mark a row.
|
||||
- **The right bar**: the settings as they are now (model, mode, effort, autocomplete — `Enter`
|
||||
on a line opens its choices right under it), the chat, and the prompt.
|
||||
Every row is laid out from known widths: fixed cells, one cell that takes the rest and is cut
|
||||
with an ellipsis, nothing wrapped. On a narrow screen the right bar folds away, then the tree.
|
||||
- **The prompt says what Enter will do**: `ask ›`, `rewrite ›` or `add ›`. `Tab` in an empty
|
||||
prompt switches. *ask* sends the question to the chat; *rewrite* has the lines that came along
|
||||
rewritten and *add* has new code written at the point, both shown in the file as changes to
|
||||
accept or reject. `:LLeMbasPrompt [ask|rewrite|add]`.
|
||||
- **To the prompt with what you are on**: the selection, or else the cursor's line, comes along,
|
||||
and its name is shown above the prompt (`main.rs:12-18`).
|
||||
- **The LLeMbas terminal's chords**, beside keys that arrive in every terminal. One table
|
||||
(`require("llembas.keys")`) maps each action in both forms — `Ctrl+Shift+A` / `<Leader>la` to
|
||||
the prompt, `Ctrl+Tab` / `<Leader>lm` the mode, `Ctrl+Shift+M` the model, `Ctrl+Alt+M` the
|
||||
autocomplete model, `Ctrl+Alt+A` suggestions, `Ctrl+Shift+I` LLeMbas on and off, `Ctrl+Shift+G`
|
||||
stop, `Ctrl+Shift+Y` / `J` accept and reject (`Alt+Ctrl+Shift+Y` all), `Ctrl+Shift+E` the tree,
|
||||
`Ctrl+Shift+D` the chat, `Alt+←` / `Alt+→` between the bars, `Ctrl+Shift+P` the menu — and the
|
||||
bottom bar shows the form that reaches Neovim from your terminal. The IDE's cheat sheet and
|
||||
README are made from the same table.
|
||||
- **Effort**, in the settings lines, in the menu and as `:LLeMbasEffort`; a level the model does
|
||||
not offer is said, with the level it runs on.
|
||||
- **LLeMbas on and off** (`:LLeMbasAI`, `Ctrl+Shift+I`): off is a plain editor — the agent is
|
||||
stopped, no suggestion is asked for, nothing is sent.
|
||||
- **The menu** (`:LLeMbasMenu`, `Ctrl+Shift+P`): every command and every setting in one list.
|
||||
- **Remembered per working directory**, with a machine-wide default under it: the mode, the
|
||||
effort, suggestions and LLeMbas on or off, which bars are shown and how wide. The models stay
|
||||
where they were kept: the session's with the LLeMbas CLI, the autocomplete and main model in
|
||||
your account.
|
||||
- **Public API for anything that shows LLeMbas's state**: `settings()`, `setting_lines()`,
|
||||
`choices()`, `set()`, `prompt()`, `intent()`, and the event `User LLeMbasChanged`
|
||||
(`:help llembas-api`).
|
||||
- **Inside the LLeMbas terminal** the editor says that it is in front (the user var
|
||||
`llembas_ide`), so the terminal hands its own chords through; nothing is written elsewhere.
|
||||
|
||||
### Changed (LLeMbas IDE)
|
||||
|
||||
- `<Space>la`, `<Space>le` and `<Space>lg` go to the prompt (ask, rewrite, add) with the
|
||||
selection or the cursor's line, instead of asking on the command line. `<Space>lm` switches to
|
||||
the next mode; the list of modes is in the settings lines and the menu.
|
||||
- `<Space>e` shows and hides the tree; the side-by-side explorer is `<Space>E`.
|
||||
- The statusline and the line of open buffers stand in only when the bottom or the top bar is
|
||||
switched off. With the top bar shown the open buffers are reached with `<Space>,`, `<S-h>` and
|
||||
`<S-l>`.
|
||||
- In the right bar `Enter` sends from insert mode (`Ctrl+J` is a new line) and `Esc` goes back
|
||||
to the code. The chat panel on its own (`bars = false`) keeps its keys.
|
||||
- A session no longer saves the bars' windows; they are laid out anew around what it restores.
|
||||
|
||||
### Changed (Neovim plugin)
|
||||
|
||||
- A proposed change's hint, and the keys in a buffer with changes, are the key table's.
|
||||
- `<CR>`, `K` and `i` in the transcript and the prompt's keys are mapped from the key table.
|
||||
|
||||
## [1.0.0-beta.7] — 2026-12-02
|
||||
|
||||
### Changed (VS Code / VSCodium)
|
||||
|
||||
@@ -24,8 +24,9 @@ set the command to the program's full path (`cmd` in Neovim's `setup`, *LLeMbas:
|
||||
|
||||
<!-- ide:begin -->
|
||||
A complete Neovim IDE with LLeMbas built in, installed for one user by one script: a pinned
|
||||
Neovim, a ready configuration (explorer, fuzzy finder, Treesitter, language servers, completion,
|
||||
git, sessions, key hints), the LLeMbas theme and the plugin below. It keeps its own directories
|
||||
Neovim, a ready configuration (four bars around the code — state, keys, file tree, and LLeMbas's
|
||||
settings, chat and prompt — fuzzy finder, Treesitter, language servers, completion, git, sessions,
|
||||
key hints), the LLeMbas theme and the plugin below. It keeps its own directories
|
||||
and never touches a Neovim configuration of your own.
|
||||
|
||||
```sh
|
||||
@@ -92,6 +93,31 @@ By hand: add the checkout's `nvim` folder to `runtimepath` and run `:helptags <c
|
||||
| `:LLeMbasRestart` | stop the agent; it starts again when it is needed |
|
||||
| `:LLeMbasLog` | what the agent wrote on stderr (why it stopped, when it did) |
|
||||
| `:LLeMbasStatus`, `:LLeMbasHelp` | floating status overview / commands & keys card |
|
||||
| `:[range]LLeMbasPrompt [ask\|rewrite\|add]` | to the prompt with the lines, or the cursor's line, as the attachment; the prompt says what Enter will do |
|
||||
| `:LLeMbasEffort [level]` | the effort of the conversation |
|
||||
| `:LLeMbasAI [on\|off]` | everything of LLeMbas on or off (off: a plain editor, nothing is sent) |
|
||||
| `:LLeMbasMenu` | every command and every setting, to pick from |
|
||||
| `:LLeMbasBars [on\|off\|top\|bottom\|tree\|chat [on\|off]]` | the four bars, or one of them |
|
||||
| `:LLeMbasTree` | the file tree, show and hide |
|
||||
|
||||
**The four bars.** One option lays the editor out as LLeMbas IDE does — a top bar (what the agent
|
||||
is doing, the conversation, model · mode · effort, context, suggestions), a bottom bar (the keys
|
||||
for where the focus is, and Neovim's own state), a file tree on the left, and on the right the
|
||||
settings lines over the chat over the prompt:
|
||||
|
||||
```lua
|
||||
require("llembas").setup({ bars = true }) -- or a table: { tree = false, chat_width = 46, top = false, … }
|
||||
```
|
||||
|
||||
With the bars (or with `keys = true` alone) LLeMbas's keys are mapped from one table, each action
|
||||
in two forms: the LLeMbas terminal's chords (`Ctrl+Shift+A` to the prompt with the selection,
|
||||
`Ctrl+Tab` the mode, `Ctrl+Shift+M` the model, `Ctrl+Shift+Y`/`J` accept/reject, `Ctrl+Shift+E`/`D`
|
||||
the tree and the chat, `Ctrl+Shift+P` the menu, …), which need a terminal with the kitty keyboard
|
||||
protocol, and a key after `<Leader>l` that always arrives. In an empty prompt `<Tab>` switches
|
||||
what Enter does: ask, rewrite, add. The mode, the effort, on/off and the bars are remembered per
|
||||
working directory. Everything the bars show is public API — `settings()`, `setting_lines()`,
|
||||
`choices()`, `set()`, `prompt()`, the `User LLeMbasChanged` event — see `:help llembas-bars`,
|
||||
`:help llembas-keys` and `:help llembas-api`.
|
||||
|
||||
In the prompt: `<CR>` (normal mode) or `<C-s>` sends (or steers mid-turn), `<C-c>` stops the turn, `<C-x><C-f>` inserts `@file`, `<C-x><C-o>` inserts `/command`, `q` closes, `g?` opens help.
|
||||
In the transcript: `<CR>` / `gf` opens `file:line`, `K` inspects tool output in a float, `y` yanks the fenced code block under the cursor, `i` jumps to the prompt, `q` closes.
|
||||
|
||||
+169
-22
@@ -2,10 +2,11 @@
|
||||
|
||||
A complete Neovim editor with LLeMbas built in, installed by one script.
|
||||
|
||||
It is stock Neovim, a pinned release, with a ready configuration: file explorer, fuzzy finder,
|
||||
Treesitter highlighting, language servers, a completion menu, git signs and diffs, a statusline
|
||||
and a line of open buffers, key hints, a terminal, sessions, and the LLeMbas plugin for chat,
|
||||
asking about code, rewriting and suggestions as you type. It keeps to itself: its own
|
||||
It is stock Neovim, a pinned release, with a ready configuration: four bars around the code (what
|
||||
LLeMbas is doing at the top, the keys for where you are at the bottom, the file tree on the left,
|
||||
LLeMbas's settings, chat and prompt on the right), a fuzzy finder, Treesitter highlighting,
|
||||
language servers, a completion menu, git signs and diffs, key hints, a terminal, sessions, and
|
||||
the LLeMbas plugin for chat, asking about code, rewriting and suggestions as you type. It keeps to itself: its own
|
||||
`NVIM_APPNAME`, its own directories. A Neovim configuration of your own in `~/.config/nvim` is
|
||||
never read and never written.
|
||||
|
||||
@@ -91,23 +92,100 @@ does: a new version of the IDE carries new pins.
|
||||
- **Formatting** happens when you ask (`<Space>cf`), with a formatter that is installed, or the
|
||||
language server.
|
||||
|
||||
## The screen
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────────┐
|
||||
│ ● idle │ fix config loader │ flash · manual · high │ ctx 12% │ AC on │ top bar
|
||||
├────────────┬──────────────────────────────────┬──────────────────────┤
|
||||
│ ▾ src/ │ 1 fn main() { │ model flash │ the settings, live:
|
||||
│ ▸ api/ │ 2 let cfg = Config::load() │ mode manual │ Enter on a line opens
|
||||
│ main.rs│ 3 run(cfg) │ effort high │ its choices right there
|
||||
│ lib.rs │ 4 } │ autocomplete on │
|
||||
│ ▸ tests/ │ 5 ├──────────────────────┤
|
||||
│ Cargo.to…│ 6 fn run(cfg: Config) { │ ## You │ the chat
|
||||
│ README.md│ 7 ... │ why does load … │
|
||||
│ │ ├──────────────────────┤
|
||||
│ │ │ main.rs:2-3 │ what comes along
|
||||
│ │ │ ask › _ │ the prompt
|
||||
├────────────┴──────────────────────────────────┴──────────────────────┤
|
||||
│ ^⇧A ask · Tab accept suggestion · ^⇧P menu · Alt+←→ bars NOR 3:9 │ bottom bar
|
||||
└──────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
- **Top bar.** What LLeMbas is doing (idle, thinking, tools, writing, waiting for you, not signed
|
||||
in, no CLI, AI off), the conversation's title, model · mode · effort, how full the model's
|
||||
context is, suggestions on or off, and at the right end the git branch and the file's problems
|
||||
when there is room. Every cell has a fixed width; the title takes what is left and is cut with
|
||||
an ellipsis.
|
||||
- **Bottom bar.** The keys you need most *where the focus is*: it changes as you move between the
|
||||
code, the tree, the prompt, the settings lines, the transcript, and a proposed change. It is
|
||||
made from the same table that maps the keys, so it cannot show a key that is not bound, and it
|
||||
is cut from the end to fit, never wrapped. At its right end is Neovim's own state: the mode,
|
||||
`+` for unsaved changes, the macro being recorded, the search count, the line and column, and
|
||||
the pending operator.
|
||||
- **The tree** (left). Open by default, 26 columns. The file you are in is followed and marked.
|
||||
`Enter` opens a file and opens or closes a directory (`→`/`←` too), `a` makes a file — or a
|
||||
directory when the name ends in `/` — `r` renames or moves, `d` deletes after asking (into the
|
||||
trash where the system has one), `/` filters as you type, `.` shows hidden files. One mark per
|
||||
row says its git state (`M` changed, `A` added, `?` new, `D` deleted, `!` conflict, `•` a
|
||||
directory with changes inside).
|
||||
- **The right bar.** At the top the settings as they are now; move there and press `Enter` on a
|
||||
line to open its choices under it, `Enter` again to take one. Under them the conversation, and
|
||||
at the bottom the prompt. The prompt's first line begins with what `Enter` will do: `ask ›`,
|
||||
`rewrite ›` or `add ›`.
|
||||
|
||||
**From the code to LLeMbas.** `Ctrl+Shift+A` (or `<Space>la`) goes to the prompt and takes along
|
||||
what you are on: the selection, or else the cursor's line. Its name is shown above the prompt
|
||||
(`main.rs:12-18`). In an empty prompt `Tab` switches what `Enter` does with it:
|
||||
|
||||
| The prompt says | Enter |
|
||||
|---|---|
|
||||
| `ask ›` | sends the question to the chat, with what came along as context |
|
||||
| `rewrite ›` | has those lines rewritten; the result is shown in the file as changes to accept or reject |
|
||||
| `add ›` | has new code written at that point, shown the same way |
|
||||
|
||||
Nothing is written into a file until you accept it (`Ctrl+Shift+Y`, or `ga`; `Ctrl+Shift+J` or
|
||||
`gr` rejects). With text in the prompt `Tab` is Neovim's own Tab. `Enter` sends, `Ctrl+J` makes a
|
||||
new line, `Esc` goes back to the code.
|
||||
|
||||
**Narrow and low screens.** When the code would be left with fewer than 60 columns the right bar
|
||||
folds away, then the tree; `Ctrl+Shift+D` and `Ctrl+Shift+E` (or `Alt+→` / `Alt+←`) bring them
|
||||
back at any width. The top and bottom bars drop their least needed cells. Under 18 rows the
|
||||
settings lines make room for the chat.
|
||||
|
||||
**What is remembered.** The mode, the effort, suggestions on or off, LLeMbas on or off, which
|
||||
bars are shown and how wide the side bars are: per working directory, in
|
||||
`~/.local/state/llembas-ide/llembas/settings.json`. A directory that has chosen nothing takes
|
||||
the machine-wide values, which *Make these settings the default for every directory* in the menu
|
||||
(`Ctrl+Shift+P`) sets from where you are. The models are not kept here: the LLeMbas CLI remembers
|
||||
the model last used in a directory, and your account the autocomplete model.
|
||||
|
||||
## Keys
|
||||
|
||||
The leader key is `<Space>`. Press it and wait: the next keys are shown. `:LLeMbasIdeKeys` (or
|
||||
`<Space>ik`) shows this list in the editor.
|
||||
|
||||
**LLeMbas's keys have two forms.** The chords — `Ctrl+Shift+A` and the rest, the same as in the
|
||||
LLeMbas terminal — reach Neovim only from a terminal that reports such keys distinctly (the kitty
|
||||
keyboard protocol: kitty, Ghostty, foot, WezTerm with it switched on, and the LLeMbas terminal,
|
||||
which hands its own chords through while the IDE is in front). The other form, a key after
|
||||
`<Space>l`, arrives everywhere. Both are always mapped. The bottom bar shows the chords once one
|
||||
has arrived from your terminal (that is remembered) or the terminal is one known to report them,
|
||||
and the `<Space>` keys otherwise; `keys = { chords = true }` or `false` in your own file settles
|
||||
it by hand.
|
||||
|
||||
The completion menu and LLeMbas's suggestions share insert mode and never want the same key:
|
||||
`<Tab>` only ever accepts LLeMbas's grey suggestion; the menu is moved in with `<C-n>`/`<C-p>`
|
||||
and taken with `<CR>` (the entry you moved to) or `<C-y>` (the first one).
|
||||
`<Tab>` accepts LLeMbas's grey suggestion when one is shown and is a plain Tab otherwise; the menu
|
||||
is moved in with `<C-n>`/`<C-p>` and taken with `<CR>` (the entry you moved to) or `<C-y>` (the
|
||||
first one). In an empty prompt `<Tab>` switches ask, rewrite, add; no menu opens over the prompt.
|
||||
|
||||
<!-- keys:begin -->
|
||||
**Typing**
|
||||
|
||||
| Keys | In | What it does |
|
||||
|---|---|---|
|
||||
| `<Tab>` | insert | Accept LLeMbas's suggestion (the grey text) |
|
||||
| `<M-Right>` | insert | Accept one word of it |
|
||||
| `<M-\>` | insert | Ask for a suggestion now |
|
||||
| `<M-\>` | insert | Ask LLeMbas for a suggestion now (accepting one: under LLeMbas, below) |
|
||||
| `<C-n> <C-p>` | insert | Move in the completion menu (also <Down> <Up>) |
|
||||
| `<CR>` | insert | Take the menu entry you moved to; otherwise a new line |
|
||||
| `<C-y>` | insert | Take the menu's first entry |
|
||||
@@ -130,8 +208,8 @@ and taken with `<CR>` (the entry you moved to) or `<C-y>` (the first one).
|
||||
| `<Space><Space>` | normal | Find a file |
|
||||
| `<Space>/` | normal | Search in files (needs rg) |
|
||||
| `<Space>,` | normal | Switch buffer |
|
||||
| `<Space>e` | normal | File explorer at this file |
|
||||
| `<Space>E` | normal | File explorer at the working directory |
|
||||
| `<Space>e` | normal | File tree (the left bar), show and hide |
|
||||
| `<Space>E` | normal | Directories side by side, at this file (edit them like text) |
|
||||
| `<Space>ff` | normal | Find a file |
|
||||
| `<Space>fg` | normal | Search in files (needs rg) |
|
||||
| `<Space>fw` | normal | Search the word under the cursor |
|
||||
@@ -194,23 +272,55 @@ and taken with `<CR>` (the entry you moved to) or `<C-y>` (the first one).
|
||||
|
||||
| Keys | In | What it does |
|
||||
|---|---|---|
|
||||
| `<Space>ll` | normal | Chat panel, open and close |
|
||||
| `<Space>la` | normal, visual | Ask about the line or the selection (type the question) |
|
||||
| `<Space>le` | normal, visual | Have the line or the selection rewritten (type how) |
|
||||
| `<C-S-A> or <Space>la` | normal, visual | To the chat prompt; the selection, or else the cursor's line, comes along |
|
||||
| `<Space>le` | normal, visual | To the prompt, to have the selection or the line rewritten (shown as changes) |
|
||||
| `<Space>lg` | normal, visual | To the prompt, to have new code written at the cursor (shown as changes) |
|
||||
| `<Space>lx` | normal, visual | Explain the line or the selection |
|
||||
| `<Space>lg` | normal | Generate code at the cursor (type what) |
|
||||
| `<Space>lf` | normal | Fix this file's problems |
|
||||
| `<Space>lt` | normal | Suggestions as you type, on and off |
|
||||
| `<Space>lm` | normal | Change the mode |
|
||||
| `<Space>lM` | normal | Change the model |
|
||||
| `<Tab>` | insert, with a suggestion | Accept the suggestion (the grey text); without one, Neovim's own Tab |
|
||||
| `<M-Right>` | insert, with a suggestion | Accept one word of the suggestion |
|
||||
| `<C-M-a> or <Space>lt` | normal | Suggestions as you type, on and off |
|
||||
| `<C-M-m> or <Space>lC` | normal | Choose the model that writes suggestions |
|
||||
| `<C-S-P> or <Space>lp` | normal | The LLeMbas menu: every command and every setting |
|
||||
| `<C-Tab> or <Space>lm` | normal | Switch the mode |
|
||||
| `<C-S-M> or <Space>lM` | normal | Choose the model |
|
||||
| `<Space>lE` | normal | Choose the effort |
|
||||
| `<C-S-I> or <Space>lI` | normal | LLeMbas on and off (off: a plain editor, nothing is sent) |
|
||||
| `<C-S-G> or <Space>l.` | normal | Stop the running turn |
|
||||
| `<C-S-Y> or ga` | a proposed change | Accept the proposed change under the cursor |
|
||||
| `<C-S-J> or gr` | a proposed change | Reject the proposed change under the cursor |
|
||||
| `]h` | a proposed change | The next proposed change |
|
||||
| `[h` | a proposed change | The previous proposed change |
|
||||
| `<M-C-S-Y> or gA` | a proposed change | Accept every proposed change in the file |
|
||||
| `gR` | a proposed change | Reject every proposed change in the file |
|
||||
| `<C-S-E> or <Space>lb` | normal | The file tree, show and hide |
|
||||
| `<C-S-D> or <Space>ll` | normal | The chat (the right bar), show and hide |
|
||||
| `<M-Left>` | normal, insert | To the bar on the left: chat, code, tree |
|
||||
| `<M-Right>` | normal, insert | To the bar on the right: tree, code, chat |
|
||||
| `<Space>ls` | normal | Earlier conversations |
|
||||
| `<Space>ln` | normal | New conversation |
|
||||
| `<Space>lc` | normal | Commands and skills |
|
||||
| `<Space>lS` | normal | Status |
|
||||
| `<Space>l.` | normal | Stop the running turn |
|
||||
| `<Space>li` | normal | Sign in |
|
||||
| `<Space>l?` | normal | The plugin's commands and keys |
|
||||
| `ga gr` | normal | Accept or reject LLeMbas's proposed change (gA gR: all; ]h [h: move) |
|
||||
| `<CR> <Right> l` | the tree | Open the file; open or close the directory (→ opens, ← closes) |
|
||||
| `<Left> h` | the tree | Close the directory, or go to the one above |
|
||||
| `a` | the tree | New file, or directory with a / at the end |
|
||||
| `r` | the tree | Rename or move |
|
||||
| `d` | the tree | Delete, after asking (to the trash where there is one) |
|
||||
| `/` | the tree | Filter by name as you type (empty: everything again) |
|
||||
| `.` | the tree | Hidden files, show and hide |
|
||||
| `R` | the tree | Read the directory again |
|
||||
| `<CR>` | the settings lines | Open the line's choices, or take the one under the cursor |
|
||||
| `<Up> <Down>` | the settings lines | Move between the lines and the choices |
|
||||
| `<Esc>` | the settings lines | Close the choices; from the lines, back to the code |
|
||||
| `<CR>` | the prompt | Send (while a turn runs: steer it) |
|
||||
| `<Tab>` | the prompt | In an empty prompt: what Enter will do — ask, rewrite, add |
|
||||
| `<C-j>` | the prompt | A new line in the prompt |
|
||||
| `<Esc>` | the prompt | Back to the code |
|
||||
| `<CR>` | the transcript | Open the file:line under the cursor |
|
||||
| `K` | the transcript | What the tool on this line printed |
|
||||
| `i` | the transcript | To the prompt |
|
||||
|
||||
**Session**
|
||||
|
||||
@@ -249,8 +359,11 @@ and taken with `<CR>` (the entry you moved to) or `<C-y>` (the first one).
|
||||
<!-- keys:end -->
|
||||
|
||||
`<S-h>` and `<S-l>` replace Neovim's "top and bottom of the window" motions, `s` belongs to
|
||||
surround, and `<Esc>` in normal mode also clears the search highlight. Everything else of
|
||||
Neovim's is as it was.
|
||||
surround, and `<Esc>` in normal mode also clears the search highlight. `<M-Left>` and `<M-Right>`
|
||||
move between the bars. Everything else of Neovim's is as it was.
|
||||
|
||||
The open buffers have no line of their own while the top bar is shown: `<Space>,` lists them,
|
||||
`<S-h>` and `<S-l>` go through them, and the tree marks the one you are in.
|
||||
|
||||
## Make it yours
|
||||
|
||||
@@ -259,6 +372,33 @@ sets wins: options, keys, the theme (`vim.o.background = "light"`, or another co
|
||||
altogether), the LLeMbas plugin's settings (`require("llembas").setup({ … })`, see
|
||||
`:help llembas-setup`), more language servers (`vim.lsp.enable("name")`).
|
||||
|
||||
**The bars** are one table. Each can be switched off and the side bars have widths:
|
||||
|
||||
```lua
|
||||
require("llembas").setup({ bars = {
|
||||
top = true, bottom = true, -- off: the IDE's line of open buffers / its statusline instead
|
||||
tree = true, chat = true, -- whether the side bars are open when a directory is new to you
|
||||
tree_width = 26, chat_width = 42,
|
||||
min_code = 60, -- the side bars fold away below this many columns of code
|
||||
} })
|
||||
require("llembas").setup({ bars = false }) -- none of it: one window and the plain chat panel
|
||||
```
|
||||
|
||||
What you then switch by key in a directory is remembered for that directory and holds over the
|
||||
table; the menu's *Forget what this directory chose for itself* takes it back.
|
||||
|
||||
**LLeMbas's keys** are one table too (`:help llembas-keys`). Change an entry and map again, and
|
||||
the bottom bar, the menu and this list follow:
|
||||
|
||||
```lua
|
||||
local keys = require("llembas.keys")
|
||||
keys.by_id.ask.chord = "<F2>" -- instead of Ctrl+Shift+A
|
||||
keys.by_id.tree.alt = "<Leader>t" -- instead of <Space>lb
|
||||
require("llembas").setup({ keys = { prefix = "<Leader>l" } })
|
||||
```
|
||||
|
||||
Any other key is Neovim's own to map (`vim.keymap.set`), and what you map there wins.
|
||||
|
||||
Your own plugins go in `~/.config/llembas-ide/pack/user/start/<name>/`: clone each there
|
||||
yourself and set it up in your file. The IDE loads them and never installs or updates them.
|
||||
|
||||
@@ -294,6 +434,13 @@ settings unless you say otherwise, and touches nothing else.
|
||||
installed and signed in, and send the text around the cursor to your server; `<Space>lt`
|
||||
turns them off, and `complete = { auto = false }` in your settings keeps them off.
|
||||
- **A language server** you installed runs locally; what it does on the network is its own.
|
||||
- **LLeMbas off** (`Ctrl+Shift+I`, `<Space>lI`) makes it a plain editor: the agent is stopped, no
|
||||
suggestion is asked for, the chat is put away, and it stays so in that directory until you
|
||||
switch it on.
|
||||
- **Inside the LLeMbas terminal** (`$LLEMBAS_TERM` or `$LLEMBAS_TTY` set) the IDE tells the
|
||||
terminal that it is in front, by a user var (`llembas_ide=1`, cleared on the way out), so the
|
||||
terminal passes its chords on. That goes to the terminal and no further; in any other terminal
|
||||
nothing is written.
|
||||
|
||||
What a model writes is shown as text and never run. Modelines and per-directory configuration
|
||||
files (`exrc`) are off, and a `Session.vim` lying in a project is not read.
|
||||
|
||||
@@ -298,6 +298,29 @@ local groups = {
|
||||
["LLeMbasIdeWarn"] = { fg = "warning" },
|
||||
["LLeMbasIdeStatus"] = { fg = "leaf", bg = "surface_raised" },
|
||||
["LLeMbasIdeStatusOff"] = { fg = "ink_faint", bg = "surface_raised" },
|
||||
["LLeMbasBar"] = { fg = "ink_muted", bg = "surface_raised" },
|
||||
["LLeMbasBarKey"] = { fg = "leaf", bg = "surface_raised", bold = true },
|
||||
["LLeMbasBarTitle"] = { fg = "ink", bg = "surface_raised", bold = true },
|
||||
["LLeMbasBarSeparator"] = { fg = "border_strong", bg = "surface_raised" },
|
||||
["LLeMbasBarFact"] = { fg = "ink_faint", bg = "surface_raised" },
|
||||
["LLeMbasBarIdle"] = { fg = "leaf", bg = "surface_raised" },
|
||||
["LLeMbasBarBusy"] = { fg = "warning", bg = "surface_raised", bold = true },
|
||||
["LLeMbasBarWaiting"] = { fg = "accent", bg = "surface_raised", bold = true },
|
||||
["LLeMbasBarOff"] = { fg = "ink_faint", bg = "surface_raised" },
|
||||
["LLeMbasBarVim"] = { fg = "ink", bg = "surface_active" },
|
||||
["LLeMbasPromptPrefix"] = { fg = "leaf", bold = true },
|
||||
["LLeMbasChip"] = { fg = "accent", bg = "accent_soft" },
|
||||
["LLeMbasLineLabel"] = { fg = "ink_faint" },
|
||||
["LLeMbasLineValue"] = { fg = "ink" },
|
||||
["LLeMbasLineOff"] = { fg = "ink_faint", italic = true },
|
||||
["LLeMbasLineCurrent"] = { fg = "leaf", bold = true },
|
||||
["LLeMbasTreeDirectory"] = { fg = "accent" },
|
||||
["LLeMbasTreeCurrent"] = { bg = "surface_active", bold = true },
|
||||
["LLeMbasTreeChanged"] = { fg = "warning" },
|
||||
["LLeMbasTreeAdded"] = { fg = "success" },
|
||||
["LLeMbasTreeNew"] = { fg = "leaf" },
|
||||
["LLeMbasTreeDeleted"] = { fg = "danger" },
|
||||
["LLeMbasTreeConflict"] = { fg = "danger", bold = true },
|
||||
}
|
||||
|
||||
local terminal = { "bg_sunken", "danger", "leaf", "warning", "accent", "accent_hover", "success", "ink_muted", "border_strong", "danger", "leaf_hover", "warning", "accent_hover", "accent_hover", "success", "ink" }
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
-- The statusline and the line of open buffers.
|
||||
-- The bars. LLeMbas IDE's own are the LLeMbas plugin's layout (lua/llembas/layout.lua): the top
|
||||
-- bar is the tabline, the bottom bar the statusline. What is here is what stands in when one of
|
||||
-- them is switched off: mini.statusline for the bottom, mini.tabline (the open buffers) for the top.
|
||||
local M = {}
|
||||
local set = { statusline = false, tabline = false }
|
||||
|
||||
local function active()
|
||||
local s = require("mini.statusline")
|
||||
@@ -24,12 +27,30 @@ local function active()
|
||||
})
|
||||
end
|
||||
|
||||
--- Set up the stand-in for each bar of the layout that is off. Called at the start and whenever
|
||||
--- the layout's bars change (`User LLeMbasBars`).
|
||||
function M.refresh()
|
||||
local ok, layout = pcall(require, "llembas.layout")
|
||||
local o = ok and layout.options() or { on = false }
|
||||
if not (o.on and o.bottom) and not set.statusline then
|
||||
set.statusline = true
|
||||
require("mini.statusline").setup({ use_icons = false, content = { active = active } })
|
||||
end
|
||||
if not (o.on and o.top) and not set.tabline then
|
||||
set.tabline = true
|
||||
require("mini.tabline").setup({ show_icons = false })
|
||||
end
|
||||
end
|
||||
|
||||
M.active = active
|
||||
|
||||
function M.setup()
|
||||
require("mini.statusline").setup({
|
||||
use_icons = false,
|
||||
content = { active = active },
|
||||
M.refresh()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
group = vim.api.nvim_create_augroup("llembas_ide_bars", { clear = true }),
|
||||
pattern = "LLeMbasBars",
|
||||
callback = function() M.refresh() end,
|
||||
})
|
||||
require("mini.tabline").setup({ show_icons = false })
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -12,7 +12,7 @@ M.actions = {
|
||||
{ "f", "Find a file", function() require("mini.pick").builtin.files() end },
|
||||
{ "r", "Recent files", function() require("mini.extra").pickers.oldfiles() end },
|
||||
{ "s", "Restore this directory's session", function() require("llembas_ide.sessions").restore() end },
|
||||
{ "l", "LLeMbas chat", function() require("llembas_ide.llembas").cmd("LLeMbas")() end },
|
||||
{ "l", "LLeMbas chat", function() require("llembas_ide.llembas").cmd("LLeMbasPrompt")() end },
|
||||
{ "i", "Sign in to LLeMbas", function() require("llembas_ide.llembas").sign_in() end },
|
||||
{ "k", "Keys", function() require("llembas_ide.keys").show() end },
|
||||
{ "d", "Check the installation", function() vim.cmd("LLeMbasIdeDoctor") end },
|
||||
@@ -124,9 +124,12 @@ function M.open(welcome)
|
||||
vim.keymap.set("n", a[1], act(a[3]), { buffer = buf, nowait = true, silent = true, desc = a[2] })
|
||||
end
|
||||
local group = vim.api.nvim_create_augroup("llembas_ide_dashboard_" .. buf, { clear = true })
|
||||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
-- Drawn again when the screen changes size, and when the bars beside it have been laid out.
|
||||
vim.api.nvim_create_autocmd({ "VimResized", "User" }, {
|
||||
group = group,
|
||||
callback = function()
|
||||
pattern = { "*", "LLeMbasLayout" },
|
||||
callback = function(ev)
|
||||
if ev.event == "User" and ev.match ~= "LLeMbasLayout" then return end
|
||||
local w = vim.fn.bufwinid(buf)
|
||||
if w ~= -1 then draw(buf, w, welcome == true) end
|
||||
end,
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
-- Every key the IDE adds, in one table: the mappings, the hints that appear after <Space>, the
|
||||
-- cheat sheet (:LLeMbasIdeKeys) and the table in the README are all made from it.
|
||||
-- The leader is <Space>. Neovim's own keys are unchanged unless listed here.
|
||||
--
|
||||
-- LLeMbas's own keys are not written here a second time: they are the LLeMbas plugin's key table
|
||||
-- (lua/llembas/keys.lua), which maps them, feeds the bottom bar, and is read below for the cheat
|
||||
-- sheet. Each action there has two forms: a chord (Ctrl+Shift+A …) that arrives from a terminal
|
||||
-- with the kitty keyboard protocol, and a key after <Space>l that always arrives.
|
||||
local M = {}
|
||||
|
||||
local function pick(name, opts) return function() require("mini.pick").builtin[name](opts) end end
|
||||
local function extra(name, opts) return function() require("mini.extra").pickers[name](opts) end end
|
||||
local function ll(command) return require("llembas_ide.llembas").cmd(command) end
|
||||
local function problem(count)
|
||||
return function()
|
||||
if vim.diagnostic.jump then return vim.diagnostic.jump({ count = count, float = true }) end
|
||||
@@ -33,8 +37,8 @@ M.map = {
|
||||
{ "n", "<Leader><Space>", pick("files"), "Find a file", "Find" },
|
||||
{ "n", "<Leader>/", pick("grep_live"), "Search in files (needs rg)", "Find" },
|
||||
{ "n", "<Leader>,", pick("buffers"), "Switch buffer", "Find" },
|
||||
{ "n", "<Leader>e", function() require("mini.files").open(vim.api.nvim_buf_get_name(0)) end, "File explorer at this file", "Find" },
|
||||
{ "n", "<Leader>E", function() require("mini.files").open(vim.fn.getcwd()) end, "File explorer at the working directory", "Find" },
|
||||
{ "n", "<Leader>e", function() require("llembas.layout").toggle("tree") end, "File tree (the left bar), show and hide", "Find" },
|
||||
{ "n", "<Leader>E", function() require("mini.files").open(vim.api.nvim_buf_get_name(0)) end, "Directories side by side, at this file (edit them like text)", "Find" },
|
||||
{ "n", "<Leader>ff", pick("files"), "Find a file", "Find" },
|
||||
{ "n", "<Leader>fg", pick("grep_live"), "Search in files (needs rg)", "Find" },
|
||||
{ "n", "<Leader>fw", function() require("mini.pick").builtin.grep({ pattern = vim.fn.expand("<cword>") }) end, "Search the word under the cursor", "Find" },
|
||||
@@ -75,23 +79,7 @@ M.map = {
|
||||
{ "n", "<Leader>ga", mod("llembas_ide.git", "stage_hunk"), "Stage the change under the cursor", "Git" },
|
||||
{ "n", "<Leader>gr", mod("llembas_ide.git", "reset_hunk"), "Undo the change under the cursor", "Git" },
|
||||
{ "n", "<Leader>gb", function() require("mini.git").show_at_cursor() end, "Who changed this line, and the commit", "Git" },
|
||||
-- LLeMbas
|
||||
{ "n", "<Leader>ll", ll("LLeMbas"), "Chat panel, open and close", "LLeMbas" },
|
||||
{ { "n", "x" }, "<Leader>la", ":LLeMbasAsk ", "Ask about the line or the selection (type the question)", "LLeMbas" },
|
||||
{ { "n", "x" }, "<Leader>le", ":LLeMbasEdit ", "Have the line or the selection rewritten (type how)", "LLeMbas" },
|
||||
{ { "n", "x" }, "<Leader>lx", ":LLeMbasExplain<CR>", "Explain the line or the selection", "LLeMbas" },
|
||||
{ "n", "<Leader>lg", ":LLeMbasGenerate ", "Generate code at the cursor (type what)", "LLeMbas" },
|
||||
{ "n", "<Leader>lf", ll("LLeMbasFix"), "Fix this file's problems", "LLeMbas" },
|
||||
{ "n", "<Leader>lt", mod("llembas_ide.llembas", "toggle_autocomplete"), "Suggestions as you type, on and off", "LLeMbas" },
|
||||
{ "n", "<Leader>lm", ll("LLeMbasMode"), "Change the mode", "LLeMbas" },
|
||||
{ "n", "<Leader>lM", ll("LLeMbasModel"), "Change the model", "LLeMbas" },
|
||||
{ "n", "<Leader>ls", ll("LLeMbasSessions"), "Earlier conversations", "LLeMbas" },
|
||||
{ "n", "<Leader>ln", ll("LLeMbasNew"), "New conversation", "LLeMbas" },
|
||||
{ "n", "<Leader>lc", ll("LLeMbasCommands"), "Commands and skills", "LLeMbas" },
|
||||
{ "n", "<Leader>lS", ll("LLeMbasStatus"), "Status", "LLeMbas" },
|
||||
{ "n", "<Leader>l.", ll("LLeMbasStop"), "Stop the running turn", "LLeMbas" },
|
||||
{ "n", "<Leader>li", mod("llembas_ide.llembas", "sign_in"), "Sign in", "LLeMbas" },
|
||||
{ "n", "<Leader>l?", ll("LLeMbasHelp"), "The plugin's commands and keys", "LLeMbas" },
|
||||
-- (LLeMbas: the plugin's own key table; see the top of this file.)
|
||||
-- Sessions
|
||||
{ "n", "<Leader>sr", mod("llembas_ide.sessions", "restore"), "Restore this directory's session", "Session" },
|
||||
{ "n", "<Leader>sw", mod("llembas_ide.sessions", "save"), "Save the session now", "Session" },
|
||||
@@ -123,9 +111,7 @@ M.lsp = {
|
||||
|
||||
-- Keys that are not the IDE's mappings but belong on the cheat sheet: plugins' and Neovim's own.
|
||||
M.also = {
|
||||
{ "i", "<Tab>", "Accept LLeMbas's suggestion (the grey text)", "Typing" },
|
||||
{ "i", "<M-Right>", "Accept one word of it", "Typing" },
|
||||
{ "i", "<M-\\>", "Ask for a suggestion now", "Typing" },
|
||||
{ "i", "<M-\\>", "Ask LLeMbas for a suggestion now (accepting one: under LLeMbas, below)", "Typing" },
|
||||
{ "i", "<C-n> <C-p>", "Move in the completion menu (also <Down> <Up>)", "Typing" },
|
||||
{ "i", "<CR>", "Take the menu entry you moved to; otherwise a new line", "Typing" },
|
||||
{ "i", "<C-y>", "Take the menu's first entry", "Typing" },
|
||||
@@ -136,14 +122,55 @@ M.also = {
|
||||
{ "n", "K", "Documentation of the symbol under the cursor", "Editing" },
|
||||
{ "n", "gd gD gI gy", "Definition, declaration, implementation, type (with a language server)", "Editing" },
|
||||
{ "n", "]g [g", "Next and previous git change (]G [G: last and first)", "Git" },
|
||||
{ "n", "ga gr", "Accept or reject LLeMbas's proposed change (gA gR: all; ]h [h: move)", "LLeMbas" },
|
||||
}
|
||||
|
||||
--- LLeMbas's keys, from the plugin's table: { keys, where, what it does } for the cheat sheet.
|
||||
--- Both forms of an action are in the one cell, the chord first.
|
||||
local WHERE = {
|
||||
tree = "the tree", settings = "the settings lines", prompt = "the prompt", chat = "the transcript",
|
||||
change = "a proposed change", suggestion = "insert, with a suggestion",
|
||||
}
|
||||
function M.llembas_rows()
|
||||
local ok, keys = pcall(require, "llembas.keys")
|
||||
if not ok then return {} end
|
||||
local out = {}
|
||||
for _, r in ipairs(keys.rows()) do
|
||||
local both = {}
|
||||
if r.chord then both[#both + 1] = r.chord end
|
||||
if r.alt ~= "" then both[#both + 1] = r.alt end
|
||||
local where = WHERE[r.where]
|
||||
if not where then
|
||||
local names = {}
|
||||
for _, m in ipairs(r.modes) do names[#names + 1] = ({ n = "normal", x = "visual", i = "insert" })[m] or m end
|
||||
where = table.concat(names, ", ")
|
||||
end
|
||||
if #both > 0 then out[#out + 1] = { table.concat(both, " or "), where, r.desc } end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function modes(m) return type(m) == "table" and m or { m } end
|
||||
|
||||
--- Bindings given more than once (the same mode and keys), as text. Empty when the map is sound.
|
||||
function M.duplicates()
|
||||
local seen, dup = {}, {}
|
||||
-- LLeMbas's keys that are mapped everywhere count too: nothing here may take one of them.
|
||||
local ok, llembas = pcall(require, "llembas.keys")
|
||||
for _, k in ipairs(ok and llembas.table or {}) do
|
||||
if k.run and not k.virtual then
|
||||
local function take(mode, lhs)
|
||||
seen[mode .. " " .. vim.api.nvim_replace_termcodes(llembas.lhs(lhs), true, true, true)] = true
|
||||
end
|
||||
for _, lhs in ipairs(type(k.chord) == "table" and k.chord or { k.chord }) do
|
||||
for _, mode in ipairs({ "n", "x", "i" }) do take(mode, lhs) end
|
||||
end
|
||||
if not k.scope then
|
||||
for _, lhs in ipairs(llembas.alts(k)) do
|
||||
for _, mode in ipairs(k.modes or { "n" }) do take(mode, lhs) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
for _, list in ipairs({ M.map, M.lsp }) do
|
||||
for _, k in ipairs(list) do
|
||||
for _, mode in ipairs(modes(k[1])) do
|
||||
@@ -184,7 +211,15 @@ function M.sections()
|
||||
for _, k in ipairs(M.map) do add(k[5], k[2], k[1], k[4]) end
|
||||
for _, k in ipairs(M.also) do if k[4] ~= "Typing" and k[4] ~= "Editing" then add(k[4], k[2], k[1], k[3]) end end
|
||||
local out = {}
|
||||
for _, name in ipairs(order) do table.insert(out, { name, by[name] }) end
|
||||
for _, name in ipairs(order) do
|
||||
table.insert(out, { name, by[name] })
|
||||
-- LLeMbas's own section stands after Git, where it always stood.
|
||||
if name == "Git" then
|
||||
local rows = {}
|
||||
for _, r in ipairs(M.llembas_rows()) do table.insert(rows, { shown(r[1]), r[2], r[3] }) end
|
||||
if #rows > 0 then table.insert(out, { "LLeMbas", rows }) end
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
@@ -207,15 +242,23 @@ function M.show()
|
||||
for _, s in ipairs(M.sections()) do
|
||||
table.insert(lines, s[1])
|
||||
table.insert(titles, #lines - 1)
|
||||
-- The keys' column is as wide as this section's longest, so every row of it shares one edge.
|
||||
local kw, ww = 16, 16
|
||||
for _, r in ipairs(s[2]) do
|
||||
table.insert(lines, (" %-16s %-16s %s"):format(r[1], r[2], r[3]))
|
||||
kw, ww = math.max(kw, vim.fn.strdisplaywidth(r[1])), math.max(ww, vim.fn.strdisplaywidth(r[2]))
|
||||
end
|
||||
for _, r in ipairs(s[2]) do
|
||||
table.insert(lines, " " .. r[1] .. (" "):rep(kw - vim.fn.strdisplaywidth(r[1]) + 1) .. r[2] .. (" "):rep(ww - vim.fn.strdisplaywidth(r[2]) + 1) .. r[3])
|
||||
end
|
||||
table.insert(lines, "")
|
||||
end
|
||||
local buf = require("llembas_ide.ui").page("LLeMbas IDE: keys", lines)
|
||||
for _, l in ipairs(titles) do vim.api.nvim_buf_add_highlight(buf, -1, "Title", l, 0, -1) end
|
||||
for i = 2, #lines - 1 do
|
||||
if lines[i + 1]:sub(1, 2) == " " then vim.api.nvim_buf_add_highlight(buf, -1, "LLeMbasIdeKey", i, 2, 18) end
|
||||
if lines[i + 1]:sub(1, 2) == " " then
|
||||
local keys_end = lines[i + 1]:find(" ", 3, true) or 18
|
||||
vim.api.nvim_buf_add_highlight(buf, -1, "LLeMbasIdeKey", i, 2, keys_end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,17 @@ local M = {}
|
||||
|
||||
M.loaded = false
|
||||
|
||||
function M.has_cli() return vim.fn.executable("lembas") == 1 end
|
||||
--- Whether the agent's program can be started: `lembas` on PATH or where its installer puts it,
|
||||
--- or whatever `cmd` was set to.
|
||||
function M.has_cli()
|
||||
local ok, llembas = pcall(require, "llembas")
|
||||
if ok and type(llembas._command) == "function" then return llembas._command() ~= nil end
|
||||
return vim.fn.executable("lembas") == 1
|
||||
end
|
||||
|
||||
--- The layout LLeMbas IDE starts with: all four bars. `lua/user/init.lua` changes it with
|
||||
--- require("llembas").setup({ bars = { … } }); see |llembas-bars|.
|
||||
M.bars = { top = true, bottom = true, tree = true, chat = true, tree_width = 26, chat_width = 42 }
|
||||
|
||||
function M.setup()
|
||||
local ok, llembas = pcall(require, "llembas")
|
||||
@@ -16,6 +26,17 @@ function M.setup()
|
||||
llembas.setup({
|
||||
-- Without the CLI the IDE is an editor and stays quiet: no suggestions are asked for.
|
||||
complete = { auto = M.has_cli() },
|
||||
-- The keys are the plugin's own table, mapped in both forms; an action that needs the agent
|
||||
-- says what is missing instead of failing when there is no CLI.
|
||||
keys = {
|
||||
prefix = "<Leader>l",
|
||||
guard = function()
|
||||
if M.has_cli() then return true end
|
||||
M.sign_in()
|
||||
return false
|
||||
end,
|
||||
},
|
||||
bars = vim.deepcopy(M.bars),
|
||||
})
|
||||
M.loaded = true
|
||||
end
|
||||
@@ -32,13 +53,6 @@ function M.autocomplete_on()
|
||||
return ok and type(llembas.config) == "table" and type(llembas.config.complete) == "table" and llembas.config.complete.auto == true
|
||||
end
|
||||
|
||||
function M.toggle_autocomplete()
|
||||
if not M.loaded then return vim.notify("LLeMbas: the plugin is not installed", vim.log.levels.WARN) end
|
||||
if not M.has_cli() then return M.sign_in() end
|
||||
vim.cmd("LLeMbasAutocomplete " .. (M.autocomplete_on() and "off" or "on"))
|
||||
pcall(vim.cmd.redrawstatus)
|
||||
end
|
||||
|
||||
--- For the statusline: what LLeMbas is doing, in a few characters.
|
||||
function M.status()
|
||||
if not M.loaded then return "", false end
|
||||
|
||||
@@ -22,19 +22,30 @@ local function has_files()
|
||||
return false
|
||||
end
|
||||
|
||||
function M.save(quiet)
|
||||
function M.save(quiet, leaving)
|
||||
if not has_files() then
|
||||
if not quiet then vim.notify("Session: no files are open") end
|
||||
return false
|
||||
end
|
||||
-- A session holds the code's windows: the bars are put away while it is written, and are
|
||||
-- laid out again by the layout itself, the next time as now.
|
||||
local bars, layout = pcall(require, "llembas.layout")
|
||||
if bars then
|
||||
pcall(layout.remember_widths)
|
||||
pcall(layout.hide)
|
||||
end
|
||||
local ok, err = pcall(function() require("mini.sessions").write(M.name(), { verbose = false }) end)
|
||||
if bars and not leaving then pcall(layout.apply) end
|
||||
if not quiet then vim.notify(ok and "Session saved for " .. vim.fn.getcwd() or "Session: " .. tostring(err)) end
|
||||
return ok
|
||||
end
|
||||
|
||||
function M.restore()
|
||||
if not M.exists() then return vim.notify("Session: none saved for " .. vim.fn.getcwd()) end
|
||||
local bars, layout = pcall(require, "llembas.layout")
|
||||
if bars then pcall(layout.hide) end
|
||||
local ok, err = pcall(function() require("mini.sessions").read(M.name(), { verbose = false }) end)
|
||||
if bars then vim.schedule(function() pcall(layout.apply) end) end
|
||||
if not ok then vim.notify("Session: " .. tostring(err), vim.log.levels.WARN) end
|
||||
end
|
||||
|
||||
@@ -57,7 +68,7 @@ function M.setup()
|
||||
group = vim.api.nvim_create_augroup("llembas_ide_sessions", { clear = true }),
|
||||
callback = function()
|
||||
if vim.g.llembas_ide_no_session then return end
|
||||
M.save(true)
|
||||
M.save(true, true)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
+11
-3
@@ -209,10 +209,18 @@ local function run()
|
||||
end)
|
||||
|
||||
-- Bars.
|
||||
check("the statusline and the tabline draw", function()
|
||||
local s = vim.api.nvim_eval_statusline(require("mini.statusline").active(), {})
|
||||
check("the top and the bottom bar are the layout's, and draw", function()
|
||||
assert(vim.o.tabline:find("llembas.layout", 1, true) and vim.o.showtabline == 2, vim.o.tabline)
|
||||
assert(vim.o.statusline:find("llembas.layout", 1, true) and vim.o.laststatus == 3, vim.o.statusline)
|
||||
local top = vim.api.nvim_eval_statusline(vim.o.tabline, { use_tabline = true })
|
||||
eq(top.width, vim.o.columns, "the top bar's width")
|
||||
assert(top.str:find("no conversation", 1, true), top.str)
|
||||
local bottom = vim.api.nvim_eval_statusline(vim.o.statusline, {})
|
||||
assert(bottom.str:find(" ask ", 1, true) and bottom.str:find("NOR", 1, true), bottom.str)
|
||||
end)
|
||||
check("the IDE's own statusline is ready to stand in for the bottom bar", function()
|
||||
local s = vim.api.nvim_eval_statusline(require("llembas_ide.bars").active(), {})
|
||||
assert(#s.str > 0)
|
||||
assert(vim.o.tabline:find("MiniTabline", 1, true), vim.o.tabline)
|
||||
end)
|
||||
|
||||
-- Treesitter.
|
||||
|
||||
@@ -0,0 +1,459 @@
|
||||
-- The installed IDE's four bars, checked on its own screen at three sizes, through its launcher:
|
||||
-- llembas-ide --headless -c "luafile ide/tests/layout.lua"
|
||||
-- Environment: IDE_TEST_REPO (the repository). The stand-in agent is nvim/tests/agent_levels.py.
|
||||
-- With IDE_LAYOUT_STEP set this is one start of the IDE for the checks that need a new process
|
||||
-- (what is remembered, what is written to the terminal); the answer is one line, RESULT {json}.
|
||||
local repo = assert(vim.env.IDE_TEST_REPO, "IDE_TEST_REPO")
|
||||
local agent = repo .. "/nvim/tests/agent_levels.py"
|
||||
local step = vim.env.IDE_LAYOUT_STEP
|
||||
local passed, failed = 0, {}
|
||||
|
||||
local function check(name, cond, extra)
|
||||
if cond then passed = passed + 1 else
|
||||
table.insert(failed, name .. (extra ~= nil and (": " .. (type(extra) == "string" and extra or vim.inspect(extra))) or ""))
|
||||
end
|
||||
end
|
||||
local function wait(cond, ms) return vim.wait(ms or 8000, cond, 20) end
|
||||
local function t(keys) return vim.api.nvim_replace_termcodes(keys, true, false, true) end
|
||||
local function feed(keys) vim.api.nvim_feedkeys(t(keys), "mx", false) end
|
||||
local function row(r)
|
||||
vim.cmd("redraw")
|
||||
local out = {}
|
||||
for c = 1, vim.o.columns do out[#out + 1] = vim.fn.screenstring(r, c) end
|
||||
return table.concat(out)
|
||||
end
|
||||
local function top() return row(1) end
|
||||
local function bottom() return row(vim.o.lines - vim.o.cmdheight) end
|
||||
local function rtrim(s) return (s:gsub("%s+$", "")) end
|
||||
local function cell(text, w) return text .. (" "):rep(w - vim.fn.strdisplaywidth(text)) end
|
||||
local function width(s) return vim.fn.strdisplaywidth(s) end
|
||||
local function seg() return vim.o.columns < 60 and 15 or vim.o.columns < 120 and 20 or 35 end
|
||||
local function keys_part() return rtrim(vim.fn.strcharpart(bottom(), 0, vim.o.columns - seg())) end
|
||||
-- (At full width the segment's last six cells are the pending operator's, Neovim's own: not compared.)
|
||||
local function vim_part() return vim.fn.strcharpart(bottom(), vim.o.columns - seg(), seg() == 35 and 29 or seg()) end
|
||||
local function wins()
|
||||
local out = {}
|
||||
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if vim.api.nvim_win_get_config(w).relative == "" then
|
||||
local b = vim.api.nvim_win_get_buf(w)
|
||||
local ft, name = vim.bo[b].filetype, vim.api.nvim_buf_get_name(b)
|
||||
local kind = ft == "llembas-tree" and "tree" or ft == "llembas-settings" and "settings"
|
||||
or name:match("llembas://chat$") and "chat" or name:match("llembas://prompt$") and "prompt" or "code"
|
||||
out[kind] = { win = w, width = vim.api.nvim_win_get_width(w), height = vim.api.nvim_win_get_height(w) }
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
local function kinds(w)
|
||||
local names = vim.tbl_keys(w)
|
||||
table.sort(names)
|
||||
return table.concat(names, " ")
|
||||
end
|
||||
local function resize(cols, rows)
|
||||
vim.o.columns, vim.o.lines = cols, rows
|
||||
vim.api.nvim_exec_autocmds("VimResized", {})
|
||||
vim.wait(80)
|
||||
vim.cmd("redraw")
|
||||
end
|
||||
local function calls(method)
|
||||
local out = {}
|
||||
for _, line in ipairs(vim.fn.filereadable(vim.env.FAKE_AGENT_LOG) == 1 and vim.fn.readfile(vim.env.FAKE_AGENT_LOG) or {}) do
|
||||
local m = vim.json.decode(line)
|
||||
if m.method == method then out[#out + 1] = m.params end
|
||||
end
|
||||
return out
|
||||
end
|
||||
local function last_call(method) local c = calls(method); return c[#c] end
|
||||
|
||||
local function finish()
|
||||
vim.g.llembas_ide_no_session = true
|
||||
pcall(function() require("llembas").restart(true) end)
|
||||
io.stdout:write("\n")
|
||||
for _, f in ipairs(failed) do io.stdout:write("FAIL " .. f .. "\n") end
|
||||
io.stdout:write(("ide-layout: %d passed, %d failed (Neovim %s)\n"):format(passed, #failed, tostring(vim.version())))
|
||||
vim.cmd(#failed > 0 and "cquit 1" or "qa!")
|
||||
end
|
||||
|
||||
-- ── One start, for the parent's questions. ──────────────────────────────────────────────────────
|
||||
local function one_start()
|
||||
vim.g.llembas_ide_no_session = true
|
||||
vim.notify = function() end
|
||||
local L = require("llembas")
|
||||
local out = {}
|
||||
if step ~= "start" then
|
||||
L.setup({ cmd = { "python3", agent }, complete = { auto = true } })
|
||||
vim.o.columns, vim.o.lines = 160, 45
|
||||
vim.api.nvim_exec_autocmds("VimResized", {})
|
||||
vim.wait(80)
|
||||
end
|
||||
local layout, store = require("llembas.layout"), require("llembas.store")
|
||||
if step == "change" then
|
||||
L.mode("edit")
|
||||
wait(function() return store.get().mode == "edit" end)
|
||||
L.effort("high")
|
||||
L.autocomplete(false)
|
||||
layout.toggle("tree", false)
|
||||
vim.api.nvim_win_set_width(vim.fn.bufwinid(require("llembas.chat").tbuf), 46)
|
||||
elseif step == "change_b" then
|
||||
L.mode("plan")
|
||||
wait(function() return store.get().mode == "plan" end)
|
||||
elseif step == "session" then
|
||||
local done = false
|
||||
L.choices("mode", function() done = true end)
|
||||
wait(function() return done end)
|
||||
local p = last_call("session/new")
|
||||
out.new_mode, out.new_effort = p and (p._meta or {}).mode, p and (p._meta or {}).effort
|
||||
end
|
||||
layout.remember_widths()
|
||||
local s, o = L.settings(), layout.options()
|
||||
out.mode, out.effort, out.autocomplete = s.mode, s.effort, s.autocomplete
|
||||
out.tree, out.chat_width, out.top, out.bottom = o.tree, o.chat_width, o.top, o.bottom
|
||||
out.tree_open = require("llembas.tree").is_open()
|
||||
out.kinds = kinds(wins())
|
||||
out.state_file = store.path()
|
||||
out.tabline, out.statusline = vim.o.tabline, vim.o.statusline
|
||||
out.ask_chord = require("llembas.keys").by_id.ask.chord
|
||||
out.f2 = vim.fn.maparg("<F2>", "n") ~= "" or vim.fn.maparg("<F2>", "n", false, true).callback ~= nil
|
||||
io.stdout:write("RESULT " .. vim.json.encode(out) .. "\n")
|
||||
pcall(function() L.restart(true) end)
|
||||
vim.cmd("qa!")
|
||||
end
|
||||
|
||||
--- Start the IDE again through its launcher in `dir`; returns the decoded RESULT and what it wrote on stderr.
|
||||
local function start(dir, name, env)
|
||||
local e = vim.tbl_extend("force", { IDE_LAYOUT_STEP = name, PYTHONDONTWRITEBYTECODE = "1" }, env or {})
|
||||
local done = vim.system({ vim.env.LLEMBAS_IDE_LAUNCHER, "--headless", "-c", "luafile " .. repo .. "/ide/tests/layout.lua" },
|
||||
{ cwd = dir, env = e, text = false }):wait(60000)
|
||||
local ok, data = pcall(vim.json.decode, (done.stdout or ""):match("RESULT (%b{})") or "", { luanil = { object = true, array = true } })
|
||||
return ok and data or { failed = true, out = done.stdout, code = done.code }, done.stderr or ""
|
||||
end
|
||||
|
||||
local function run()
|
||||
local ide = require("llembas_ide")
|
||||
local L = require("llembas")
|
||||
local layout = require("llembas.layout")
|
||||
local keys = require("llembas.keys")
|
||||
local tree = require("llembas.tree")
|
||||
local lines = require("llembas.lines")
|
||||
local chat = require("llembas.chat")
|
||||
local said = {}
|
||||
vim.notify = function(m) said[#said + 1] = tostring(m) end
|
||||
|
||||
local work = vim.fn.tempname()
|
||||
local project = work .. "/project"
|
||||
vim.fn.mkdir(project .. "/src", "p")
|
||||
vim.fn.writefile({ "def a():", " return 1", "", "def b():", " return 2" }, project .. "/sample.py")
|
||||
vim.fn.writefile({ "x = 1" }, project .. "/src/util.py")
|
||||
work = vim.uv.fs_realpath(work)
|
||||
project = work .. "/project"
|
||||
vim.env.FAKE_AGENT_LOG = work .. "/agent.log"
|
||||
vim.env.PYTHONDONTWRITEBYTECODE = "1"
|
||||
|
||||
check("every part of the IDE started", #ide.problems == 0, ide.problems)
|
||||
|
||||
-- ── As installed, with no CLI: the bars are there, and the keys say what is missing. ─────────────
|
||||
vim.o.columns, vim.o.lines = 160, 45
|
||||
vim.api.nvim_exec_autocmds("VimResized", {})
|
||||
vim.wait(80)
|
||||
check("the layout is on by default, all four bars", layout.options().on and layout.options().top and layout.options().bottom
|
||||
and layout.options().tree and layout.options().chat, layout.options())
|
||||
check("the start screen stands between the tree and the right bar", vim.bo.filetype == "llembas-ide-dashboard"
|
||||
and kinds(wins()) == "chat code prompt settings tree", { vim.bo.filetype, kinds(wins()) })
|
||||
if not require("llembas_ide.llembas").has_cli() then
|
||||
check("without the CLI the top bar says so, and nothing is asked of anybody",
|
||||
vim.startswith(top(), " ● no CLI │ ") and top():find("│ AC off ", 1, true) ~= nil and L._state.conn == nil, top())
|
||||
local ide_llembas = require("llembas_ide.llembas")
|
||||
local sign_in, asked_to = ide_llembas.sign_in, 0
|
||||
ide_llembas.sign_in = function() asked_to = asked_to + 1 end
|
||||
feed(" la")
|
||||
check("without the CLI <Space>la leads to signing in instead of failing, and opens nothing",
|
||||
asked_to == 1 and vim.bo.filetype == "llembas-ide-dashboard" and L._state.conn == nil, { asked_to, vim.bo.filetype })
|
||||
ide_llembas.sign_in = sign_in
|
||||
feed(" e")
|
||||
check("<Space>e hides the tree without the CLI as with it", not tree.is_open())
|
||||
feed(" e")
|
||||
check("…and shows it again", tree.is_open())
|
||||
end
|
||||
|
||||
-- ── With an agent (the stand-in). 160×45. ───────────────────────────────────────────────────────
|
||||
L.setup({ cmd = { "python3", agent }, complete = { auto = true } })
|
||||
vim.cmd("cd " .. vim.fn.fnameescape(project))
|
||||
vim.cmd("edit " .. vim.fn.fnameescape(project .. "/sample.py"))
|
||||
local fbuf = vim.api.nvim_get_current_buf()
|
||||
vim.wait(100)
|
||||
local w = wins()
|
||||
check("160×45: tree, code, settings lines, chat and prompt", kinds(w) == "chat code prompt settings tree", kinds(w))
|
||||
check("160×45: the tree is 26 columns, the right bar 42, the code the rest",
|
||||
w.tree.width == 26 and w.chat.width == 42 and w.settings.width == 42 and w.prompt.width == 42 and w.code.width == 160 - 26 - 42 - 2, w)
|
||||
check("160×45: the top bar, cell for cell",
|
||||
top() == " ● idle │ " .. cell("no conversation yet", 160 - 2 - 17 - 3 - 3 - 32 - 3 - 8 - 3 - 6)
|
||||
.. " │ " .. cell("— · — · —", 32) .. " │ ctx — │ AC on ", top())
|
||||
check("160×45: both bars are exactly as wide as the screen", width(top()) == 160 and width(bottom()) == 160)
|
||||
check("160×45, in the code: the keys that always arrive (no chord was seen in this terminal)",
|
||||
keys_part() == " Spc la ask · Tab accept suggestion · Alt+→ one word · Spc lp menu · Alt+←→ bars · Spc lb tree · Spc ll chat", keys_part())
|
||||
check("160×45: Neovim's own state in its cells", vim_part() == " NOR" .. (" "):rep(19) .. "1:1 ", "[" .. vim_part() .. "]")
|
||||
check("the tree shows the directory and marks the file you are in", vim.deep_equal(tree.lines(), { " ▸ src/", " sample.py" }), tree.lines())
|
||||
|
||||
-- The keys: the plugin's one table, mapped here in both forms, and nothing beside it.
|
||||
local missing = {}
|
||||
for _, k in ipairs(keys.table) do
|
||||
if not k.virtual and k.run then
|
||||
for _, lhs in ipairs(type(k.chord) == "table" and k.chord or { k.chord }) do
|
||||
for _, mode in ipairs({ "n", "x", "i" }) do
|
||||
if next(vim.fn.maparg(lhs, mode, false, true)) == nil then missing[#missing + 1] = mode .. " " .. lhs end
|
||||
end
|
||||
end
|
||||
if not k.scope then
|
||||
for _, lhs in ipairs(keys.alts(k)) do
|
||||
for _, mode in ipairs(k.modes or { "n" }) do
|
||||
if next(vim.fn.maparg(keys.lhs(lhs), mode, false, true)) == nil then missing[#missing + 1] = mode .. " " .. keys.lhs(lhs) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
check("keys: every key of the table is mapped", #missing == 0, missing)
|
||||
local in_table = {}
|
||||
for _, k in ipairs(keys.table) do
|
||||
for _, lhs in ipairs(type(k.chord) == "table" and k.chord or { k.chord }) do in_table[t(lhs)] = true end
|
||||
for _, lhs in ipairs(keys.alts(k)) do in_table[t(keys.lhs(lhs))] = true end
|
||||
end
|
||||
local strays = {}
|
||||
for _, mode in ipairs({ "n", "x", "i" }) do
|
||||
for _, m in ipairs(vim.api.nvim_get_keymap(mode)) do
|
||||
local lhs = t(m.lhs)
|
||||
local ours = (m.desc or ""):match("^LLeMbas: ") or (vim.startswith(lhs, " l") and #lhs > 2)
|
||||
if ours and not in_table[lhs] and lhs ~= t(L.config.complete.trigger) then strays[#strays + 1] = mode .. " " .. m.lhs end
|
||||
end
|
||||
end
|
||||
check("keys: every mapping of the LLeMbas group (<Space>l…, and LLeMbas's own) is in the table", #strays == 0, strays)
|
||||
local shown = {}
|
||||
for _, where in ipairs({ "code", "tree", "prompt", "settings", "chat", "change" }) do
|
||||
for _, form in ipairs({ true, false }) do
|
||||
for _, k in ipairs(keys.for_bar(where, form)) do
|
||||
local e = keys.by_id[k.id]
|
||||
local lhs = (form and e.chord) or keys.alts(e)[1] or e.chord
|
||||
if type(lhs) == "table" then lhs = lhs[1] end
|
||||
local buf = ({ tree = tree.buf(), settings = lines.buf(), prompt = chat.ibuf, chat = chat.tbuf })[e.scope or ""]
|
||||
local bound
|
||||
if e.virtual or e.scope == "change" or e.scope == "suggestion" then
|
||||
-- Neovim's own arrows, or mapped only while a change or a suggestion is shown (checked
|
||||
-- below and in the plugin's own suite).
|
||||
bound = true
|
||||
elseif buf and not (form and e.chord) then
|
||||
bound = vim.api.nvim_buf_call(buf, function()
|
||||
return vim.fn.maparg(lhs, "n", false, true).buffer == 1 or vim.fn.maparg(lhs, "i", false, true).buffer == 1
|
||||
end)
|
||||
else
|
||||
bound = next(vim.fn.maparg(keys.lhs(lhs), "n", false, true)) ~= nil
|
||||
end
|
||||
if not bound then shown[#shown + 1] = where .. " " .. k.id .. " " .. tostring(lhs) end
|
||||
end
|
||||
end
|
||||
end
|
||||
check("keys: every key the bottom bar can show is bound where it shows it", #shown == 0, shown)
|
||||
check("keys: the IDE's own map takes none of LLeMbas's keys", #require("llembas_ide.keys").duplicates() == 0, require("llembas_ide.keys").duplicates())
|
||||
|
||||
-- The bottom bar for each bar that has the focus.
|
||||
layout.focus("tree")
|
||||
check("focus tree", keys_part() == " Enter open · a new · r rename · d delete · / filter · Alt+→ code · . hidden files · Spc la ask · Spc lp menu · Spc lb tree", keys_part())
|
||||
layout.focus("chat")
|
||||
check("focus prompt", keys_part() == " Enter send · Tab ask/rewrite/add · Spc lm mode · Spc lM model · Esc back to code · Spc l. stop", keys_part())
|
||||
vim.cmd("stopinsert")
|
||||
vim.api.nvim_set_current_win(wins().settings.win)
|
||||
check("focus settings lines", keys_part() == " Enter change · ↑↓ move · Esc back · Alt+← code", keys_part())
|
||||
vim.api.nvim_set_current_win(wins().chat.win)
|
||||
check("focus transcript", keys_part() == " Enter open file · K tool output · i prompt · Alt+← code · Spc l. stop · Spc la ask · Spc lp menu · Spc ll chat", keys_part())
|
||||
layout.focus("code")
|
||||
|
||||
-- A chord that arrives: the bar shows the chords from then on.
|
||||
feed("<C-S-E>")
|
||||
check("Ctrl+Shift+E hides the tree", wait(function() return not tree.is_open() end))
|
||||
feed("<C-S-E>")
|
||||
wait(function() return tree.is_open() end)
|
||||
check("code, chords", keys_part() == " ^⇧A ask · Tab accept suggestion · Alt+→ one word · ^⇧P menu · Alt+←→ bars · ^⇧E tree · ^⇧D chat", keys_part())
|
||||
layout.focus("tree")
|
||||
check("tree, chords", vim.startswith(keys_part(), " Enter open · a new · r rename · d delete · / filter · Alt+→ code"), keys_part())
|
||||
layout.focus("chat")
|
||||
check("prompt, chords", vim.startswith(keys_part(), " Enter send · Tab ask/rewrite/add · ^Tab mode · ^⇧M model · Esc back to code"), keys_part())
|
||||
|
||||
-- Tab in the prompt.
|
||||
local function prompt_rows()
|
||||
local pw = wins().prompt.win
|
||||
local pos = vim.fn.win_screenpos(pw)
|
||||
local out = {}
|
||||
for r = pos[1], pos[1] + vim.api.nvim_win_get_height(pw) - 1 do
|
||||
out[#out + 1] = vim.fn.strcharpart(row(r), pos[2] - 1, vim.api.nvim_win_get_width(pw))
|
||||
end
|
||||
return out
|
||||
end
|
||||
check("the prompt begins with what Enter does", prompt_rows()[2] == cell("ask ›", 42), prompt_rows())
|
||||
feed("<Tab>")
|
||||
check("Tab in an empty prompt: rewrite", L.intent() == "rewrite" and vim.startswith(prompt_rows()[2], "rewrite › "), prompt_rows())
|
||||
feed("<Tab>")
|
||||
check("Tab: add", L.intent() == "add" and vim.startswith(prompt_rows()[2], "add › "), prompt_rows())
|
||||
feed("<Tab>")
|
||||
check("Tab: ask again", L.intent() == "ask" and vim.startswith(prompt_rows()[2], "ask › "), prompt_rows())
|
||||
local menu = require("blink.cmp.config").keymap
|
||||
check("the completion menu has no <Tab>, and is not offered over the prompt", menu["<Tab>"] == nil and vim.b[chat.ibuf].completion == false)
|
||||
feed("<Esc>")
|
||||
check("Esc is back in the code", vim.api.nvim_get_current_buf() == fbuf)
|
||||
|
||||
-- What comes along.
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
||||
feed("Vj<C-S-A>")
|
||||
check("Ctrl+Shift+A with a selection: the chip names the lines", vim.api.nvim_get_current_buf() == chat.ibuf and rtrim(prompt_rows()[1]) == " sample.py:1-2", prompt_rows())
|
||||
vim.api.nvim_buf_set_lines(chat.ibuf, 0, -1, false, { "what is this?" })
|
||||
feed("<CR>")
|
||||
check("Enter sends the question with the selection", wait(function() return last_call("session/prompt") ~= nil end) and wait(function() return not L._state.busy end)
|
||||
and ((((last_call("session/prompt") or {})._meta or {}).lembas or {}).editor or {}).selection ~= nil, last_call("session/prompt"))
|
||||
check("the top bar and the settings lines follow the session",
|
||||
wait(function() return L.settings().context == 4 end)
|
||||
and top():find("│ " .. cell("model-a · manual · default", 32) .. " │ ctx 4% │ AC on ", 1, true) ~= nil
|
||||
and vim.deep_equal(lines.lines(), { "model model-a", "mode manual", "effort default", "autocomplete on" }), { top(), lines.lines() })
|
||||
layout.focus("code")
|
||||
vim.api.nvim_win_set_cursor(0, { 4, 0 })
|
||||
feed(" la")
|
||||
check("<Space>la without a selection: the cursor's line, as a point", rtrim(prompt_rows()[1]) == " sample.py:4", prompt_rows())
|
||||
feed("<Esc>")
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
||||
feed("Vj le")
|
||||
vim.api.nvim_buf_set_lines(chat.ibuf, 0, -1, false, { "REPLACE def a():\\n return 100" })
|
||||
feed("<CR>")
|
||||
check("rewrite: shown in the file as a change; the bar shows the change's keys",
|
||||
wait(function() return require("llembas.diff").pending(fbuf) == 1 end) and vim.api.nvim_get_current_buf() == fbuf
|
||||
and wait(function() return keys_part() == " ^⇧Y accept · ^⇧J reject · ]h next · Alt+^⇧Y accept all · [h previous · ^⇧P menu" end), keys_part())
|
||||
feed("<C-S-Y>")
|
||||
check("Ctrl+Shift+Y accepts it", vim.api.nvim_buf_get_lines(fbuf, 1, 2, false)[1] == " return 100")
|
||||
vim.cmd("silent write")
|
||||
|
||||
-- The settings lines, through the agent.
|
||||
vim.api.nvim_set_current_win(wins().settings.win)
|
||||
vim.api.nvim_win_set_cursor(0, { 2, 0 })
|
||||
feed("<CR>")
|
||||
check("Enter on mode opens its choices in the bar", wait(function() return #lines.lines() == 8 end) and lines.lines()[3] == " ● manual" and wins().settings.height == 8, lines.lines())
|
||||
feed("j<CR>")
|
||||
check("a choice is set through the agent and shown", wait(function() return (last_call("session/set_mode") or {}).modeId == "edit" end)
|
||||
and wait(function() return lines.lines()[2] == "mode edit" and #lines.lines() == 4 end) and top():find("model-a · edit · default", 1, true) ~= nil, { lines.lines(), top() })
|
||||
L.set("effort", "high")
|
||||
check("the effort too", wait(function() return (last_call("_lembas/configure") or {}).effort == "high" end)
|
||||
and wait(function() return lines.lines()[3] == "effort high" end), lines.lines())
|
||||
feed("<Esc>")
|
||||
local asked
|
||||
local select = vim.ui.select
|
||||
vim.ui.select = function(items, opts) asked = { items = items, opts = opts } end
|
||||
feed("<C-S-P>")
|
||||
local menu_text = {}
|
||||
for _, i in ipairs(asked and asked.items or {}) do menu_text[#menu_text + 1] = asked.opts.format_item(i) end
|
||||
menu_text = table.concat(menu_text, "\n")
|
||||
check("Ctrl+Shift+P: the menu has the effort and the bars", menu_text:find("Effort: high", 1, true) and menu_text:find("Tree: shown", 1, true)
|
||||
and menu_text:find("Top bar: shown", 1, true), menu_text)
|
||||
vim.ui.select = select
|
||||
|
||||
-- ── 100×30 and 80×24. ───────────────────────────────────────────────────────────────────────────
|
||||
vim.api.nvim_set_current_win(wins().code.win)
|
||||
vim.api.nvim_win_set_cursor(0, { 1, 0 })
|
||||
resize(100, 30)
|
||||
w = wins()
|
||||
check("100×30: the chat folds away, the tree stays", kinds(w) == "code tree" and w.tree.width == 26 and w.code.width == 73, w)
|
||||
check("100×30: the top bar",
|
||||
top() == " ● idle │ " .. cell("conversation", 100 - 2 - 17 - 3 - 3 - 32 - 3 - 8 - 3 - 6) .. " │ " .. cell("model-a · edit · high", 32) .. " │ ctx 4% │ AC on ", top())
|
||||
check("100×30: the bottom bar", keys_part() == " ^⇧A ask · Tab accept suggestion · Alt+→ one word · ^⇧P menu · Alt+←→ bars"
|
||||
and vim_part() == " NOR" .. (" "):rep(10) .. "1:1 ", { keys_part(), "[" .. vim_part() .. "]" })
|
||||
check("100×30: both rows are 100 wide", width(top()) == 100 and width(bottom()) == 100)
|
||||
layout.focus("tree")
|
||||
check("100×30, in the tree", keys_part() == " Enter open · a new · r rename · d delete · / filter · Alt+→ code", keys_part())
|
||||
layout.focus("code")
|
||||
resize(80, 24)
|
||||
w = wins()
|
||||
check("80×24: the code alone, all 80 columns", kinds(w) == "code" and w.code.width == 80, w)
|
||||
check("80×24: the top bar",
|
||||
top() == " ● idle │ " .. cell("conversation", 80 - 2 - 9 - 3 - 3 - 26 - 3 - 8 - 3 - 6) .. " │ " .. cell("model-a · edit · high", 26) .. " │ ctx 4% │ AC on ", top())
|
||||
check("80×24: the bottom bar", keys_part() == " ^⇧A ask · Tab accept suggestion · Alt+→ one word · ^⇧P menu"
|
||||
and vim_part() == " NOR" .. (" "):rep(10) .. "1:1 ", { keys_part(), "[" .. vim_part() .. "]" })
|
||||
check("80×24: both rows are 80 wide", width(top()) == 80 and width(bottom()) == 80)
|
||||
feed("<M-Right>")
|
||||
check("80×24: Alt+→ still reaches the chat", chat.is_open() and vim.api.nvim_get_current_buf() == chat.ibuf)
|
||||
check("80×24, in the prompt", keys_part() == " Enter send · Tab ask/rewrite/add · ^Tab mode · ^⇧M model", keys_part())
|
||||
feed("<Esc>")
|
||||
resize(160, 45)
|
||||
check("160×45 again: everything is back", kinds(wins()) == "chat code prompt settings tree", kinds(wins()))
|
||||
|
||||
-- ── A bar switched off: the IDE's stand-ins. ────────────────────────────────────────────────────
|
||||
layout.toggle("top", false)
|
||||
check("the top bar off: the line of open buffers stands in", vim.o.tabline:find("MiniTabline", 1, true) ~= nil and vim.o.showtabline == 2, vim.o.tabline)
|
||||
layout.toggle("bottom", false)
|
||||
check("the bottom bar off: the IDE's statusline stands in",
|
||||
#vim.api.nvim_eval_statusline(require("mini.statusline").active(), {}).str > 0 and not vim.o.statusline:find("llembas.layout", 1, true), vim.o.statusline)
|
||||
layout.toggle("top", true)
|
||||
layout.toggle("bottom", true)
|
||||
check("…and on again", vim.startswith(top(), " ● idle") and vim.startswith(keys_part(), " ^⇧A ask"), { top(), keys_part() })
|
||||
|
||||
-- ── A session holds the code's windows, not the bars. ───────────────────────────────────────────
|
||||
local sessions = require("llembas_ide.sessions")
|
||||
check("a session is saved with the bars put away, and they are back after", sessions.save(true) and kinds(wins()) == "chat code prompt settings tree", kinds(wins()))
|
||||
local session_text = table.concat(vim.fn.readfile(vim.fn.stdpath("state") .. "/sessions/" .. sessions.name()), "\n")
|
||||
check("the session file names no bar", not session_text:find("llembas://", 1, true), session_text:match("[^\n]*llembas://[^\n]*"))
|
||||
sessions.restore()
|
||||
vim.wait(200)
|
||||
check("restored: the file, with the bars around it", kinds(wins()) == "chat code prompt settings tree"
|
||||
and vim.fn.fnamemodify(vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(wins().code.win)), ":t") == "sample.py", kinds(wins()))
|
||||
sessions.delete()
|
||||
pcall(function() L.restart(true) end)
|
||||
|
||||
-- ── Remembered across restarts, per directory; and a person's own file. ─────────────────────────
|
||||
local dir_a, dir_b = work .. "/dir-a", work .. "/dir-b"
|
||||
vim.fn.mkdir(dir_a, "p")
|
||||
vim.fn.mkdir(dir_b, "p")
|
||||
local env = { FAKE_AGENT_LOG = work .. "/remember.log" }
|
||||
local r = start(dir_a, "change", env)
|
||||
check("remember: changed in one directory", r.mode == "edit" and r.effort == "high" and r.autocomplete == false and r.tree == false and r.chat_width == 46, r)
|
||||
check("remember: kept in the IDE's own state directory", type(r.state_file) == "string"
|
||||
and r.state_file:find("/llembas%-ide/llembas/settings%.json$") ~= nil and vim.fn.filereadable(r.state_file) == 1, r.state_file)
|
||||
r = start(dir_b, "look", env)
|
||||
check("remember: another directory starts as the IDE does", r.mode == nil and r.effort == nil and r.autocomplete == true and r.tree == true
|
||||
and r.chat_width == 42 and r.kinds == "chat code prompt settings tree", r)
|
||||
r = start(dir_b, "change_b", env)
|
||||
r = start(dir_a, "look", env)
|
||||
check("remember: the first directory, started again", r.mode == "edit" and r.effort == "high" and r.autocomplete == false and r.tree == false
|
||||
and r.tree_open == false and r.chat_width == 46 and r.kinds == "chat code prompt settings", r)
|
||||
r = start(dir_a, "session", env)
|
||||
check("remember: a session there starts on that mode and effort", r.new_mode == "edit" and r.new_effort == "high", r)
|
||||
r = start(dir_b, "look", env)
|
||||
check("remember: the second directory has its own", r.mode == "plan" and r.effort == nil and r.tree == true, r)
|
||||
|
||||
local user = vim.fn.stdpath("config") .. "/lua/user/init.lua"
|
||||
local before = vim.fn.readfile(user)
|
||||
vim.fn.writefile(vim.list_extend(vim.list_slice(before), {
|
||||
'require("llembas.keys").by_id.ask.chord = "<F2>"',
|
||||
'require("llembas").setup({ bars = { top = false, chat_width = 48 }, keys = { prefix = "<Leader>l" } })',
|
||||
}), user)
|
||||
r = start(dir_b, "look", env)
|
||||
check("your own file: a bar switched off, a width, a key changed in the table and mapped",
|
||||
r.top == false and r.bottom == true and r.chat_width == 48 and r.tabline:find("MiniTabline", 1, true) ~= nil
|
||||
and r.statusline:find("llembas.layout", 1, true) ~= nil and r.ask_chord == "<F2>" and r.f2 == true, r)
|
||||
vim.fn.writefile(vim.list_extend(vim.list_slice(before), { 'require("llembas").setup({ bars = false })' }), user)
|
||||
r = start(dir_b, "look", env)
|
||||
check("your own file: no bars at all — one window, the IDE's statusline and buffer line",
|
||||
r.kinds == "code" and r.tabline:find("MiniTabline", 1, true) ~= nil and not r.statusline:find("llembas.layout", 1, true), r)
|
||||
vim.fn.writefile(before, user)
|
||||
|
||||
-- ── The terminal. ───────────────────────────────────────────────────────────────────────────────
|
||||
local set, clear = "\27]1337;SetUserVar=llembas_ide=MQ==\7", "\27]1337;SetUserVar=llembas_ide=\7"
|
||||
local _, err = start(dir_b, "start", { LLEMBAS_TERM = "1" })
|
||||
check("user var: in the LLeMbas terminal llembas_ide=1 is set on start and cleared on exit, and nothing else is written", err == set .. clear, vim.inspect(err))
|
||||
_, err = start(dir_b, "start", { LLEMBAS_TTY = "pane-1" })
|
||||
check("user var: $LLEMBAS_TTY counts as well", err == set .. clear, vim.inspect(err))
|
||||
_, err = start(dir_b, "start", {})
|
||||
check("user var: in any other terminal nothing is written", err == "", vim.inspect(err))
|
||||
|
||||
vim.cmd("cd /")
|
||||
vim.fn.delete(work, "rf")
|
||||
end
|
||||
|
||||
vim.schedule(function()
|
||||
local ok, err = xpcall(step and one_start or run, debug.traceback)
|
||||
if not ok then table.insert(failed, "the checks themselves stopped: " .. tostring(err)) end
|
||||
if step and ok then return end
|
||||
finish()
|
||||
end)
|
||||
@@ -21,3 +21,19 @@
|
||||
-- Your own plugins: put each in ~/.config/llembas-ide/pack/user/start/<name>/ (git clone it
|
||||
-- there yourself) and set it up here. The IDE never installs or updates them.
|
||||
-- require("some_plugin").setup({})
|
||||
--
|
||||
-- The four bars (top, bottom, the tree on the left, LLeMbas on the right). Each can be switched
|
||||
-- off, and the side bars have widths; what you then switch by key in a directory is remembered
|
||||
-- for that directory (the LLeMbas menu forgets it again). See :help llembas-bars.
|
||||
-- require("llembas").setup({ bars = { top = true, bottom = true, tree = true, chat = true,
|
||||
-- tree_width = 26, chat_width = 42 } })
|
||||
-- require("llembas").setup({ bars = false }) -- no bars at all: the plain chat panel
|
||||
--
|
||||
-- LLeMbas's keys are one table (:help llembas-keys). Change an entry, then map again:
|
||||
-- local keys = require("llembas.keys")
|
||||
-- keys.by_id.ask.chord = "<F2>" -- instead of Ctrl+Shift+A
|
||||
-- keys.by_id.tree.alt = "<Leader>t" -- instead of <Space>lb
|
||||
-- require("llembas").setup({ keys = { prefix = "<Leader>l" } })
|
||||
-- When your terminal reports Ctrl+Shift chords and the bottom bar still shows the <Space> keys
|
||||
-- (or the other way round), say which it is:
|
||||
-- require("llembas").setup({ keys = { chords = true } })
|
||||
+196
-1
@@ -18,6 +18,11 @@ COMMANDS *llembas-commands*
|
||||
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.
|
||||
The prompt's first line begins with what <CR> will do: `ask ›`,
|
||||
`rewrite ›` or `add ›` (|llembas-intent|). <Tab> in an empty prompt
|
||||
switches between them; with text in the prompt it is Neovim's own <Tab>.
|
||||
<C-j> is a new line. With the bars (|llembas-bars|) <CR> sends from
|
||||
insert mode too and <Esc> goes back to the code.
|
||||
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.
|
||||
@@ -42,6 +47,37 @@ COMMANDS *llembas-commands*
|
||||
:LLeMbasGenerate [instruction] *:LLeMbasGenerate*
|
||||
Generate code at the cursor line and show it as inline proposed hunks.
|
||||
|
||||
:[range]LLeMbasPrompt [ask|rewrite|add] *:LLeMbasPrompt*
|
||||
To the prompt, with the lines of [range] — without one, the cursor's
|
||||
line — as the attachment: its name stands above the prompt
|
||||
(`main.rs:12-18`). The argument sets what <CR> will do. *llembas-intent*
|
||||
ask the question goes to the chat, the lines with it as context
|
||||
rewrite the lines are rewritten; the result is shown in the file as
|
||||
changes to accept or reject (as |:LLeMbasEdit|)
|
||||
add new code is written at the point, shown the same way
|
||||
(as |:LLeMbasGenerate|)
|
||||
After a rewrite or an add the prompt says `ask ›` again.
|
||||
|
||||
:LLeMbasEffort [level] *:LLeMbasEffort*
|
||||
The effort of the conversation: off, minimal, low, medium, high, xhigh,
|
||||
max or default. Without a level, pick one. A level the model does not
|
||||
offer is said, with the level it runs on.
|
||||
|
||||
:LLeMbasAI [on|off] *:LLeMbasAI*
|
||||
Everything of LLeMbas on or off. Off is a plain editor: the agent is
|
||||
stopped, no suggestion is asked for, nothing is sent, and it stays off in
|
||||
this directory until it is switched on.
|
||||
|
||||
:LLeMbasMenu *:LLeMbasMenu*
|
||||
Every command and every setting — the model, the mode, the effort,
|
||||
suggestions, the bars — in one list to pick from.
|
||||
|
||||
:LLeMbasBars [on|off|top|bottom|tree|chat [on|off]] *:LLeMbasBars*
|
||||
The four bars (|llembas-bars|) on or off, or one of them.
|
||||
|
||||
:LLeMbasTree *:LLeMbasTree*
|
||||
The file tree, show and hide (|llembas-tree|).
|
||||
|
||||
:LLeMbasCancelEdit *:LLeMbasCancelEdit*
|
||||
Cancel an in-flight rewrite or generation in the current buffer.
|
||||
|
||||
@@ -139,6 +175,155 @@ COMMANDS *llembas-commands*
|
||||
Show what the agent wrote on stderr: the running one's, or the last
|
||||
one's — where to look when it stopped.
|
||||
|
||||
==============================================================================
|
||||
THE BARS *llembas-bars*
|
||||
|
||||
`bars = true` in |llembas-setup| lays the editor out in four bars, each of
|
||||
which can be switched off (`bars = { top = false }`, |:LLeMbasBars|):
|
||||
|
||||
top what LLeMbas is doing, the conversation's title, model · mode ·
|
||||
effort, the context in percent, suggestions on or off, and the
|
||||
git branch and the file's problems when there is room. It is the
|
||||
'tabline'.
|
||||
bottom the keys for the bar that has the focus (|llembas-keys|), and
|
||||
Neovim's own state: mode, modified, macro, search count, line
|
||||
and column, pending operator. It is the 'statusline' (with
|
||||
'laststatus' 3 and 'showcmdloc' statusline).
|
||||
tree the file tree on the left (|llembas-tree|).
|
||||
chat the right bar: the settings lines (model, mode, effort,
|
||||
autocomplete — <CR> on a line opens its choices under it, <CR>
|
||||
on a choice takes it, <Esc> closes), the transcript, and the
|
||||
prompt with the attachment's name above it.
|
||||
|
||||
Every row is made of cells of a known width; one cell takes what is left and
|
||||
is cut with an ellipsis. Nothing wraps. When the code would have fewer than
|
||||
`min_code` columns the chat folds away, then the tree; a bar opened by key at
|
||||
that width is shown all the same. Under 18 rows the settings lines are left
|
||||
out. Switched off, the top and bottom bars give 'tabline' and 'statusline'
|
||||
back as they were (`User LLeMbasBars` is fired, for a distribution that puts
|
||||
its own there).
|
||||
>lua
|
||||
require("llembas").setup({ bars = {
|
||||
top = true, bottom = true, tree = true, chat = true,
|
||||
tree_width = 26, -- 16 to 60
|
||||
chat_width = 42, -- 34 to 50
|
||||
prompt_height = 3,
|
||||
min_code = 60,
|
||||
} })
|
||||
<
|
||||
The tree *llembas-tree*
|
||||
The working directory as lines. <CR> or l opens a file, and opens or
|
||||
closes a directory; <Right> opens, <Left> or h closes or goes to the
|
||||
directory above. a makes a file (a directory when the name ends in /),
|
||||
r renames or moves, d deletes after asking — into the trash where the
|
||||
system has one (`gio trash`, `trash-put`, `trash`), and for good, said so
|
||||
in the question, where it has none. / filters by name as you type, .
|
||||
shows hidden files, R reads the directory again. The file you are in is
|
||||
followed. The first column of a row is its git state: M changed, A added,
|
||||
? new, D deleted, ! conflict, • a directory with changes inside.
|
||||
|
||||
==============================================================================
|
||||
KEYS *llembas-keys*
|
||||
|
||||
`keys = true` (or `bars`) maps LLeMbas's keys from one table,
|
||||
`require("llembas.keys").table`. An action has two forms, and both are
|
||||
mapped:
|
||||
|
||||
the chord the LLeMbas terminal's: <C-S-A> and so on. It reaches
|
||||
Neovim only from a terminal that reports such keys (the
|
||||
kitty keyboard protocol).
|
||||
the other a key after the prefix (<Leader>l), or a plain key in one of
|
||||
the bars. It always arrives.
|
||||
|
||||
<C-S-A> <Leader>la to the prompt; the selection or the cursor's line
|
||||
comes along (|:LLeMbasPrompt|)
|
||||
<Leader>le the same, to rewrite <Leader>lg to add
|
||||
<C-Tab> <Leader>lm switch the mode
|
||||
<C-S-M> <Leader>lM choose the model <Leader>lE the effort
|
||||
<C-M-m> <Leader>lC choose the autocomplete model
|
||||
<C-M-a> <Leader>lt suggestions as you type, on and off
|
||||
<C-S-I> <Leader>lI LLeMbas on and off (|:LLeMbasAI|)
|
||||
<C-S-G> <Leader>l. stop the running turn
|
||||
<C-S-Y> ga accept the proposed change under the cursor
|
||||
<C-S-J> gr reject it <M-C-S-Y> gA accept all
|
||||
<C-S-E> <Leader>lb the tree, show and hide
|
||||
<C-S-D> <Leader>ll the chat, show and hide
|
||||
<M-Left> <M-Right> to the bar on the left, on the right
|
||||
<C-S-P> <Leader>lp the menu (|:LLeMbasMenu|)
|
||||
<Leader>ls sessions, ln new, lc commands, lx explain, lf fix, lS status,
|
||||
li sign in, l? help.
|
||||
|
||||
The bottom bar shows the form that works: the chords once one has arrived
|
||||
from this terminal (remembered) or when the terminal is one known to report
|
||||
them, the other form otherwise. `keys = { chords = true }` or `false` says it
|
||||
by hand; `keys = { prefix = "<Leader>a" }` moves the other form.
|
||||
To change a key, change its entry and set up again:
|
||||
>lua
|
||||
local keys = require("llembas.keys")
|
||||
keys.by_id.ask.chord = "<F2>"
|
||||
require("llembas").setup({ keys = true })
|
||||
<
|
||||
<Tab> has three jobs that never meet: while typing code it accepts a shown
|
||||
suggestion and is Neovim's own otherwise (the mapping exists only while a
|
||||
suggestion is shown); in an empty prompt it switches ask, rewrite, add; and
|
||||
it is never a completion menu's.
|
||||
|
||||
Inside the LLeMbas terminal (`$LLEMBAS_TERM` or `$LLEMBAS_TTY`) the plugin
|
||||
sets the terminal's user var `llembas_ide` to 1 when the keys are mapped and
|
||||
clears it on exit, so that the terminal hands its own chords through. Nothing
|
||||
is written in any other terminal.
|
||||
|
||||
==============================================================================
|
||||
FOR A STATUSLINE, A BAR, A SCRIPT *llembas-api*
|
||||
|
||||
require("llembas").settings() *llembas.settings()*
|
||||
What holds now: `state` ("idle", "thinking", "tools", "writing",
|
||||
"waiting", "starting", "signed_out", "no_cli", "off"), `title`,
|
||||
`session` (boolean), `model`, `mode`, `effort`, `context` (percent of the
|
||||
model's window, or nil), `autocomplete`, `ai`, `intent`, `attachment`,
|
||||
`busy`, `changes` (proposed changes in this buffer).
|
||||
|
||||
User LLeMbasChanged *LLeMbasChanged*
|
||||
Fired when any of that changes. `User LLeMbasBars`: the top or bottom bar
|
||||
was switched; `User LLeMbasLayout`: the side bars were laid out.
|
||||
|
||||
require("llembas").setting_lines() *llembas.setting_lines()*
|
||||
The settings as lines: `{ id, label, value, off }` for model, mode,
|
||||
effort, autocomplete.
|
||||
require("llembas").choices({id}, {cb}) *llembas.choices()*
|
||||
What a setting can be set to: `cb(list)` of `{ value, label, current }`,
|
||||
or `cb(nil, why)`. The models and modes are asked of the CLI.
|
||||
require("llembas").set({id}, {value}) *llembas.set()*
|
||||
Set it.
|
||||
require("llembas").prompt({opts}) *llembas.prompt()*
|
||||
|:LLeMbasPrompt|: `intent`, `first`, `last`, `attach = false`.
|
||||
require("llembas").intent([{name}]) *llembas.intent()*
|
||||
Set, and return, what <CR> in the prompt will do.
|
||||
require("llembas").effort([{level}]) .ai([{on}]) .autocomplete([{on}])
|
||||
require("llembas").cycle_mode() .menu()
|
||||
As the commands of those names.
|
||||
require("llembas.layout").toggle({bar} [, {on}]) .focus("tree"|"code"|"chat")
|
||||
.go(-1|1) .where() .options() .top_text([{width}])
|
||||
.bottom_text([{where} [, {width} [, {chords}]]])
|
||||
The bars: show and hide, move the focus, where it is, and the two rows as
|
||||
plain text of exactly the width asked for.
|
||||
require("llembas.keys").table .by_id .for_bar({where}) .rows()
|
||||
.written({lhs}) .chords()
|
||||
The key table, the keys a bar shows, the rows of a cheat sheet, a key as
|
||||
the bar writes it, and whether the chords arrive.
|
||||
|
||||
What is remembered *llembas-remembered*
|
||||
The mode, the effort, suggestions and LLeMbas on or off, which bars are
|
||||
shown and how wide the side bars are: per working directory, with a
|
||||
machine-wide level under it, in `stdpath("state")/llembas/settings.json`.
|
||||
A change is the directory's own. *Make these settings the default* in
|
||||
the menu copies what holds here to the machine-wide level; *Forget what
|
||||
this directory chose* removes the directory's own. `remember = false`
|
||||
keeps nothing. The models are not kept here: the session's model is the
|
||||
LLeMbas CLI's to remember (the model last used in a directory), and the
|
||||
autocomplete and main model are your account's
|
||||
(|:LLeMbasAutocompleteModel|, |:LLeMbasMainModel|).
|
||||
|
||||
==============================================================================
|
||||
WHEN SOMETHING IS WRONG *llembas-trouble*
|
||||
|
||||
@@ -180,13 +365,23 @@ SETUP *llembas-setup*
|
||||
accept_word = "<M-Right>", -- accepts next word of suggestion
|
||||
trigger = "<M-\\>", -- asks for a suggestion now
|
||||
},
|
||||
keys = false, -- true or { prefix, chords }: |llembas-keys|
|
||||
bars = false, -- true or a table: |llembas-bars|
|
||||
remember = true, -- |llembas-remembered|
|
||||
})
|
||||
<
|
||||
Statusline component: `require("llembas").statusline()`.
|
||||
Highlights: `LLeMbasBrand`, `LLeMbasUserHeader`, `LLeMbasAgentHeader`,
|
||||
`LLeMbasThought`, `LLeMbasToolPending`, `LLeMbasToolDone`, `LLeMbasToolFail`,
|
||||
`LLeMbasToolDenied`, `LLeMbasPlanHeader`, `LLeMbasDiffAdd`, `LLeMbasDiffDelete`,
|
||||
`LLeMbasDiffHint`, `LLeMbasGhost`, `LLeMbasSeparator` (all `default = true`).
|
||||
`LLeMbasDiffHint`, `LLeMbasGhost`, `LLeMbasSeparator`; the bars' `LLeMbasBar`,
|
||||
`LLeMbasBarKey`, `LLeMbasBarTitle`, `LLeMbasBarSeparator`, `LLeMbasBarFact`,
|
||||
`LLeMbasBarIdle`, `LLeMbasBarBusy`, `LLeMbasBarWaiting`, `LLeMbasBarOff`,
|
||||
`LLeMbasBarVim`; `LLeMbasPromptPrefix`, `LLeMbasChip`, `LLeMbasLineLabel`,
|
||||
`LLeMbasLineValue`, `LLeMbasLineOff`, `LLeMbasLineCurrent`; the tree's
|
||||
`LLeMbasTreeDirectory`, `LLeMbasTreeCurrent`, `LLeMbasTreeChanged`,
|
||||
`LLeMbasTreeAdded`, `LLeMbasTreeNew`, `LLeMbasTreeDeleted`,
|
||||
`LLeMbasTreeConflict` (all `default = true`).
|
||||
|
||||
What the model writes is shown as text. It is never run, and the panel's
|
||||
buffers read no modeline.
|
||||
|
||||
@@ -1740,11 +1740,20 @@ function M.help()
|
||||
" :LLeMbasFiles[!] Attach @file (! opens directly)",
|
||||
" :LLeMbasCommands Pick a /command or skill",
|
||||
"",
|
||||
" :[range]LLeMbasPrompt To the prompt with the lines: ask, rewrite or add",
|
||||
"",
|
||||
"Inline Diff Proposal Keys:",
|
||||
" ga / gr Accept / reject hunk under cursor",
|
||||
" gA / gR Accept / reject all hunks",
|
||||
" ]h / [h Next / previous proposed hunk",
|
||||
"",
|
||||
"Settings and bars:",
|
||||
" :LLeMbasMenu Every command and every setting",
|
||||
" :LLeMbasMode / Model / Effort",
|
||||
" :LLeMbasAI [on|off] LLeMbas on or off (off: a plain editor)",
|
||||
" :LLeMbasBars / Tree The four bars; the file tree",
|
||||
" Prompt: <Tab> in an empty prompt switches ask, rewrite, add",
|
||||
"",
|
||||
"Autocomplete:",
|
||||
" <Tab> / <M-Right> Accept suggestion / accept word",
|
||||
" <M-\\> Trigger suggestion manually",
|
||||
@@ -1964,6 +1973,11 @@ function M.menu()
|
||||
kept = nil
|
||||
vim.notify("LLeMbas: these settings are now the default; a directory with its own keeps them")
|
||||
end }
|
||||
items[#items + 1] = { text = "Forget what this directory chose for itself (the default holds again at the next start)", run = function()
|
||||
store.forget()
|
||||
kept = nil
|
||||
vim.notify("LLeMbas: this directory's own settings are forgotten")
|
||||
end }
|
||||
local done = {}
|
||||
for _, k in ipairs(keys.table) do
|
||||
if k.run and not k.scope and not done[k.desc] then
|
||||
|
||||
@@ -23,6 +23,9 @@ local function diff() return require("llembas.diff") end
|
||||
--- bar where the bottom bar shows it, with its priority there (1 first; cut from the end):
|
||||
--- { code = 1 } or { tree = { 6, "code" } } to say another word there.
|
||||
--- show how the keys are written in the bar when that is not the key's own name.
|
||||
--- virtual a line of the bar that stands for keys bound elsewhere (two entries' keys in one, or
|
||||
--- Neovim's own arrows); `sheet = false` keeps it out of a cheat sheet that has the others.
|
||||
--- free needs no agent: a distribution's guard is not asked.
|
||||
M.table = {
|
||||
-- From the code to the chat, with what you are on.
|
||||
{ id = "ask", chord = "<C-S-A>", alt = "<Prefix>a", modes = { "n", "x" }, label = "ask",
|
||||
@@ -89,7 +92,7 @@ M.table = {
|
||||
{ id = "right", alt = "<M-Right>", modes = { "n", "i" }, label = "bars", show = "Alt+→", free = true,
|
||||
desc = "To the bar on the right: tree, code, chat", run = function() layout().go(1) end,
|
||||
bar = { tree = { 6, "code" } } },
|
||||
{ id = "bars", alt = { "<M-Left>", "<M-Right>" }, virtual = true, label = "bars", show = "Alt+←→",
|
||||
{ id = "bars", alt = { "<M-Left>", "<M-Right>" }, virtual = true, sheet = false, label = "bars", show = "Alt+←→",
|
||||
desc = "Move between the tree, the code and the chat", bar = { code = 5 } },
|
||||
|
||||
-- Conversations.
|
||||
@@ -258,10 +261,10 @@ function M.rows()
|
||||
for _, k in ipairs(M.table) do
|
||||
local alts = {}
|
||||
for _, a in ipairs(M.alts(k)) do alts[#alts + 1] = M.lhs(a) end
|
||||
out[#out + 1] = {
|
||||
if k.sheet ~= false then out[#out + 1] = {
|
||||
id = k.id, chord = list(k.chord)[1], alt = table.concat(alts, " "),
|
||||
where = k.scope or "everywhere", desc = k.desc, modes = k.modes or { "n" },
|
||||
}
|
||||
} end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
@@ -286,14 +286,20 @@ end
|
||||
|
||||
local function floating(win) return vim.api.nvim_win_get_config(win).relative ~= "" end
|
||||
|
||||
--- A window beside the code that is not where a file is opened: a terminal, a quickfix list.
|
||||
local function aside(win)
|
||||
local bt = vim.bo[vim.api.nvim_win_get_buf(win)].buftype
|
||||
return bt == "terminal" or bt == "quickfix" or bt == "prompt"
|
||||
end
|
||||
|
||||
--- The window the code is in: the last one that had the focus and is not a bar.
|
||||
function M.code_win()
|
||||
if Y.code and vim.api.nvim_win_is_valid(Y.code) and not is_bar(Y.code) and not floating(Y.code)
|
||||
if Y.code and vim.api.nvim_win_is_valid(Y.code) and not is_bar(Y.code) and not floating(Y.code) and not aside(Y.code)
|
||||
and vim.api.nvim_win_get_tabpage(Y.code) == vim.api.nvim_get_current_tabpage() then
|
||||
return Y.code
|
||||
end
|
||||
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if not is_bar(w) and not floating(w) then
|
||||
if not is_bar(w) and not floating(w) and not aside(w) then
|
||||
Y.code = w
|
||||
return w
|
||||
end
|
||||
@@ -358,6 +364,8 @@ function M.apply()
|
||||
if not ok then vim.schedule(function() vim.notify("LLeMbas: the bars could not be laid out: " .. tostring(err), vim.log.levels.WARN) end) end
|
||||
pcall(vim.cmd, "redrawtabline")
|
||||
pcall(vim.cmd, "redrawstatus")
|
||||
-- The windows have their sizes: anything drawn to fit one may draw again.
|
||||
pcall(vim.api.nvim_exec_autocmds, "User", { pattern = "LLeMbasLayout", modeline = false })
|
||||
end
|
||||
|
||||
--- Whether a side bar is on the screen now.
|
||||
@@ -566,7 +574,7 @@ function M.setup(opts)
|
||||
vim.api.nvim_create_autocmd({ "WinEnter", "BufEnter", "ModeChanged", "DiagnosticChanged", "RecordingEnter", "RecordingLeave" },
|
||||
{ group = group, callback = function()
|
||||
local w = vim.api.nvim_get_current_win()
|
||||
if not is_bar(w) and not floating(w) then Y.code = w end
|
||||
if not is_bar(w) and not floating(w) and not aside(w) then Y.code = w end
|
||||
vim.schedule(redraw)
|
||||
end })
|
||||
vim.api.nvim_create_autocmd("VimResized", { group = group, callback = function()
|
||||
|
||||
@@ -103,6 +103,15 @@ function M.make_default(cwd)
|
||||
return write(data)
|
||||
end
|
||||
|
||||
--- Forget what the directory chose for itself: it takes the machine-wide values again.
|
||||
function M.forget(cwd)
|
||||
if not M.enabled then return false end
|
||||
local data = read()
|
||||
if data.directories[M.dir(cwd)] == nil then return true end
|
||||
data.directories[M.dir(cwd)] = nil
|
||||
return write(data)
|
||||
end
|
||||
|
||||
--- Whether the key chords were seen to arrive from the terminal named `id` (nil: never seen).
|
||||
function M.terminal(id)
|
||||
if not M.enabled or not id or id == "" then return nil end
|
||||
|
||||
+19
-8
@@ -35,14 +35,6 @@ local HIGHLIGHTS = {
|
||||
LLeMbasStatusAttach = { link = "DiagnosticHint" },
|
||||
-- The bars.
|
||||
LLeMbasBar = { link = "StatusLine" },
|
||||
LLeMbasBarKey = { link = "Special" },
|
||||
LLeMbasBarTitle = { link = "Title" },
|
||||
LLeMbasBarSeparator = { link = "WinSeparator" },
|
||||
LLeMbasBarFact = { link = "Comment" },
|
||||
LLeMbasBarIdle = { link = "DiagnosticOk" },
|
||||
LLeMbasBarBusy = { link = "DiagnosticWarn" },
|
||||
LLeMbasBarWaiting = { link = "DiagnosticInfo" },
|
||||
LLeMbasBarOff = { link = "Comment" },
|
||||
LLeMbasBarVim = { link = "StatusLine" },
|
||||
-- The prompt and the settings lines.
|
||||
LLeMbasPromptPrefix = { link = "Special" },
|
||||
@@ -61,12 +53,30 @@ local HIGHLIGHTS = {
|
||||
LLeMbasTreeConflict = { link = "DiagnosticError" },
|
||||
}
|
||||
|
||||
-- The coloured cells of the bars: each takes its colour from a standard group and its ground
|
||||
-- from StatusLine, so that a row of cells has one ground whatever the colourscheme.
|
||||
local BAR_CELLS = {
|
||||
LLeMbasBarKey = "Special", LLeMbasBarTitle = "Title", LLeMbasBarSeparator = "WinSeparator", LLeMbasBarFact = "Comment",
|
||||
LLeMbasBarIdle = "DiagnosticOk", LLeMbasBarBusy = "DiagnosticWarn", LLeMbasBarWaiting = "DiagnosticInfo", LLeMbasBarOff = "Comment",
|
||||
}
|
||||
|
||||
local function bar_cells()
|
||||
local base = vim.api.nvim_get_hl(0, { name = "StatusLine", link = false })
|
||||
local fg, bg = base.fg, base.bg
|
||||
if base.reverse then fg, bg = bg, fg end
|
||||
for name, from in pairs(BAR_CELLS) do
|
||||
local own = vim.api.nvim_get_hl(0, { name = from, link = false })
|
||||
vim.api.nvim_set_hl(0, name, { default = true, fg = own.fg or fg, bg = bg, bold = own.bold, italic = own.italic })
|
||||
end
|
||||
end
|
||||
|
||||
local hi_installed = false
|
||||
|
||||
function M.setup_highlights()
|
||||
for name, spec in pairs(HIGHLIGHTS) do
|
||||
vim.api.nvim_set_hl(0, name, vim.tbl_extend("force", { default = true }, spec))
|
||||
end
|
||||
bar_cells()
|
||||
if not hi_installed then
|
||||
hi_installed = true
|
||||
local group = vim.api.nvim_create_augroup("llembas-highlights", { clear = true })
|
||||
@@ -76,6 +86,7 @@ function M.setup_highlights()
|
||||
for name, spec in pairs(HIGHLIGHTS) do
|
||||
vim.api.nvim_set_hl(0, name, vim.tbl_extend("force", { default = true }, spec))
|
||||
end
|
||||
bar_cells()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
@@ -315,6 +315,31 @@ GROUPS = [
|
||||
("LLeMbasIdeWarn", "warning", None, ""),
|
||||
("LLeMbasIdeStatus", "leaf", "surface_raised", ""),
|
||||
("LLeMbasIdeStatusOff", "ink_faint", "surface_raised", ""),
|
||||
# --- the layout: the top and the bottom bar share one ground, so no cell stands out by it ---
|
||||
("LLeMbasBar", "ink_muted", "surface_raised", ""),
|
||||
("LLeMbasBarKey", "leaf", "surface_raised", "bold"),
|
||||
("LLeMbasBarTitle", "ink", "surface_raised", "bold"),
|
||||
("LLeMbasBarSeparator", "border_strong", "surface_raised", ""),
|
||||
("LLeMbasBarFact", "ink_faint", "surface_raised", ""),
|
||||
("LLeMbasBarIdle", "leaf", "surface_raised", ""),
|
||||
("LLeMbasBarBusy", "warning", "surface_raised", "bold"),
|
||||
("LLeMbasBarWaiting", "accent", "surface_raised", "bold"),
|
||||
("LLeMbasBarOff", "ink_faint", "surface_raised", ""),
|
||||
("LLeMbasBarVim", "ink", "surface_active", ""),
|
||||
# --- the prompt, the settings lines, the tree ---
|
||||
("LLeMbasPromptPrefix", "leaf", None, "bold"),
|
||||
("LLeMbasChip", "accent", "accent_soft", ""),
|
||||
("LLeMbasLineLabel", "ink_faint", None, ""),
|
||||
("LLeMbasLineValue", "ink", None, ""),
|
||||
("LLeMbasLineOff", "ink_faint", None, "italic"),
|
||||
("LLeMbasLineCurrent", "leaf", None, "bold"),
|
||||
("LLeMbasTreeDirectory", "accent", None, ""),
|
||||
("LLeMbasTreeCurrent", None, "surface_active", "bold"),
|
||||
("LLeMbasTreeChanged", "warning", None, ""),
|
||||
("LLeMbasTreeAdded", "success", None, ""),
|
||||
("LLeMbasTreeNew", "leaf", None, ""),
|
||||
("LLeMbasTreeDeleted", "danger", None, ""),
|
||||
("LLeMbasTreeConflict", "danger", None, "bold"),
|
||||
]
|
||||
|
||||
# The terminal's sixteen colours, by palette name.
|
||||
|
||||
+21
-3
@@ -23,7 +23,8 @@ QUICK=0
|
||||
case "${1:-}" in
|
||||
--quick) QUICK=1 ;;
|
||||
--update-readme)
|
||||
nvim --headless -u NONE --cmd "set rtp+=ide/config" \
|
||||
# LLeMbas's own rows are read from the plugin's key table, so the plugin is on the path too.
|
||||
nvim --headless -u NONE --cmd "set rtp+=ide/config" --cmd "set rtp+=nvim" \
|
||||
-c 'lua io.stdout:write(table.concat(require("llembas_ide.keys").markdown(), "\n"))' -c q >ide/README.keys.tmp
|
||||
python3 - <<'PY'
|
||||
import re
|
||||
@@ -113,10 +114,19 @@ typing() { # the completion menu, through the launcher
|
||||
out="$( (cd "$WORK" && as "$home" timeout 60 "$home/.local/bin/llembas-ide" --headless -c "luafile $REPO/ide/tests/typing.lua" 2>&1) || true)"
|
||||
if grep -q -F 'ide-typing: the menu opens' <<<"$out"; then ok "$2"; else fail "$2" "$out"; fi
|
||||
}
|
||||
# The four bars, on the installed IDE's own screen. layout <home> "name"
|
||||
layout() {
|
||||
local home="$1" out line
|
||||
out="$( (cd "$WORK" && as "$home" env IDE_TEST_REPO="$REPO" timeout 420 "$home/.local/bin/llembas-ide" --headless \
|
||||
-c "luafile $REPO/ide/tests/layout.lua" 2>&1) || true)"
|
||||
line="$(grep -o -E 'ide-layout: [0-9]+ passed, 0 failed.*' <<<"$out" || true)"
|
||||
if [ -n "$line" ]; then ok "$2: ${line#ide-layout: }"; else fail "$2" "$(grep -E '^(FAIL|ide-layout:)' <<<"$out" | cut -c1-600 || true)
|
||||
$(tail -n 5 <<<"$out" | cut -c1-300)"; fi
|
||||
}
|
||||
report_headless() { # report_headless "name" "output"
|
||||
local line
|
||||
line="$(grep -o -E 'ide-headless: [0-9]+ passed, 0 failed.*' <<<"$2" || true)"
|
||||
if [ -n "$line" ]; then ok "$1: ${line#ide-headless: }"; else fail "$1" "$2"; fi
|
||||
if [ -n "$line" ]; then ok "$1: ${line#ide-headless: }"; else fail "$1" "$(cut -c1-600 <<<"$2")"; fi
|
||||
}
|
||||
startup_ms() { # the best of three starts, in milliseconds
|
||||
local home="$1" best="" ms i
|
||||
@@ -158,7 +168,7 @@ check "Neovim is pinned with a SHA-256 for each of the four platforms" \
|
||||
bash -c '[ "$(grep -c -E "^[0-9a-f]{64} nvim-(linux|macos)-(x86_64|arm64)\.tar\.gz$" ide/neovim.sha256)" = 4 ] && grep -q -E "^[0-9]+\.[0-9]+\.[0-9]+$" ide/neovim.version'
|
||||
check "nothing private in the tracked files" scripts/hygiene.sh
|
||||
check "the Lua of the configuration parses" \
|
||||
bash -c 'for f in ide/config/init.lua ide/config/colors/llembas.lua ide/config/lua/llembas_ide/*.lua ide/user-init.lua ide/tests/headless.lua; do "$0" --headless -u NONE -c "lua local f, e = loadfile([[$f]]); if not f then io.stdout:write(e) vim.cmd([[cquit 1]]) end" -c q || exit 1; done' "$SYSTEM_NVIM"
|
||||
bash -c 'for f in ide/config/init.lua ide/config/colors/llembas.lua ide/config/lua/llembas_ide/*.lua ide/user-init.lua ide/tests/headless.lua ide/tests/layout.lua ide/tests/typing.lua; do "$0" --headless -u NONE -c "lua local f, e = loadfile([[$f]]); if not f then io.stdout:write(e) vim.cmd([[cquit 1]]) end" -c q || exit 1; done' "$SYSTEM_NVIM"
|
||||
|
||||
# --- 2. a dry run ------------------------------------------------------------------------------
|
||||
echo "A dry run"
|
||||
@@ -216,6 +226,12 @@ expect "--version: Neovim" "$out" "Neovim $("$SYSTEM_NVIM" --version |
|
||||
expect "--version: the plugin" "$out" "LLeMbas plugin $VERSION"
|
||||
report_headless "headless start, from the inside" "$(headless "$A" 0 IDE_TEST_FIRST=1 || true)"
|
||||
typing "$A" "typing: the completion menu opens with the buffer's words, and <Tab> stays LLeMbas's"
|
||||
layout "$A" "the four bars at 160×45, 100×30 and 80×24, the keys, what is remembered, the terminal's user var"
|
||||
check "the plugin alone, in a Neovim without the distribution, loads and has no bars unless asked" \
|
||||
bash -c 'cd "$1" && env -i PATH="$PATH" HOME="$2" XDG_STATE_HOME="$2/plain-state" TERM=dumb "$3" --headless -u NONE -i NONE --cmd "set rtp+=nvim" \
|
||||
-c "runtime plugin/llembas.lua" \
|
||||
-c "lua require([[llembas]]).setup({}); assert(vim.o.tabline == [[]] and vim.fn.maparg([[<C-S-A>]], [[n]]) == [[]] and #vim.api.nvim_list_wins() == 1); require([[llembas]]).setup({ bars = true }); assert(vim.o.tabline:find([[llembas.layout]], 1, true) and vim.fn.maparg([[<C-S-A>]], [[n]], false, true).desc)" \
|
||||
-c "qa!" 2>&1 | { ! grep -q .; }' _ "$REPO" "$WORK" "$SYSTEM_NVIM"
|
||||
attempt as "$A" "$A/.local/bin/llembas-ide" doctor
|
||||
out="$OUT"
|
||||
passes "doctor finds the installation sound"
|
||||
@@ -361,6 +377,8 @@ passes "installs from the release, with the pinned Neovim downloaded and the gra
|
||||
check "it is the IDE's own copy" test -x "$B/.local/share/llembas-ide/nvim/bin/nvim"
|
||||
report_headless "headless start on the pinned Neovim with compiled grammars" "$(headless "$B" 1 IDE_TEST_FIRST=1 || true)"
|
||||
typing "$B" "typing on the pinned Neovim: the completion menu opens, and <Tab> stays LLeMbas's"
|
||||
layout "$B" "the four bars on the pinned Neovim"
|
||||
check "the plugin on its own passes its whole suite (scripts/test-nvim.sh)" scripts/test-nvim.sh
|
||||
attempt as "$B" "$B/.local/bin/llembas-ide" doctor
|
||||
out="$OUT"
|
||||
passes "doctor finds it sound"
|
||||
|
||||
Reference in new issue
Block a user