diff --git a/ide/README.md b/ide/README.md
new file mode 100644
index 0000000..4052160
--- /dev/null
+++ b/ide/README.md
@@ -0,0 +1,309 @@
+# LLeMbas IDE
+
+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
+`NVIM_APPNAME`, its own directories. A Neovim configuration of your own in `~/.config/nvim` is
+never read and never written.
+
+It works fully as an editor on its own. LLeMbas needs two more things: the
+[LLeMbas CLI](https://github.com/LLeMbas/LLeMbas-CLI), which the installer offers, and a sign-in
+to your LLeMbas server (`lembas login
`). No server, model or key is set anywhere in
+the IDE.
+
+## Install
+
+```sh
+curl -fsSL https://github.com/LLeMbas/LLeMbas-IDE/releases/latest/download/install.sh | bash
+```
+
+While LLeMbas IDE is in beta there is no stable release for that to find; ask for the betas:
+
+```sh
+curl -fsSL https://github.com/LLeMbas/LLeMbas-IDE/releases/download/v/install.sh | bash -s -- --channel beta
+```
+
+From a clone of this repository: `ide/install.sh --from-checkout`.
+
+Then start it with `llembas-ide` (any arguments go to Neovim: `llembas-ide src/main.c`).
+
+Linux on x86-64 and arm64. macOS is written for and has not been tried. It needs `bash`, `git`,
+`curl`, `tar` and `sha256sum`; nothing runs as root. Good to have: a C compiler (`cc`) for the
+Treesitter grammars, `rg` (ripgrep) for searching in files, a Nerd Font is not needed.
+
+| Option | What it does |
+|---|---|
+| `--version X` | install release X instead of the newest |
+| `--channel stable\|beta` | which releases "newest" looks at (default `stable`) |
+| `--prefix DIR` | where the IDE itself goes (default `~/.local/share/llembas-ide`) |
+| `--from-checkout` | install from the clone the script sits in |
+| `--nvim-bin PATH` | use a Neovim of your own (0.10 or newer) instead of the pinned release |
+| `--no-cli` | do not offer the LLeMbas CLI |
+| `--no-parsers` | do not compile the Treesitter grammars |
+| `--yes` | ask nothing |
+| `--dry-run` | print every action and do nothing |
+
+### What gets installed, and where
+
+| Where | What |
+|---|---|
+| `~/.local/share/llembas-ide/nvim/` | Neovim, the release pinned in [`neovim.version`](neovim.version); its SHA-256 is checked against [`neovim.sha256`](neovim.sha256) before it is unpacked |
+| `~/.local/share/llembas-ide/site/pack/llembas/` | the IDE's configuration, the third-party plugins, the compiled Treesitter grammars |
+| `~/.local/share/llembas-ide/lib/` | the LLeMbas plugin, the installer and the lock files (for `update`, `doctor` and `uninstall`) |
+| `~/.config/llembas-ide/init.lua` | starts the IDE; replaced by an update unless you edited it |
+| `~/.config/llembas-ide/lua/user/init.lua` | **yours**: created once with comments only, never overwritten |
+| `~/.local/bin/llembas-ide` | the launcher |
+| `~/.local/share/applications/llembas-ide.desktop`, `~/.local/share/icons/hicolor/256x256/apps/llembas-ide.png` | the menu entry (Linux) |
+
+Neovim keeps the IDE's history, undo files and sessions in `~/.local/state/llembas-ide/` and its
+cache in `~/.cache/llembas-ide/`. Nothing else is written. `XDG_DATA_HOME`, `XDG_CONFIG_HOME`,
+`XDG_STATE_HOME` and `XDG_CACHE_HOME` are honoured.
+
+Everything is built in a staging directory and started there once, headless, before it replaces
+what is installed. A failure at any point leaves the previous installation, or nothing, exactly
+as it was.
+
+### What it is made of
+
+The third-party plugins are five, each fetched with git at exactly the commit in
+[`plugins.lock`](plugins.lock) (the commit hash is the check), and the Treesitter grammars are
+compiled from the commits in [`parsers.lock`](parsers.lock). Names, sources, licences and pins:
+[`THIRD_PARTY.md`](THIRD_PARTY.md). All of it is MIT or Apache-2.0.
+
+There is no plugin manager. The plugins are plain Neovim packages (`:help packages`) that the
+installer places; the editor only loads what is there. So nothing is installed, fetched or
+updated when the IDE starts or while it runs, no plugin ever moves off its pinned commit on its
+own, and the IDE starts the same with or without a network. Plugins change when LLeMbas IDE
+does: a new version of the IDE carries new pins.
+
+- **Treesitter.** With a C compiler at install, 19 grammars are compiled (Bash, C, CSS, Go, HTML,
+ JavaScript, JSON, Lua, Markdown, Python, Rust, TOML, TSX, TypeScript, Vimscript, help, YAML and
+ two helpers). Without one, Neovim's own bundled grammars colour C, Lua, Markdown, Vimscript and
+ help, and every other language uses Neovim's regular syntax files; install a compiler and run
+ `llembas-ide update` to get them all.
+- **Language servers.** Neovim's built-in client starts the servers it finds on your `PATH`
+ (`:LLeMbasIdeLsp` lists the ones the IDE knows, which are found, and how each project says to
+ install its server). The IDE never downloads a language server or a formatter: there is no
+ installer for third-party programs in it.
+- **Formatting** happens when you ask (`cf`), with a formatter that is installed, or the
+ language server.
+
+## Keys
+
+The leader key is ``. Press it and wait: the next keys are shown. `:LLeMbasIdeKeys` (or
+`ik`) shows this list in the editor.
+
+The completion menu and LLeMbas's suggestions share insert mode and never want the same key:
+`` only ever accepts LLeMbas's grey suggestion; the menu is moved in with ``/``
+and taken with `` (the entry you moved to) or `` (the first one).
+
+
+**Typing**
+
+| Keys | In | What it does |
+|---|---|---|
+| `` | insert | Accept LLeMbas's suggestion (the grey text) |
+| `` | insert | Accept one word of it |
+| `` | insert | Ask for a suggestion now |
+| ` ` | insert | Move in the completion menu (also ) |
+| `` | insert | Take the menu entry you moved to; otherwise a new line |
+| `` | insert | Take the menu's first entry |
+| `` | insert | Close the menu |
+| `` | insert | Open the menu, or the entry's documentation |
+
+**Editing**
+
+| Keys | In | What it does |
+|---|---|---|
+| `gcc` | normal | Comment the line, on and off (gc with a motion or a selection) |
+| `sa sd sr` | normal | Surround: add (saiw"), delete (sd"), replace (sr"') |
+| `K` | normal | Documentation of the symbol under the cursor |
+| `gd gD gI gy` | normal | Definition, declaration, implementation, type (with a language server) |
+
+**Find**
+
+| Keys | In | What it does |
+|---|---|---|
+| `` | normal | Find a file |
+| `/` | normal | Search in files (needs rg) |
+| `,` | normal | Switch buffer |
+| `e` | normal | File explorer at this file |
+| `E` | normal | File explorer at the working directory |
+| `ff` | normal | Find a file |
+| `fg` | normal | Search in files (needs rg) |
+| `fw` | normal | Search the word under the cursor |
+| `fb` | normal | Open buffers |
+| `fr` | normal | Recent files |
+| `fs` | normal | Symbols in this file |
+| `fS` | normal | Symbols in the project |
+| `fR` | normal | References to the symbol under the cursor |
+| `fd` | normal | Problems in the project |
+| `fh` | normal | Help pages |
+| `fk` | normal | All key mappings |
+| `f.` | normal | The last search again |
+
+**Buffers**
+
+| Keys | In | What it does |
+|---|---|---|
+| `bd` | normal | Close the buffer, keep the window |
+| `bn` | normal | Next buffer |
+| `bp` | normal | Previous buffer |
+| `` | normal | Next buffer |
+| `` | normal | Previous buffer |
+| `w` | normal | Save |
+| `q` | normal | Close the window |
+| `` | normal | Clear the search highlight |
+
+**Code**
+
+| Keys | In | What it does |
+|---|---|---|
+| `ca` | normal | Code action |
+| `cr` | normal | Rename the symbol |
+| `cf` | normal, visual | Format the file or the selection |
+| `cd` | normal | The problem on this line |
+| `cl` | normal | Language servers: found, missing, how to install |
+
+**Problems**
+
+| Keys | In | What it does |
+|---|---|---|
+| `xx` | normal | Problems in this file, as a list |
+| `xw` | normal | Problems in the project, as a list |
+| `xn` | normal | Next problem |
+| `xp` | normal | Previous problem |
+
+**Git**
+
+| Keys | In | What it does |
+|---|---|---|
+| `gs` | normal | Changed files |
+| `gh` | normal | Changes, hunk by hunk |
+| `gd` | normal | This file beside its committed version |
+| `go` | normal | Show changes inline, on and off |
+| `ga` | normal | Stage the change under the cursor |
+| `gr` | normal | Undo the change under the cursor |
+| `gb` | normal | Who changed this line, and the commit |
+| `]g [g` | normal | Next and previous git change (]G [G: last and first) |
+
+**LLeMbas**
+
+| Keys | In | What it does |
+|---|---|---|
+| `ll` | normal | Chat panel, open and close |
+| `la` | normal, visual | Ask about the line or the selection (type the question) |
+| `le` | normal, visual | Have the line or the selection rewritten (type how) |
+| `lx` | normal, visual | Explain the line or the selection |
+| `lg` | normal | Generate code at the cursor (type what) |
+| `lf` | normal | Fix this file's problems |
+| `lt` | normal | Suggestions as you type, on and off |
+| `lm` | normal | Change the mode |
+| `lM` | normal | Change the model |
+| `ls` | normal | Earlier conversations |
+| `ln` | normal | New conversation |
+| `lc` | normal | Commands and skills |
+| `lS` | normal | Status |
+| `l.` | normal | Stop the running turn |
+| `li` | normal | Sign in |
+| `l?` | normal | The plugin's commands and keys |
+| `ga gr` | normal | Accept or reject LLeMbas's proposed change (gA gR: all; ]h [h: move) |
+
+**Session**
+
+| Keys | In | What it does |
+|---|---|---|
+| `sr` | normal | Restore this directory's session |
+| `sw` | normal | Save the session now |
+| `sd` | normal | Forget this directory's session |
+
+**Terminal**
+
+| Keys | In | What it does |
+|---|---|---|
+| `tt` | normal | Terminal, open and close |
+| `` | normal, terminal | Terminal, open and close |
+| `` | normal, terminal | The same, as some terminals send it |
+| `` | terminal | Leave the terminal's typing mode |
+
+**Look**
+
+| Keys | In | What it does |
+|---|---|---|
+| `ut` | normal | Dark and light theme |
+| `uw` | normal | Wrap long lines, on and off |
+| `un` | normal | Relative line numbers, on and off |
+
+**IDE**
+
+| Keys | In | What it does |
+|---|---|---|
+| `ih` | normal | Start screen |
+| `ik` | normal | This list of keys |
+| `id` | normal | Check the installation |
+| `iu` | normal | Open your own settings file |
+| `iv` | normal | Versions |
+
+
+`` and `` replace Neovim's "top and bottom of the window" motions, `s` belongs to
+surround, and `` in normal mode also clears the search highlight. Everything else of
+Neovim's is as it was.
+
+## Make it yours
+
+`~/.config/llembas-ide/lua/user/init.lua` (open it with `iu`) is loaded last, so what it
+sets wins: options, keys, the theme (`vim.o.background = "light"`, or another colourscheme
+altogether), the LLeMbas plugin's settings (`require("llembas").setup({ … })`, see
+`:help llembas-setup`), more language servers (`vim.lsp.enable("name")`).
+
+Your own plugins go in `~/.config/llembas-ide/pack/user/start//`: clone each there
+yourself and set it up in your file. The IDE loads them and never installs or updates them.
+
+The colourscheme `llembas` has two halves from LLeMbas's two themes: `moria` (dark, the default)
+and `shire` (light). `ut` switches.
+
+## Update, check, remove
+
+```sh
+llembas-ide update # the newest release over this one; your settings are kept
+llembas-ide doctor # what is installed, what is missing, what is off without it
+llembas-ide --version # the IDE, Neovim and the LLeMbas plugin
+llembas-ide uninstall # remove it; --purge also removes your settings
+```
+
+`update` runs the installed installer: it finds the newest release of the channel you are on (a
+beta stays with the betas), downloads it, checks it against the release's `SHA256SUMS`, and runs
+the installer inside it. Running `install.sh` again does the same. Plugins that did not change
+are kept as they are, so an update only fetches what is new.
+
+`uninstall` removes what the installer placed and the IDE's history and cache. It keeps your
+settings unless you say otherwise, and touches nothing else.
+
+## Privacy: what leaves the machine, and when
+
+- **Installing and updating** download Neovim and the plugins from GitHub, and the release from
+ this repository. That is all the network the IDE itself ever uses.
+- **Running the editor sends nothing.** No telemetry, no update check, nothing loaded from a
+ network at start or later. Opening, editing, searching and completing are local.
+- **LLeMbas features** talk to the LLeMbas CLI on your machine, which talks to the LLeMbas server
+ you signed in to, and to nothing else. That begins when you use one: open the chat, ask,
+ rewrite, or type with suggestions on. Suggestions as you type are on once the CLI is
+ installed and signed in, and send the text around the cursor to your server; `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.
+
+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.
+
+## For developers
+
+`scripts/test-ide.sh` checks all of this: the scripts with shellcheck, a dry run, real installs
+into a temporary home (with the pinned Neovim and with the oldest supported one), a headless
+start with the checks in [`tests/headless.lua`](tests/headless.lua), updating in place, and
+uninstalling. `scripts/gen-ide-theme.py` writes the colourscheme from the design tokens
+([`tokens.css`](tokens.css)); `scripts/package-ide.sh` writes the release files into `dist/`.
+
+The oldest Neovim the IDE runs on is 0.10. The one it installs is the pinned release.
diff --git a/ide/THIRD_PARTY.md b/ide/THIRD_PARTY.md
new file mode 100644
index 0000000..997d5c7
--- /dev/null
+++ b/ide/THIRD_PARTY.md
@@ -0,0 +1,57 @@
+# Third-party software in LLeMbas IDE
+
+LLeMbas IDE itself is MIT (see `LICENSE`). It does not carry the software below in its repository or
+its release: `install.sh` fetches each piece from its own home at exactly the version or commit
+named here and checks it (a SHA-256 for Neovim, the commit hash for everything fetched with git).
+Each keeps its own licence, which is in its directory after installation. Only permissively
+licensed software is used; each licence below was read in the project's own licence file at the
+pinned commit.
+
+## Neovim
+
+| Name | From | Licence | Pinned |
+|---|---|---|---|
+| Neovim | https://github.com/neovim/neovim/releases | Apache-2.0 (and the Vim licence for code from Vim) | release v0.12.7, SHA-256 per platform in `neovim.sha256` |
+
+## Plugins (`plugins.lock`)
+
+| Name | From | Licence | Pinned commit | What the IDE uses it for |
+|---|---|---|---|---|
+| mini.nvim (v0.18.0) | https://github.com/nvim-mini/mini.nvim | MIT | `1345d191bb3da9c7b0e977f4387c5761f9bff68d` | file explorer, fuzzy finder, key hints, statusline and tabline, git signs and hunks, surround, autopairs, sessions, buffer removal |
+| blink.cmp (v1.10.2) | https://github.com/Saghen/blink.cmp | MIT | `78336bc89ee5365633bcf754d93df01678b5c08f` | the completion menu (language server, paths, buffer words), with its Lua matcher: no binary is downloaded |
+| conform.nvim (v9.1.0) | https://github.com/stevearc/conform.nvim | MIT | `3543d000dafbc41cc7761d860cfdb24e82154f75` | format on demand with the formatters installed on the machine |
+| nvim-lspconfig (v2.13.0) | https://github.com/neovim/nvim-lspconfig | Apache-2.0 | `4648fd8ba5c678d7e2db75ae44ffac269bb589d8` | the start commands and root markers of language servers, for Neovim's built-in client |
+| nvim-treesitter (master) | https://github.com/nvim-treesitter/nvim-treesitter | Apache-2.0 | `cf12346a3414fa1b06af75c79faebe7f76df080a` | its highlight queries only, with the compiled grammars; its installer and commands are not loaded |
+
+## Treesitter grammars (`parsers.lock`)
+
+Compiled on the machine at install when a C compiler is there; the revisions are the ones
+nvim-treesitter's `lockfile.json` names at the commit above.
+
+| Language | From | Licence | Pinned commit |
+|---|---|---|---|
+| bash | https://github.com/tree-sitter/tree-sitter-bash | MIT | `0c46d792d54c536be5ff7eb18eb95c70fccdb232` |
+| c | https://github.com/tree-sitter/tree-sitter-c | MIT | `2a265d69a4caf57108a73ad2ed1e6922dd2f998c` |
+| css | https://github.com/tree-sitter/tree-sitter-css | MIT | `6e327db434fec0ee90f006697782e43ec855adf5` |
+| go | https://github.com/tree-sitter/tree-sitter-go | MIT | `5e73f476efafe5c768eda19bbe877f188ded6144` |
+| html | https://github.com/tree-sitter/tree-sitter-html | MIT | `cbb91a0ff3621245e890d1c50cc811bffb77a26b` |
+| javascript | https://github.com/tree-sitter/tree-sitter-javascript | MIT | `6fbef40512dcd9f0a61ce03a4c9ae7597b36ab5c` |
+| json | https://github.com/tree-sitter/tree-sitter-json | MIT | `46aa487b3ade14b7b05ef92507fdaa3915a662a3` |
+| lua | https://github.com/MunifTanjim/tree-sitter-lua | MIT | `db16e76558122e834ee214c8dc755b4a3edc82a9` |
+| markdown | https://github.com/MDeiml/tree-sitter-markdown (`tree-sitter-markdown/`) | MIT | `413285231ce8fa8b11e7074bbe265b48aa7277f9` |
+| markdown_inline | https://github.com/MDeiml/tree-sitter-markdown (`tree-sitter-markdown-inline/`) | MIT | `413285231ce8fa8b11e7074bbe265b48aa7277f9` |
+| python | https://github.com/tree-sitter/tree-sitter-python | MIT | `710796b8b877a970297106e5bbc8e2afa47f86ec` |
+| query | https://github.com/nvim-treesitter/tree-sitter-query | Apache-2.0 | `930202c2a80965a7a9ca018b5b2a08b25dfa7f12` |
+| rust | https://github.com/tree-sitter/tree-sitter-rust | MIT | `e86119bdb4968b9799f6a014ca2401c178d54b5f` |
+| toml | https://github.com/tree-sitter-grammars/tree-sitter-toml | MIT | `64b56832c2cffe41758f28e05c756a3a98d16f41` |
+| tsx | https://github.com/tree-sitter/tree-sitter-typescript (`tsx/`) | MIT | `75b3874edb2dc714fb1fd77a32013d0f8699989f` |
+| typescript | https://github.com/tree-sitter/tree-sitter-typescript (`typescript/`) | MIT | `75b3874edb2dc714fb1fd77a32013d0f8699989f` |
+| vim | https://github.com/neovim/tree-sitter-vim | MIT | `11b688a1f0e97c0c4e3dbabf4a38016335f4d237` |
+| vimdoc | https://github.com/neovim/tree-sitter-vimdoc | Apache-2.0 | `2694c3d27e2ca98a0ccde72f33887394300d524e` |
+| yaml | https://github.com/tree-sitter-grammars/tree-sitter-yaml | MIT | `1805917414a9a8ba2473717fd69447277a175fae` |
+
+## Not installed by the IDE
+
+The LLeMbas CLI is offered by the installer and installed by the CLI's own installer, which checks
+its release signature. Language servers and formatters are never installed: the IDE uses the ones
+already on the machine.
diff --git a/ide/assets/llembas-ide.png b/ide/assets/llembas-ide.png
new file mode 100644
index 0000000..8b22488
Binary files /dev/null and b/ide/assets/llembas-ide.png differ
diff --git a/ide/bin/llembas-ide b/ide/bin/llembas-ide
new file mode 100755
index 0000000..65e881b
--- /dev/null
+++ b/ide/bin/llembas-ide
@@ -0,0 +1,304 @@
+#!/usr/bin/env bash
+# LLeMbas IDE: the launcher. It starts the IDE's own Neovim with the IDE's own configuration
+# (NVIM_APPNAME=llembas-ide), so a Neovim configuration of your own is never read or written.
+#
+# llembas-ide [files…] start the editor; every argument goes to Neovim
+# llembas-ide --version the versions of the IDE, Neovim and the LLeMbas plugin
+# llembas-ide doctor check the installation, and say what is off without what
+# llembas-ide update install the newest release over this one (keeps your settings)
+# llembas-ide uninstall remove it (--purge: your settings too; --yes: ask nothing)
+#
+# A file named like one of those words is opened as ./doctor.
+set -euo pipefail
+
+PREFIX='' # set by install.sh
+APP="llembas-ide"
+
+say() { printf '%s\n' "$*"; }
+die() {
+ printf 'llembas-ide: %s\n' "$*" >&2
+ exit 1
+}
+
+[ -n "$PREFIX" ] || die "this launcher was not put in place by the installer (ide/install.sh)"
+case "$PREFIX" in /*/*) ;; *) die "the installation's directory ($PREFIX) is not one of the IDE's own" ;; esac
+CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/$APP"
+STATE="${XDG_STATE_HOME:-$HOME/.local/state}/$APP"
+CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/$APP"
+DATA="${XDG_DATA_HOME:-$HOME/.local/share}/$APP"
+LIB="$PREFIX/lib"
+# Before Neovim is run for anything: its own log and state go to the IDE's directories.
+export NVIM_APPNAME="$APP"
+
+recorded() { sed -n "s/^$1=//p" "$LIB/installed" 2>/dev/null | head -n1; }
+nvim_path() { cat "$LIB/nvim-path" 2>/dev/null || true; }
+sha256_of() {
+ if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi
+}
+has_tty() { [ -r /dev/tty ] && { : /dev/null; }
+git_quiet() { GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 git "$@"; }
+lock_lines() { grep -v -E '^[[:space:]]*(#|$)' "$1"; }
+
+# Remove a directory only when it is the IDE's own: its last part is the application's name.
+remove_app_dir() {
+ case "$1" in
+ */"$APP") rm -rf -- "$1" ;;
+ esac
+}
+
+versions() {
+ local nvim
+ nvim="$(nvim_path)"
+ say "LLeMbas IDE $(cat "$LIB/VERSION" 2>/dev/null || echo unknown)"
+ say "Neovim $("$nvim" --version 2>/dev/null | sed -n '1s/^NVIM v//p' || true)"
+ say "LLeMbas plugin $(cat "$LIB/llembas/VERSION" 2>/dev/null || echo missing)"
+}
+
+# --- doctor ------------------------------------------------------------------------------------
+
+BAD=0
+WARNED=0
+good() { printf ' ok %s\n' "$*"; }
+off() {
+ WARNED=$((WARNED + 1))
+ printf ' note %s\n' "$*"
+}
+bad() {
+ BAD=$((BAD + 1))
+ printf ' FAIL %s\n' "$*"
+}
+
+doctor() {
+ local nvim name where _url commit rest dir count have out lembas paths index
+ nvim="$(nvim_path)"
+ say "LLeMbas IDE $(cat "$LIB/VERSION" 2>/dev/null || echo '(version unknown)') in $PREFIX"
+ say ""
+ say "The editor"
+ if [ -n "$nvim" ] && "$nvim" --version >/dev/null 2>&1; then
+ good "Neovim $("$nvim" --version | sed -n '1s/^NVIM v//p') runs ($nvim; $(cut -d' ' -f1,2 "$LIB/nvim-source" 2>/dev/null))"
+ else
+ bad "Neovim does not run (${nvim:-no path recorded}); run the installer again"
+ fi
+ if [ -f "$CONFIG/init.lua" ]; then
+ if [ "$(sha256_of "$CONFIG/init.lua")" = "$(recorded init_sha)" ]; then
+ good "configuration $CONFIG/init.lua is the IDE's own"
+ else
+ off "$CONFIG/init.lua was edited; an update keeps yours and writes init.lua.new beside it"
+ fi
+ else
+ bad "$CONFIG/init.lua is missing; run the installer again"
+ fi
+ if [ -f "$CONFIG/lua/user/init.lua" ]; then
+ good "your settings: $CONFIG/lua/user/init.lua"
+ else
+ off "no settings file of your own ($CONFIG/lua/user/init.lua); the installer creates one"
+ fi
+
+ say ""
+ say "Plugins, each at its pinned commit"
+ if command -v git >/dev/null 2>&1 && [ -f "$LIB/ide/plugins.lock" ]; then
+ while read -r name where _url commit rest; do
+ dir="$PREFIX/site/pack/llembas/$where/$name"
+ if [ ! -d "$dir/.git" ]; then
+ bad "$name is missing"
+ elif [ "$(git_quiet -C "$dir" rev-parse HEAD 2>/dev/null)" != "$commit" ]; then
+ bad "$name is at $(git_quiet -C "$dir" rev-parse --short HEAD 2>/dev/null), not its pin ${commit:0:12}"
+ elif [ -n "$(git_quiet -C "$dir" status --porcelain --untracked-files=no 2>/dev/null)" ]; then
+ bad "$name is at its pin but its files were changed"
+ else
+ good "$name ${commit:0:12}"
+ fi
+ done < <(lock_lines "$LIB/ide/plugins.lock")
+ else
+ off "git is not installed: the plugins' commits cannot be checked, and git signs and diffs are off"
+ fi
+ if [ -f "$LIB/llembas/nvim/plugin/llembas.lua" ]; then
+ good "LLeMbas plugin $(cat "$LIB/llembas/VERSION")"
+ else
+ bad "the LLeMbas plugin is missing"
+ fi
+ count="$(lock_lines "$LIB/ide/parsers.lock" 2>/dev/null | wc -l | tr -d ' ' || true)"
+ have="$(find "$PREFIX/site/pack/llembas/start/llembas-parsers/parser" -name '*.so' 2>/dev/null | wc -l | tr -d ' ' || true)"
+ if [ "$have" = "$count" ] && [ "$count" != 0 ]; then
+ good "$have Treesitter grammars compiled"
+ else
+ off "Treesitter grammars are not compiled: Neovim's bundled ones colour C, Lua, Markdown, Vimscript and help; other languages use plain syntax files. With a C compiler installed, run: $APP update"
+ fi
+
+ say ""
+ say "A start, headless"
+ if [ -n "$nvim" ]; then
+ out="$(NVIM_APPNAME="$APP" LLEMBAS_IDE_PREFIX="$PREFIX" "$nvim" --headless \
+ --cmd 'lua vim.g.llembas_ide_no_session = true; vim.g.llembas_ide_no_dashboard = true' \
+ -c 'lua local ok, ide = pcall(require, "llembas_ide"); io.stdout:write(ok and ("problems=" .. #ide.problems .. " " .. table.concat(ide.problems, " | ")) or "problems=all the IDE did not load")' \
+ -c 'qa!' 2>&1 || true)"
+ if [ "$(printf '%s' "$out" | tr -d '[:space:]')" = "problems=0" ]; then
+ good "every part of the IDE loads"
+ else
+ bad "the IDE does not start cleanly: ${out#problems=}"
+ fi
+ fi
+
+ say ""
+ say "Tools the IDE uses when they are there"
+ if command -v git >/dev/null 2>&1; then good "git"; else off "git: no git signs, no diff, no update"; fi
+ if command -v rg >/dev/null 2>&1; then
+ good "rg (ripgrep)"
+ else
+ off "rg (ripgrep) is missing: searching in files (/) is off; finding files falls back to git or fd"
+ fi
+ if command -v fd >/dev/null 2>&1 || command -v fdfind >/dev/null 2>&1; then
+ good "fd"
+ else
+ off "fd is missing: nothing is off, rg or git lists the files"
+ fi
+ if command -v cc >/dev/null 2>&1 || command -v gcc >/dev/null 2>&1 || command -v clang >/dev/null 2>&1; then
+ good "a C compiler"
+ else
+ off "no C compiler: Treesitter grammars cannot be compiled at install"
+ fi
+ if command -v curl >/dev/null 2>&1; then good "curl"; else off "curl is missing: $APP update cannot download"; fi
+ if [ -n "${WAYLAND_DISPLAY:-}" ] && ! command -v wl-copy >/dev/null 2>&1; then
+ off "wl-clipboard is missing: the system clipboard is off"
+ fi
+ if [ -z "${WAYLAND_DISPLAY:-}" ] && [ -n "${DISPLAY:-}" ] && ! command -v xclip >/dev/null 2>&1 && ! command -v xsel >/dev/null 2>&1; then
+ off "xclip or xsel is missing: the system clipboard is off"
+ fi
+ case ":$PATH:" in *":$(dirname "$0"):"*) ;; *) off "$(dirname "$0") is not on your PATH" ;; esac
+
+ say ""
+ say "LLeMbas"
+ lembas="$(command -v lembas 2>/dev/null || true)"
+ if [ -z "$lembas" ]; then
+ off "the LLeMbas CLI (lembas) is not installed: chat, asking, rewriting and suggestions are off; the editor works. https://github.com/LLeMbas/LLeMbas-CLI"
+ else
+ good "LLeMbas CLI $("$lembas" --version 2>/dev/null || echo '(no version)') ($lembas)"
+ # Where the CLI keeps its sign-ins; it has no command that only says whether there is one.
+ paths="$("$lembas" __paths 2>/dev/null || true)"
+ index="$(printf '%s\n' "$paths" | sed -n 's/^config=//p')/lembas.json"
+ if [ -z "$paths" ]; then
+ off "could not tell whether the CLI is signed in; try: lembas login "
+ elif [ -f "$index" ] && grep -q '"base_url"' "$index"; then
+ good "signed in to a LLeMbas server"
+ else
+ off "not signed in: lembas login "
+ fi
+ fi
+
+ say ""
+ if [ "$BAD" -gt 0 ]; then
+ say "$BAD thing(s) are broken. Running the installer again repairs the installation: $APP update"
+ return 1
+ fi
+ if [ "$WARNED" -gt 0 ]; then
+ say "The installation is sound; $WARNED note(s) above say what is off."
+ else
+ say "The installation is sound."
+ fi
+}
+
+# --- update ------------------------------------------------------------------------------------
+
+update() {
+ local channel=stable args=()
+ [ -f "$LIB/ide/install.sh" ] || die "the installer is missing from $LIB; install again from https://github.com/LLeMbas/LLeMbas-IDE"
+ # A beta stays with the betas, a release with the releases; --channel says otherwise.
+ case "$(cat "$LIB/VERSION" 2>/dev/null)" in *-beta.*) channel=beta ;; esac
+ args=(--prefix "$PREFIX" --channel "$channel")
+ case "$(cat "$LIB/nvim-source" 2>/dev/null)" in own\ *) args+=(--nvim-bin "$(nvim_path)") ;; esac
+ # The installed installer finds the newest release, checks it, and runs the installer inside it.
+ exec bash "$LIB/ide/install.sh" "${args[@]}" "$@"
+}
+
+# --- uninstall ---------------------------------------------------------------------------------
+
+uninstall() {
+ local purge=0 yes=0 a answer launcher desktop icon keep_config=1
+ for a in "$@"; do
+ case "$a" in
+ --purge) purge=1 ;;
+ --yes | -y) yes=1 ;;
+ *) die "uninstall takes --purge and --yes" ;;
+ esac
+ done
+ launcher="$(recorded launcher)"
+ desktop="$(recorded desktop)"
+ icon="$(recorded icon)"
+ [ -n "$launcher" ] || launcher="$0"
+ say "This removes LLeMbas IDE:"
+ say " $PREFIX/nvim, $PREFIX/site/pack/llembas, $PREFIX/lib"
+ say " $launcher${desktop:+, $desktop, $icon}"
+ say " its history and cache ($STATE, $CACHE)"
+ if [ "$purge" = 1 ]; then say " and your own settings: $CONFIG"; else say "Your own settings in $CONFIG are kept."; fi
+ say "Nothing else is touched: not ~/.config/nvim, not the LLeMbas CLI."
+ if [ "$yes" != 1 ]; then
+ has_tty || die "no terminal to ask on; add --yes"
+ printf 'Remove it? [y/N] ' >/dev/tty
+ read -r answer /dev/tty
+ read -r answer /dev/null || true
+ rmdir "$PREFIX/site/pack" "$PREFIX/site" 2>/dev/null || true
+ # What Neovim itself left in its data directory goes with a purge; otherwise only if empty.
+ [ "$purge" != 1 ] || remove_app_dir "$DATA"
+ rmdir "$PREFIX" 2>/dev/null || true
+ rmdir "$DATA" 2>/dev/null || true
+ rm -f -- "$launcher"
+ if [ "$keep_config" = 1 ] && [ -d "$CONFIG" ]; then
+ say "LLeMbas IDE is removed. Your settings are still in $CONFIG."
+ else
+ say "LLeMbas IDE is removed."
+ fi
+}
+
+case "${1:-}" in
+ --version | -V)
+ versions
+ exit 0
+ ;;
+ doctor)
+ doctor
+ exit $?
+ ;;
+ update)
+ shift
+ update "$@"
+ ;;
+ uninstall)
+ shift
+ uninstall "$@"
+ exit 0
+ ;;
+ --launcher-help)
+ sed -n '2,/^set -euo/p' "$0" | sed -e '$d' -e 's/^# \{0,1\}//'
+ exit 0
+ ;;
+esac
+
+NVIM="$(nvim_path)"
+if [ -z "$NVIM" ] || [ ! -x "$NVIM" ]; then
+ die "the IDE's Neovim is missing (${NVIM:-no path recorded}); run the installer again"
+fi
+export NVIM_APPNAME="$APP" LLEMBAS_IDE_PREFIX="$PREFIX" LLEMBAS_IDE_LAUNCHER="$0"
+exec "$NVIM" "$@"
diff --git a/ide/config/colors/llembas.lua b/ide/config/colors/llembas.lua
new file mode 100644
index 0000000..3dd0246
--- /dev/null
+++ b/ide/config/colors/llembas.lua
@@ -0,0 +1,318 @@
+-- LLeMbas: the colourscheme of LLeMbas IDE. moria when 'background' is dark, shire when light.
+-- GENERATED by scripts/gen-ide-theme.py from the design tokens. Do not edit: change the tokens
+-- or the generator, and run it again. Your own colours belong in lua/user/init.lua.
+local palettes = {
+ dark = { -- moria
+ accent = "#8FD8E8",
+ accent_hover = "#B4E6F1",
+ accent_ink = "#061418",
+ accent_soft = "#1B252A",
+ add_bg = "#1D2F22",
+ bg = "#0B0D10",
+ bg_sunken = "#07090B",
+ border = "#26303A",
+ border_strong = "#5C6976",
+ change_bg = "#2B2317",
+ danger = "#F0735F",
+ danger_soft = "#291A1A",
+ delete_bg = "#301D1D",
+ ghost = "#636D76",
+ guide = "#1E252D",
+ ink = "#E2E8EC",
+ ink_faint = "#808D98",
+ ink_inverse = "#07090B",
+ ink_muted = "#A6B2BC",
+ leaf = "#7EE081",
+ leaf_hover = "#A2EAA3",
+ leaf_soft = "#19261E",
+ line = "#15191F",
+ match = "#503C1E",
+ selection = "#354E55",
+ success = "#5FD6B0",
+ success_soft = "#162725",
+ surface = "#11151A",
+ surface_active = "#232B34",
+ surface_hover = "#1D232B",
+ surface_raised = "#171C22",
+ text_bg = "#543F1F",
+ warning = "#F0A840",
+ warning_soft = "#292116",
+ },
+ light = { -- shire
+ accent = "#285F3C",
+ accent_hover = "#1F4D30",
+ accent_ink = "#F8F3E5",
+ accent_soft = "#DDDCC7",
+ add_bg = "#D4D6B8",
+ bg = "#F1EAD6",
+ bg_sunken = "#E7DEC6",
+ border = "#CBBF9D",
+ border_strong = "#2A2E22",
+ change_bg = "#E1D5B8",
+ danger = "#A3321F",
+ danger_soft = "#E9D8C4",
+ delete_bg = "#E5CDB9",
+ ghost = "#838472",
+ guide = "#D6CCAE",
+ ink = "#1F2418",
+ ink_faint = "#5E6250",
+ ink_inverse = "#F8F3E5",
+ ink_muted = "#474D3B",
+ leaf = "#3D6B1C",
+ leaf_hover = "#2F5615",
+ leaf_soft = "#DFDDC3",
+ line = "#EEE7D2",
+ match = "#CEBC96",
+ selection = "#C1C9B1",
+ success = "#2B6A55",
+ success_soft = "#DDDDC9",
+ surface = "#F8F3E5",
+ surface_active = "#E2D8BD",
+ surface_hover = "#ECE4CF",
+ surface_raised = "#FCF9F0",
+ text_bg = "#CCB992",
+ warning = "#7E5200",
+ warning_soft = "#E6DBC1",
+ },
+}
+
+local groups = {
+ ["Normal"] = { fg = "ink", bg = "bg" },
+ ["NormalNC"] = { fg = "ink", bg = "bg" },
+ ["NormalFloat"] = { fg = "ink", bg = "surface" },
+ ["FloatBorder"] = { fg = "border_strong", bg = "surface" },
+ ["FloatTitle"] = { fg = "leaf", bg = "surface", bold = true },
+ ["FloatFooter"] = { fg = "ink_faint", bg = "surface" },
+ ["Cursor"] = { fg = "bg", bg = "ink" },
+ ["CursorLine"] = { bg = "line" },
+ ["CursorColumn"] = { bg = "line" },
+ ["ColorColumn"] = { bg = "surface" },
+ ["LineNr"] = { fg = "ink_faint" },
+ ["CursorLineNr"] = { fg = "leaf", bg = "line", bold = true },
+ ["SignColumn"] = { fg = "ink_faint", bg = "bg" },
+ ["FoldColumn"] = { fg = "ink_faint", bg = "bg" },
+ ["Folded"] = { fg = "ink_muted", bg = "surface" },
+ ["WinSeparator"] = { fg = "border" },
+ ["VertSplit"] = { fg = "border" },
+ ["Visual"] = { bg = "selection" },
+ ["VisualNOS"] = { bg = "selection" },
+ ["Search"] = { fg = "ink", bg = "match" },
+ ["CurSearch"] = { fg = "ink_inverse", bg = "warning", bold = true },
+ ["IncSearch"] = { fg = "ink_inverse", bg = "warning", bold = true },
+ ["Substitute"] = { fg = "ink_inverse", bg = "danger" },
+ ["MatchParen"] = { fg = "accent", bg = "surface_active", bold = true },
+ ["NonText"] = { fg = "guide" },
+ ["Whitespace"] = { fg = "guide" },
+ ["SpecialKey"] = { fg = "guide" },
+ ["EndOfBuffer"] = { fg = "bg" },
+ ["Conceal"] = { fg = "ink_faint" },
+ ["Directory"] = { fg = "accent" },
+ ["Title"] = { fg = "leaf", bold = true },
+ ["ErrorMsg"] = { fg = "danger" },
+ ["WarningMsg"] = { fg = "warning" },
+ ["MoreMsg"] = { fg = "accent" },
+ ["ModeMsg"] = { fg = "ink_muted" },
+ ["Question"] = { fg = "accent" },
+ ["MsgArea"] = { fg = "ink" },
+ ["MsgSeparator"] = { fg = "border", bg = "bg" },
+ ["QuickFixLine"] = { bg = "surface_active", bold = true },
+ ["WildMenu"] = { fg = "accent_ink", bg = "accent" },
+ ["WinBar"] = { fg = "ink_muted", bg = "bg" },
+ ["WinBarNC"] = { fg = "ink_faint", bg = "bg" },
+ ["Pmenu"] = { fg = "ink", bg = "surface_raised" },
+ ["PmenuSel"] = { fg = "accent_ink", bg = "accent" },
+ ["PmenuKind"] = { fg = "ink_faint", bg = "surface_raised" },
+ ["PmenuExtra"] = { fg = "ink_faint", bg = "surface_raised" },
+ ["PmenuSbar"] = { bg = "surface_hover" },
+ ["PmenuThumb"] = { bg = "border_strong" },
+ ["PmenuMatch"] = { fg = "accent", bold = true },
+ ["PmenuMatchSel"] = { fg = "accent_ink", bold = true },
+ ["StatusLine"] = { fg = "ink", bg = "surface_raised" },
+ ["StatusLineNC"] = { fg = "ink_faint", bg = "surface" },
+ ["TabLine"] = { fg = "ink_muted", bg = "surface" },
+ ["TabLineSel"] = { fg = "ink", bg = "bg", bold = true },
+ ["TabLineFill"] = { bg = "bg_sunken" },
+ ["SpellBad"] = { undercurl = true, sp = "danger" },
+ ["SpellCap"] = { undercurl = true, sp = "warning" },
+ ["SpellRare"] = { undercurl = true, sp = "accent" },
+ ["SpellLocal"] = { undercurl = true, sp = "success" },
+ ["Comment"] = { fg = "ink_faint", italic = true },
+ ["Constant"] = { fg = "warning" },
+ ["String"] = { fg = "leaf" },
+ ["Character"] = { fg = "leaf" },
+ ["Number"] = { fg = "warning" },
+ ["Boolean"] = { fg = "warning" },
+ ["Float"] = { fg = "warning" },
+ ["Identifier"] = { fg = "ink" },
+ ["Function"] = { fg = "accent_hover" },
+ ["Statement"] = { fg = "accent" },
+ ["Conditional"] = { fg = "accent" },
+ ["Repeat"] = { fg = "accent" },
+ ["Label"] = { fg = "accent" },
+ ["Operator"] = { fg = "ink_muted" },
+ ["Keyword"] = { fg = "accent" },
+ ["Exception"] = { fg = "danger" },
+ ["PreProc"] = { fg = "success" },
+ ["Include"] = { fg = "accent" },
+ ["Define"] = { fg = "success" },
+ ["Macro"] = { fg = "success" },
+ ["Type"] = { fg = "success" },
+ ["StorageClass"] = { fg = "accent" },
+ ["Structure"] = { fg = "success" },
+ ["Typedef"] = { fg = "success" },
+ ["Special"] = { fg = "accent_hover" },
+ ["SpecialChar"] = { fg = "warning" },
+ ["Tag"] = { fg = "accent" },
+ ["Delimiter"] = { fg = "ink_muted" },
+ ["SpecialComment"] = { fg = "ink_muted", italic = true },
+ ["Debug"] = { fg = "danger" },
+ ["Underlined"] = { fg = "accent", underline = true },
+ ["Ignore"] = { fg = "ink_faint" },
+ ["Error"] = { fg = "danger" },
+ ["Todo"] = { fg = "ink_inverse", bg = "warning", bold = true },
+ ["Added"] = { fg = "leaf" },
+ ["Changed"] = { fg = "warning" },
+ ["Removed"] = { fg = "danger" },
+ ["DiffAdd"] = { bg = "add_bg" },
+ ["DiffChange"] = { bg = "change_bg" },
+ ["DiffDelete"] = { fg = "danger", bg = "delete_bg" },
+ ["DiffText"] = { bg = "text_bg", bold = true },
+ ["@variable"] = { fg = "ink" },
+ ["@variable.builtin"] = { fg = "danger" },
+ ["@variable.parameter"] = { fg = "ink", italic = true },
+ ["@variable.member"] = { fg = "ink_muted" },
+ ["@property"] = { fg = "ink_muted" },
+ ["@constant.builtin"] = { fg = "warning" },
+ ["@module"] = { fg = "ink" },
+ ["@constructor"] = { fg = "success" },
+ ["@punctuation"] = { fg = "ink_muted" },
+ ["@tag"] = { fg = "accent" },
+ ["@tag.attribute"] = { fg = "success" },
+ ["@tag.delimiter"] = { fg = "ink_faint" },
+ ["@markup.heading"] = { fg = "leaf", bold = true },
+ ["@markup.strong"] = { bold = true },
+ ["@markup.italic"] = { italic = true },
+ ["@markup.link"] = { fg = "accent", underline = true },
+ ["@markup.raw"] = { fg = "warning" },
+ ["@markup.list"] = { fg = "accent" },
+ ["@markup.quote"] = { fg = "ink_muted", italic = true },
+ ["LspReferenceText"] = { bg = "surface_active" },
+ ["LspReferenceRead"] = { bg = "surface_active" },
+ ["LspReferenceWrite"] = { bg = "surface_active" },
+ ["LspInlayHint"] = { fg = "ghost", italic = true },
+ ["LspSignatureActiveParameter"] = { fg = "warning", bold = true },
+ ["DiagnosticError"] = { fg = "danger" },
+ ["DiagnosticWarn"] = { fg = "warning" },
+ ["DiagnosticInfo"] = { fg = "accent" },
+ ["DiagnosticHint"] = { fg = "success" },
+ ["DiagnosticOk"] = { fg = "leaf" },
+ ["DiagnosticVirtualTextError"] = { fg = "danger", bg = "danger_soft" },
+ ["DiagnosticVirtualTextWarn"] = { fg = "warning", bg = "warning_soft" },
+ ["DiagnosticVirtualTextInfo"] = { fg = "accent", bg = "accent_soft" },
+ ["DiagnosticVirtualTextHint"] = { fg = "success", bg = "success_soft" },
+ ["DiagnosticUnderlineError"] = { undercurl = true, sp = "danger" },
+ ["DiagnosticUnderlineWarn"] = { undercurl = true, sp = "warning" },
+ ["DiagnosticUnderlineInfo"] = { undercurl = true, sp = "accent" },
+ ["DiagnosticUnderlineHint"] = { undercurl = true, sp = "success" },
+ ["DiagnosticUnnecessary"] = { fg = "ink_faint" },
+ ["MiniStatuslineModeNormal"] = { fg = "ink_inverse", bg = "leaf", bold = true },
+ ["MiniStatuslineModeInsert"] = { fg = "accent_ink", bg = "accent", bold = true },
+ ["MiniStatuslineModeVisual"] = { fg = "ink_inverse", bg = "warning", bold = true },
+ ["MiniStatuslineModeReplace"] = { fg = "ink_inverse", bg = "danger", bold = true },
+ ["MiniStatuslineModeCommand"] = { fg = "ink_inverse", bg = "success", bold = true },
+ ["MiniStatuslineModeOther"] = { fg = "ink_inverse", bg = "ink_muted", bold = true },
+ ["MiniStatuslineDevinfo"] = { fg = "ink_muted", bg = "surface_active" },
+ ["MiniStatuslineFilename"] = { fg = "ink", bg = "surface_raised" },
+ ["MiniStatuslineFileinfo"] = { fg = "ink_muted", bg = "surface_active" },
+ ["MiniStatuslineInactive"] = { fg = "ink_faint", bg = "surface" },
+ ["MiniTablineCurrent"] = { fg = "ink", bg = "bg", bold = true },
+ ["MiniTablineVisible"] = { fg = "ink_muted", bg = "surface" },
+ ["MiniTablineHidden"] = { fg = "ink_faint", bg = "bg_sunken" },
+ ["MiniTablineModifiedCurrent"] = { fg = "warning", bg = "bg", bold = true },
+ ["MiniTablineModifiedVisible"] = { fg = "warning", bg = "surface" },
+ ["MiniTablineModifiedHidden"] = { fg = "warning", bg = "bg_sunken" },
+ ["MiniTablineFill"] = { bg = "bg_sunken" },
+ ["MiniTablineTabpagesection"] = { fg = "ink_inverse", bg = "leaf", bold = true },
+ ["MiniTablineTrunc"] = { fg = "ink_faint", bg = "bg_sunken" },
+ ["MiniPickMatchCurrent"] = { bg = "surface_active", bold = true },
+ ["MiniPickMatchRanges"] = { fg = "accent", bold = true },
+ ["MiniPickPrompt"] = { fg = "leaf", bg = "surface", bold = true },
+ ["MiniPickBorderText"] = { fg = "leaf", bg = "surface" },
+ ["MiniFilesTitleFocused"] = { fg = "leaf", bg = "surface", bold = true },
+ ["MiniFilesDirectory"] = { fg = "accent" },
+ ["MiniFilesCursorLine"] = { bg = "surface_active" },
+ ["MiniClueNextKey"] = { fg = "leaf", bg = "surface", bold = true },
+ ["MiniClueNextKeyWithPostkeys"] = { fg = "warning", bg = "surface", bold = true },
+ ["MiniClueDescGroup"] = { fg = "accent", bg = "surface" },
+ ["MiniClueDescSingle"] = { fg = "ink", bg = "surface" },
+ ["MiniClueSeparator"] = { fg = "border_strong", bg = "surface" },
+ ["MiniClueTitle"] = { fg = "leaf", bg = "surface", bold = true },
+ ["MiniDiffSignAdd"] = { fg = "leaf" },
+ ["MiniDiffSignChange"] = { fg = "warning" },
+ ["MiniDiffSignDelete"] = { fg = "danger" },
+ ["MiniDiffOverAdd"] = { bg = "add_bg" },
+ ["MiniDiffOverChange"] = { bg = "text_bg" },
+ ["MiniDiffOverChangeBuf"] = { bg = "change_bg" },
+ ["MiniDiffOverContext"] = { bg = "change_bg" },
+ ["MiniDiffOverContextBuf"] = { },
+ ["MiniDiffOverDelete"] = { bg = "delete_bg" },
+ ["MiniIconsAzure"] = { fg = "accent" },
+ ["MiniIconsBlue"] = { fg = "accent" },
+ ["MiniIconsCyan"] = { fg = "success" },
+ ["MiniIconsGreen"] = { fg = "leaf" },
+ ["MiniIconsGrey"] = { fg = "ink_muted" },
+ ["MiniIconsOrange"] = { fg = "warning" },
+ ["MiniIconsPurple"] = { fg = "accent_hover" },
+ ["MiniIconsRed"] = { fg = "danger" },
+ ["MiniIconsYellow"] = { fg = "warning" },
+ ["BlinkCmpMenu"] = { fg = "ink", bg = "surface_raised" },
+ ["BlinkCmpMenuBorder"] = { fg = "border_strong", bg = "surface_raised" },
+ ["BlinkCmpMenuSelection"] = { fg = "accent_ink", bg = "accent" },
+ ["BlinkCmpLabelMatch"] = { fg = "accent", bold = true },
+ ["BlinkCmpKind"] = { fg = "ink_faint" },
+ ["BlinkCmpDoc"] = { fg = "ink", bg = "surface" },
+ ["BlinkCmpDocBorder"] = { fg = "border_strong", bg = "surface" },
+ ["LLeMbasBrand"] = { fg = "leaf", bold = true },
+ ["LLeMbasUserHeader"] = { fg = "accent", bold = true },
+ ["LLeMbasAgentHeader"] = { fg = "leaf", bold = true },
+ ["LLeMbasThought"] = { fg = "ink_faint", italic = true },
+ ["LLeMbasToolPending"] = { fg = "warning" },
+ ["LLeMbasToolDone"] = { fg = "success" },
+ ["LLeMbasToolFail"] = { fg = "danger" },
+ ["LLeMbasToolDenied"] = { fg = "danger", italic = true },
+ ["LLeMbasPlanHeader"] = { fg = "accent", bold = true },
+ ["LLeMbasDiffAdd"] = { bg = "add_bg" },
+ ["LLeMbasDiffDelete"] = { fg = "danger", bg = "delete_bg" },
+ ["LLeMbasDiffHint"] = { fg = "ink_faint", italic = true },
+ ["LLeMbasGhost"] = { fg = "ghost", italic = true },
+ ["LLeMbasSeparator"] = { fg = "border" },
+ ["LLeMbasIdeLeaf"] = { fg = "leaf" },
+ ["LLeMbasIdeSign"] = { fg = "accent" },
+ ["LLeMbasIdeTitle"] = { fg = "ink", bold = true },
+ ["LLeMbasIdeVersion"] = { fg = "ink_faint" },
+ ["LLeMbasIdeKey"] = { fg = "leaf", bold = true },
+ ["LLeMbasIdeAction"] = { fg = "ink" },
+ ["LLeMbasIdeMuted"] = { fg = "ink_faint" },
+ ["LLeMbasIdeNote"] = { fg = "ink_muted", italic = true },
+ ["LLeMbasIdeGood"] = { fg = "success" },
+ ["LLeMbasIdeWarn"] = { fg = "warning" },
+ ["LLeMbasIdeStatus"] = { fg = "leaf", bg = "surface_raised" },
+ ["LLeMbasIdeStatusOff"] = { fg = "ink_faint", bg = "surface_raised" },
+}
+
+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" }
+
+if vim.g.colors_name then vim.cmd("highlight clear") end
+vim.g.colors_name = "llembas"
+local p = palettes[vim.o.background == "light" and "light" or "dark"]
+for name, spec in pairs(groups) do
+ local hl = {}
+ for key, value in pairs(spec) do
+ if key == "fg" or key == "bg" or key == "sp" then hl[key] = p[value] else hl[key] = value end
+ end
+ vim.api.nvim_set_hl(0, name, hl)
+end
+for i, name in ipairs(terminal) do vim.g["terminal_color_" .. (i - 1)] = p[name] end
+
+-- For the configuration: the palette in use, by token name.
+return p
diff --git a/ide/config/init.lua b/ide/config/init.lua
new file mode 100644
index 0000000..83add69
--- /dev/null
+++ b/ide/config/init.lua
@@ -0,0 +1,20 @@
+-- LLeMbas IDE. This file starts the distribution and is replaced when the IDE is updated.
+-- Your own settings, keys and plugins belong in lua/user/init.lua beside it, which is loaded
+-- last and is never overwritten.
+local prefix = vim.env.LLEMBAS_IDE_PREFIX
+if not prefix or prefix == "" then prefix = vim.fn.stdpath("data") end
+local here = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
+if vim.fn.isdirectory(here .. "/lua/llembas_ide") == 0 then
+ -- Installed: the distribution and its pinned plugins are packages under the prefix.
+ vim.opt.packpath:prepend(prefix .. "/site")
+end
+local ok, ide = pcall(require, "llembas_ide")
+if not ok then
+ vim.api.nvim_echo({
+ { "LLeMbas IDE is not installed where this configuration expects it (" .. prefix .. ").\n", "WarningMsg" },
+ { "Run the installer again, or `llembas-ide doctor`. Neovim itself works.\n", "WarningMsg" },
+ { tostring(ide) .. "\n", "Comment" },
+ }, true, {})
+ return
+end
+ide.start({ prefix = prefix })
diff --git a/ide/config/lua/llembas_ide/bars.lua b/ide/config/lua/llembas_ide/bars.lua
new file mode 100644
index 0000000..b4be5ad
--- /dev/null
+++ b/ide/config/lua/llembas_ide/bars.lua
@@ -0,0 +1,35 @@
+-- The statusline and the line of open buffers.
+local M = {}
+
+local function active()
+ local s = require("mini.statusline")
+ local mode, mode_hl = s.section_mode({ trunc_width = 100 })
+ local git = s.section_git({ trunc_width = 60 })
+ local diff = s.section_diff({ trunc_width = 80 })
+ local diagnostics = s.section_diagnostics({ trunc_width = 80 })
+ local lsp = s.section_lsp({ trunc_width = 100 })
+ local filename = s.section_filename({ trunc_width = 140 })
+ local fileinfo = s.section_fileinfo({ trunc_width = 120 })
+ local llembas, live = require("llembas_ide.llembas").status()
+ if s.is_truncated(70) then llembas = "" end
+ return s.combine_groups({
+ { hl = mode_hl, strings = { mode } },
+ { hl = "MiniStatuslineDevinfo", strings = { git, diff, diagnostics, lsp } },
+ "%<",
+ { hl = "MiniStatuslineFilename", strings = { filename } },
+ "%=",
+ { hl = live and "LLeMbasIdeStatus" or "LLeMbasIdeStatusOff", strings = { (llembas:gsub("%%", "%%%%")) } },
+ { hl = "MiniStatuslineFileinfo", strings = { fileinfo } },
+ { hl = mode_hl, strings = { "%l:%v" } },
+ })
+end
+
+function M.setup()
+ require("mini.statusline").setup({
+ use_icons = false,
+ content = { active = active },
+ })
+ require("mini.tabline").setup({ show_icons = false })
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/brand.lua b/ide/config/lua/llembas_ide/brand.lua
new file mode 100644
index 0000000..ac93780
--- /dev/null
+++ b/ide/config/lua/llembas_ide/brand.lua
@@ -0,0 +1,20 @@
+-- The LLeMbas IDE mark as text: the mallorn leaf with the editor's angle brackets, drawn in
+-- half blocks from the product icon. Each row is { leaf, sign }: two colours, one picture.
+local M = {}
+
+M.name = "LLeMbas IDE"
+M.mark = {
+ { " ▄▄▄▄▄ ", "" },
+ { " ▄▄███████ ", "" },
+ { " ▄████████ ", "" },
+ { " ▄████████▀ ", "" },
+ { " ███████▀ ", "" },
+ { " ███▀▀▀ ", "" },
+ { " ▄▀ ", "▄▄ ▄▄ " },
+ { "▀ ", "▄█▀ ▀█▄" },
+ { " ", "▀█▄ ▄█▀ " },
+}
+-- The welcome line: the one place the road shows.
+M.welcome = "Waybread for the code ahead."
+
+return M
diff --git a/ide/config/lua/llembas_ide/commands.lua b/ide/config/lua/llembas_ide/commands.lua
new file mode 100644
index 0000000..1eb1ec8
--- /dev/null
+++ b/ide/config/lua/llembas_ide/commands.lua
@@ -0,0 +1,48 @@
+-- The IDE's own commands. All begin with :LLeMbasIde.
+local M = {}
+
+local function launcher()
+ local l = vim.env.LLEMBAS_IDE_LAUNCHER
+ if l and l ~= "" and vim.fn.executable(l) == 1 then return l end
+ if vim.fn.executable("llembas-ide") == 1 then return "llembas-ide" end
+ return nil
+end
+
+function M.versions()
+ local ide = require("llembas_ide")
+ local v = vim.version()
+ return {
+ ("LLeMbas IDE %s"):format(ide.version),
+ ("Neovim %d.%d.%d"):format(v.major, v.minor, v.patch),
+ ("LLeMbas plugin %s"):format(require("llembas_ide.llembas").version() or "not installed"),
+ }
+end
+
+function M.setup()
+ local cmd = vim.api.nvim_create_user_command
+ cmd("LLeMbasIdeKeys", function() require("llembas_ide.keys").show() end, { desc = "LLeMbas IDE: the keys" })
+ cmd("LLeMbasIdeHome", function() require("llembas_ide.dashboard").open() end, { desc = "LLeMbas IDE: the start screen" })
+ cmd("LLeMbasIdeLsp", function() require("llembas_ide.lsp").guide() end, { desc = "LLeMbas IDE: language servers, found and missing" })
+ cmd("LLeMbasIdeFormat", function() require("llembas_ide.plugins").format() end, { range = true, desc = "LLeMbas IDE: format the file or the selection" })
+ cmd("LLeMbasIdeTerminal", function() require("llembas_ide.terminal").toggle() end, { desc = "LLeMbas IDE: the terminal, open and close" })
+ cmd("LLeMbasIdeDiff", function() require("llembas_ide.git").diff_head() end, { desc = "LLeMbas IDE: this file beside its committed version" })
+ cmd("LLeMbasIdeSignIn", function() require("llembas_ide.llembas").sign_in() end, { desc = "LLeMbas IDE: sign in to LLeMbas" })
+ cmd("LLeMbasIdeVersion", function() vim.notify(table.concat(M.versions(), "\n")) end, { desc = "LLeMbas IDE: versions" })
+ cmd("LLeMbasIdeConfig", function()
+ vim.cmd.edit(vim.fn.fnameescape(vim.fn.stdpath("config") .. "/lua/user/init.lua"))
+ end, { desc = "LLeMbas IDE: open your own settings file" })
+ cmd("LLeMbasIdeProblems", function()
+ local p = require("llembas_ide").problems
+ local lines = #p == 0 and { "Every part of the IDE started." } or vim.list_extend({ "These parts did not start:", "" }, p)
+ require("llembas_ide.ui").page("LLeMbas IDE: problems", lines)
+ end, { desc = "LLeMbas IDE: what did not start" })
+ cmd("LLeMbasIdeDoctor", function()
+ local l = launcher()
+ if not l then
+ return vim.notify("The llembas-ide command is not on PATH; run `llembas-ide doctor` from where it was installed (~/.local/bin).", vim.log.levels.WARN)
+ end
+ require("llembas_ide.terminal").run({ l, "doctor" })
+ end, { desc = "LLeMbas IDE: check the installation" })
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/completion.lua b/ide/config/lua/llembas_ide/completion.lua
new file mode 100644
index 0000000..65c4349
--- /dev/null
+++ b/ide/config/lua/llembas_ide/completion.lua
@@ -0,0 +1,43 @@
+-- The completion menu: language server, paths and words of the open buffers.
+--
+-- It shares insert mode with LLeMbas's suggestions (the grey text ahead of the cursor), and the
+-- two never want the same key:
+-- accepts LLeMbas's suggestion ( one word of it). Never the menu.
+-- or move in the menu; nothing in it is chosen until you do.
+-- takes the menu entry you moved to; with none chosen it is a plain Enter.
+-- takes the first entry without moving.
+-- closes the menu. opens it, or shows the entry's documentation.
+local M = {}
+
+function M.setup()
+ require("blink.cmp").setup({
+ keymap = {
+ preset = "none",
+ [""] = { "show", "show_documentation", "hide_documentation" },
+ [""] = { "hide", "fallback" },
+ [""] = { "select_and_accept", "fallback" },
+ [""] = { "accept", "fallback" },
+ [""] = { "select_next", "fallback_to_mappings" },
+ [""] = { "select_prev", "fallback_to_mappings" },
+ [""] = { "select_next", "fallback" },
+ [""] = { "select_prev", "fallback" },
+ [""] = { "scroll_documentation_down", "fallback" },
+ [""] = { "scroll_documentation_up", "fallback" },
+ },
+ completion = {
+ list = { selection = { preselect = false, auto_insert = false } },
+ ghost_text = { enabled = false }, -- the grey text is LLeMbas's
+ documentation = { auto_show = true, auto_show_delay_ms = 400, window = { border = "rounded" } },
+ menu = {
+ border = "rounded",
+ draw = { columns = { { "label", "label_description", gap = 1 }, { "kind" } } }, -- kinds in words: no icon font needed
+ },
+ },
+ sources = { default = { "lsp", "path", "buffer" } },
+ cmdline = { enabled = false }, -- the command line keeps Neovim's own completion
+ -- The matcher written in Lua: the compiled one would be a binary downloaded at run time.
+ fuzzy = { implementation = "lua", prebuilt_binaries = { download = false } },
+ })
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/dashboard.lua b/ide/config/lua/llembas_ide/dashboard.lua
new file mode 100644
index 0000000..7058198
--- /dev/null
+++ b/ide/config/lua/llembas_ide/dashboard.lua
@@ -0,0 +1,155 @@
+-- The start screen: the mark, the name and version, and what to do next, one key each.
+-- Shown when the IDE starts without a file; ih brings it back.
+local M = {}
+
+local ns = vim.api.nvim_create_namespace("llembas_ide_dashboard")
+
+local function act(fn) return function() vim.schedule(fn) end end
+
+-- { key, what it does, action }
+M.actions = {
+ { "n", "New file", function() vim.cmd.enew() end },
+ { "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 },
+ { "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 },
+ { "q", "Quit", function() vim.cmd("confirm qall") end },
+}
+
+local function first_run()
+ local marker = vim.fn.stdpath("state") .. "/welcomed"
+ if vim.fn.filereadable(marker) == 1 then return false end
+ vim.fn.mkdir(vim.fn.stdpath("state"), "p")
+ pcall(vim.fn.writefile, { os.date("%Y-%m-%d") }, marker)
+ return true
+end
+
+-- The block: the mark, the name and the actions share one column of a known width, so the keys
+-- line up by construction. Notes are short lines centred on their own.
+local ACTION_WIDTH = 38
+
+--- The screen's rows: { text, { {from, to, group}, … }, in_block }.
+function M.content(welcome)
+ local ide, brand = require("llembas_ide"), require("llembas_ide.brand")
+ local llembas = require("llembas_ide.llembas")
+ local rows = {}
+ local function row(text, marks, in_block) table.insert(rows, { text, marks or {}, in_block == true }) end
+ local function inside(text) -- centred within the block's own width
+ return string.rep(" ", math.max(0, math.floor((ACTION_WIDTH - vim.fn.strdisplaywidth(text)) / 2)))
+ end
+ local function note(text, group) row(text, { { 0, -1, group or "LLeMbasIdeMuted" } }) end
+
+ for _, pair in ipairs(brand.mark) do
+ local pad = inside(brand.mark[1][1])
+ row(pad .. pair[1] .. pair[2], {
+ { #pad, #pad + #pair[1], "LLeMbasIdeLeaf" },
+ { #pad + #pair[1], #pad + #pair[1] + #pair[2], "LLeMbasIdeSign" },
+ }, true)
+ end
+ row("")
+ local title = brand.name .. " " .. ide.version
+ local pad = inside(title)
+ row(pad .. title, { { #pad, #pad + #brand.name, "LLeMbasIdeTitle" }, { #pad + #brand.name, #pad + #title, "LLeMbasIdeVersion" } }, true)
+ pad = inside(brand.welcome)
+ row(pad .. brand.welcome, { { #pad, -1, "LLeMbasIdeNote" } }, true)
+ row("")
+ for _, a in ipairs(M.actions) do
+ local text = ("%s %-" .. (ACTION_WIDTH - 4) .. "s"):format(a[1], a[2])
+ row(text, { { 0, 1, "LLeMbasIdeKey" }, { 1, #text, "LLeMbasIdeAction" } }, true)
+ end
+ row("")
+ if not llembas.loaded then
+ note("The LLeMbas plugin is missing. The editor works.")
+ note("Press d to check the installation.")
+ elseif not llembas.has_cli() then
+ note("The LLeMbas CLI is not installed.")
+ note("The editor works without it. Press i.")
+ else
+ note("LLeMbas needs a server and a sign-in: press i.")
+ note("The editor works without them.")
+ end
+ if welcome then
+ row("")
+ note("Welcome. is the leader key:")
+ note("press it and wait to see what follows.")
+ note("Your own settings: iu")
+ note("Nothing leaves this machine until you use LLeMbas.")
+ end
+ if #ide.problems > 0 then
+ row("")
+ note(#ide.problems .. " part(s) did not start: :LLeMbasIdeProblems", "LLeMbasIdeWarn")
+ end
+ return rows
+end
+
+local function draw(buf, win, welcome)
+ local rows = M.content(welcome)
+ local width, height = vim.api.nvim_win_get_width(win), vim.api.nvim_win_get_height(win)
+ local block_pad = math.max(0, math.floor((width - ACTION_WIDTH) / 2))
+ local pad_top = math.max(0, math.floor((height - #rows) / 2))
+ local lines, pads = {}, {}
+ for _ = 1, pad_top do table.insert(lines, "") end
+ for i, r in ipairs(rows) do
+ pads[i] = r[3] and block_pad or math.max(0, math.floor((width - vim.fn.strdisplaywidth(r[1])) / 2))
+ table.insert(lines, r[1] == "" and "" or string.rep(" ", pads[i]) .. r[1])
+ end
+ vim.bo[buf].modifiable = true
+ vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
+ vim.bo[buf].modifiable = false
+ vim.bo[buf].modified = false
+ vim.api.nvim_buf_clear_namespace(buf, ns, 0, -1)
+ for i, r in ipairs(rows) do
+ for _, m in ipairs(r[2]) do
+ vim.api.nvim_buf_add_highlight(buf, ns, m[3], pad_top + i - 1, pads[i] + m[1], m[2] == -1 and -1 or pads[i] + m[2])
+ end
+ end
+end
+
+function M.open(welcome)
+ local buf = vim.api.nvim_create_buf(false, true)
+ vim.bo[buf].bufhidden = "wipe"
+ vim.bo[buf].buftype = "nofile"
+ vim.bo[buf].swapfile = false
+ vim.bo[buf].filetype = "llembas-ide-dashboard"
+ vim.api.nvim_set_current_buf(buf)
+ local win = vim.api.nvim_get_current_win()
+ for opt, value in pairs({ number = false, relativenumber = false, cursorline = false, signcolumn = "no", list = false, wrap = false }) do
+ vim.api.nvim_set_option_value(opt, value, { scope = "local", win = win })
+ end
+ draw(buf, win, welcome == true)
+ for _, a in ipairs(M.actions) do
+ 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", {
+ group = group,
+ callback = function()
+ local w = vim.fn.bufwinid(buf)
+ if w ~= -1 then draw(buf, w, welcome == true) end
+ end,
+ })
+ vim.api.nvim_create_autocmd("BufWipeout", {
+ group = group, buffer = buf,
+ callback = function() pcall(vim.api.nvim_del_augroup_by_id, group) end,
+ })
+ return buf
+end
+
+function M.setup()
+ vim.api.nvim_create_autocmd("VimEnter", {
+ group = vim.api.nvim_create_augroup("llembas_ide_dashboard", { clear = true }),
+ once = true,
+ callback = function()
+ -- Only on an empty start: no file named, nothing piped in, nothing typed into the buffer.
+ if vim.fn.argc() > 0 or vim.g.llembas_ide_no_dashboard then return end
+ if vim.api.nvim_buf_get_name(0) ~= "" or vim.bo.modified or vim.bo.filetype ~= "" then return end
+ if vim.api.nvim_buf_line_count(0) > 1 or vim.api.nvim_buf_get_lines(0, 0, 1, false)[1] ~= "" then return end
+ M.open(first_run())
+ end,
+ })
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/git.lua b/ide/config/lua/llembas_ide/git.lua
new file mode 100644
index 0000000..1e6b302
--- /dev/null
+++ b/ide/config/lua/llembas_ide/git.lua
@@ -0,0 +1,46 @@
+-- The file beside its committed version, as a two-window diff.
+local M = {}
+
+function M.diff_head()
+ local file = vim.api.nvim_buf_get_name(0)
+ if file == "" or vim.bo.buftype ~= "" then return vim.notify("Diff: this buffer is not a file", vim.log.levels.INFO) end
+ if vim.fn.executable("git") == 0 then return vim.notify("Diff: git is not installed", vim.log.levels.WARN) end
+ local dir = vim.fn.fnamemodify(file, ":h")
+ local rel = vim.fn.systemlist({ "git", "-C", dir, "ls-files", "--full-name", "--", file })[1]
+ if vim.v.shell_error ~= 0 or not rel or rel == "" then
+ return vim.notify("Diff: this file is not tracked by git", vim.log.levels.INFO)
+ end
+ local old = vim.fn.systemlist({ "git", "-C", dir, "show", "HEAD:" .. rel })
+ if vim.v.shell_error ~= 0 then return vim.notify("Diff: no committed version of this file yet", vim.log.levels.INFO) end
+
+ local ft, win = vim.bo.filetype, vim.api.nvim_get_current_win()
+ vim.cmd("leftabove vnew")
+ local buf = vim.api.nvim_get_current_buf()
+ vim.api.nvim_buf_set_lines(buf, 0, -1, false, old)
+ vim.bo[buf].buftype = "nofile"
+ vim.bo[buf].bufhidden = "wipe"
+ vim.bo[buf].swapfile = false
+ vim.bo[buf].modifiable = false
+ vim.bo[buf].filetype = ft
+ pcall(vim.api.nvim_buf_set_name, buf, "HEAD:" .. rel)
+ vim.cmd.diffthis()
+ vim.api.nvim_set_current_win(win)
+ vim.cmd.diffthis()
+ local function close()
+ if vim.api.nvim_buf_is_valid(buf) then vim.api.nvim_buf_delete(buf, { force = true }) end
+ if vim.api.nvim_win_is_valid(win) then vim.api.nvim_win_call(win, function() vim.cmd.diffoff() end) end
+ end
+ vim.keymap.set("n", "q", close, { buffer = buf, nowait = true, desc = "Close the diff" })
+end
+
+local function hunk_at_cursor(action)
+ local ok, diff = pcall(require, "mini.diff")
+ if not ok then return end
+ local line = vim.api.nvim_win_get_cursor(0)[1]
+ pcall(diff.do_hunks, 0, action, { line_start = line, line_end = line })
+end
+
+function M.stage_hunk() hunk_at_cursor("apply") end
+function M.reset_hunk() hunk_at_cursor("reset") end
+
+return M
diff --git a/ide/config/lua/llembas_ide/init.lua b/ide/config/lua/llembas_ide/init.lua
new file mode 100644
index 0000000..0c9b99e
--- /dev/null
+++ b/ide/config/lua/llembas_ide/init.lua
@@ -0,0 +1,71 @@
+-- LLeMbas IDE: a complete Neovim, with LLeMbas built in. Everything here works from what the
+-- installer placed: nothing is fetched, installed or updated when the editor starts.
+local M = {}
+
+M.name = "LLeMbas IDE"
+M.problems = {} -- what could not be set up, in words; the dashboard and :LLeMbasIdeDoctor show it
+M.prefix = nil
+M.version = "dev"
+
+--- Run one part of the setup; a part that fails is named, and the editor still starts.
+function M.try(what, fn)
+ local ok, err = xpcall(fn, debug.traceback)
+ if not ok then table.insert(M.problems, what .. ": " .. tostring(err):gsub("\n.*", "")) end
+ return ok
+end
+
+local function read_first_line(path)
+ local f = io.open(path, "r")
+ if not f then return nil end
+ local line = f:read("*l")
+ f:close()
+ return line and vim.trim(line) or nil
+end
+
+--- Whether a plugin the installer places is there: a module that `require` can find.
+function M.has(module)
+ return #vim.api.nvim_get_runtime_file("lua/" .. module:gsub("%.", "/") .. ".lua", false) > 0
+ or #vim.api.nvim_get_runtime_file("lua/" .. module:gsub("%.", "/") .. "/init.lua", false) > 0
+end
+
+function M.start(opts)
+ if M.started then return end
+ M.started = true
+ M.prefix = opts and opts.prefix or vim.fn.stdpath("data")
+ local here = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
+ M.version = read_first_line(M.prefix .. "/lib/VERSION")
+ or read_first_line(vim.fn.fnamemodify(here, ":h:h:h:h") .. "/VERSION") -- a checkout
+ or "dev"
+
+ -- The LLeMbas plugin sits beside its VERSION file, as it does in its repository.
+ local plugin = M.prefix .. "/lib/llembas/nvim"
+ if vim.fn.isdirectory(plugin) == 0 then plugin = vim.fn.fnamemodify(here, ":h:h:h:h") .. "/nvim" end
+ if vim.fn.isdirectory(plugin) == 1 then vim.opt.runtimepath:prepend(plugin) end
+
+ M.try("options", function() require("llembas_ide.options").setup() end)
+ M.try("theme", function() vim.cmd.colorscheme("llembas") end)
+ M.try("plugins", function() require("llembas_ide.plugins").setup() end)
+ M.try("treesitter", function() require("llembas_ide.treesitter").setup() end)
+ M.try("completion", function() require("llembas_ide.completion").setup() end)
+ M.try("lsp", function() require("llembas_ide.lsp").setup() end)
+ M.try("llembas", function() require("llembas_ide.llembas").setup() end)
+ M.try("bars", function() require("llembas_ide.bars").setup() end)
+ M.try("sessions", function() require("llembas_ide.sessions").setup() end)
+ M.try("keys", function() require("llembas_ide.keys").setup() end)
+ M.try("commands", function() require("llembas_ide.commands").setup() end)
+ M.try("dashboard", function() require("llembas_ide.dashboard").setup() end)
+
+ -- The person's own file, last: it may change anything above.
+ local user = vim.fn.stdpath("config") .. "/lua/user/init.lua"
+ if vim.fn.filereadable(user) == 1 then
+ M.try("your lua/user/init.lua", function() dofile(user) end)
+ end
+
+ if #M.problems > 0 then
+ vim.schedule(function()
+ vim.notify("LLeMbas IDE: " .. #M.problems .. " part(s) did not start. :LLeMbasIdeProblems lists them.", vim.log.levels.WARN)
+ end)
+ end
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/keys.lua b/ide/config/lua/llembas_ide/keys.lua
new file mode 100644
index 0000000..282e22c
--- /dev/null
+++ b/ide/config/lua/llembas_ide/keys.lua
@@ -0,0 +1,222 @@
+-- Every key the IDE adds, in one table: the mappings, the hints that appear after , the
+-- cheat sheet (:LLeMbasIdeKeys) and the table in the README are all made from it.
+-- The leader is . Neovim's own keys are unchanged unless listed here.
+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
+ if count > 0 then vim.diagnostic.goto_next() else vim.diagnostic.goto_prev() end -- Neovim 0.10
+ end
+end
+local function mod(module, fn) return function(...) return require(module)[fn](...) end end
+
+M.groups = {
+ { "f", "find" },
+ { "b", "buffer" },
+ { "c", "code" },
+ { "g", "git" },
+ { "l", "LLeMbas" },
+ { "s", "session" },
+ { "t", "terminal" },
+ { "u", "look" },
+ { "x", "problems" },
+ { "i", "IDE" },
+}
+
+-- { modes, keys, action, what it does, section }
+M.map = {
+ -- Files and search
+ { "n", "", pick("files"), "Find a file", "Find" },
+ { "n", "/", pick("grep_live"), "Search in files (needs rg)", "Find" },
+ { "n", ",", pick("buffers"), "Switch buffer", "Find" },
+ { "n", "e", function() require("mini.files").open(vim.api.nvim_buf_get_name(0)) end, "File explorer at this file", "Find" },
+ { "n", "E", function() require("mini.files").open(vim.fn.getcwd()) end, "File explorer at the working directory", "Find" },
+ { "n", "ff", pick("files"), "Find a file", "Find" },
+ { "n", "fg", pick("grep_live"), "Search in files (needs rg)", "Find" },
+ { "n", "fw", function() require("mini.pick").builtin.grep({ pattern = vim.fn.expand("") }) end, "Search the word under the cursor", "Find" },
+ { "n", "fb", pick("buffers"), "Open buffers", "Find" },
+ { "n", "fr", extra("oldfiles"), "Recent files", "Find" },
+ { "n", "fs", extra("lsp", { scope = "document_symbol" }), "Symbols in this file", "Find" },
+ { "n", "fS", extra("lsp", { scope = "workspace_symbol" }), "Symbols in the project", "Find" },
+ { "n", "fR", extra("lsp", { scope = "references" }), "References to the symbol under the cursor", "Find" },
+ { "n", "fd", extra("diagnostic", { scope = "all" }), "Problems in the project", "Find" },
+ { "n", "fh", pick("help"), "Help pages", "Find" },
+ { "n", "fk", extra("keymaps"), "All key mappings", "Find" },
+ { "n", "f.", pick("resume"), "The last search again", "Find" },
+ -- Buffers and windows
+ { "n", "bd", function() require("mini.bufremove").delete() end, "Close the buffer, keep the window", "Buffers" },
+ { "n", "bn", "bnext", "Next buffer", "Buffers" },
+ { "n", "bp", "bprevious", "Previous buffer", "Buffers" },
+ { "n", "", "bnext", "Next buffer", "Buffers" },
+ { "n", "", "bprevious", "Previous buffer", "Buffers" },
+ { "n", "w", "write", "Save", "Buffers" },
+ { "n", "q", "quit", "Close the window", "Buffers" },
+ { "n", "", "nohlsearch", "Clear the search highlight", "Buffers" },
+ -- Code
+ { "n", "ca", function() vim.lsp.buf.code_action() end, "Code action", "Code" },
+ { "n", "cr", function() vim.lsp.buf.rename() end, "Rename the symbol", "Code" },
+ { { "n", "x" }, "cf", mod("llembas_ide.plugins", "format"), "Format the file or the selection", "Code" },
+ { "n", "cd", function() vim.diagnostic.open_float() end, "The problem on this line", "Code" },
+ { "n", "cl", mod("llembas_ide.lsp", "guide"), "Language servers: found, missing, how to install", "Code" },
+ -- Problems
+ { "n", "xx", function() vim.diagnostic.setloclist() end, "Problems in this file, as a list", "Problems" },
+ { "n", "xw", function() vim.diagnostic.setqflist() end, "Problems in the project, as a list", "Problems" },
+ { "n", "xn", problem(1), "Next problem", "Problems" },
+ { "n", "xp", problem(-1), "Previous problem", "Problems" },
+ -- Git
+ { "n", "gs", extra("git_files", { scope = "modified" }), "Changed files", "Git" },
+ { "n", "gh", extra("git_hunks"), "Changes, hunk by hunk", "Git" },
+ { "n", "gd", mod("llembas_ide.git", "diff_head"), "This file beside its committed version", "Git" },
+ { "n", "go", function() require("mini.diff").toggle_overlay(0) end, "Show changes inline, on and off", "Git" },
+ { "n", "ga", mod("llembas_ide.git", "stage_hunk"), "Stage the change under the cursor", "Git" },
+ { "n", "gr", mod("llembas_ide.git", "reset_hunk"), "Undo the change under the cursor", "Git" },
+ { "n", "gb", function() require("mini.git").show_at_cursor() end, "Who changed this line, and the commit", "Git" },
+ -- LLeMbas
+ { "n", "ll", ll("LLeMbas"), "Chat panel, open and close", "LLeMbas" },
+ { { "n", "x" }, "la", ":LLeMbasAsk ", "Ask about the line or the selection (type the question)", "LLeMbas" },
+ { { "n", "x" }, "le", ":LLeMbasEdit ", "Have the line or the selection rewritten (type how)", "LLeMbas" },
+ { { "n", "x" }, "lx", ":LLeMbasExplain", "Explain the line or the selection", "LLeMbas" },
+ { "n", "lg", ":LLeMbasGenerate ", "Generate code at the cursor (type what)", "LLeMbas" },
+ { "n", "lf", ll("LLeMbasFix"), "Fix this file's problems", "LLeMbas" },
+ { "n", "lt", mod("llembas_ide.llembas", "toggle_autocomplete"), "Suggestions as you type, on and off", "LLeMbas" },
+ { "n", "lm", ll("LLeMbasMode"), "Change the mode", "LLeMbas" },
+ { "n", "lM", ll("LLeMbasModel"), "Change the model", "LLeMbas" },
+ { "n", "ls", ll("LLeMbasSessions"), "Earlier conversations", "LLeMbas" },
+ { "n", "ln", ll("LLeMbasNew"), "New conversation", "LLeMbas" },
+ { "n", "lc", ll("LLeMbasCommands"), "Commands and skills", "LLeMbas" },
+ { "n", "lS", ll("LLeMbasStatus"), "Status", "LLeMbas" },
+ { "n", "l.", ll("LLeMbasStop"), "Stop the running turn", "LLeMbas" },
+ { "n", "li", mod("llembas_ide.llembas", "sign_in"), "Sign in", "LLeMbas" },
+ { "n", "l?", ll("LLeMbasHelp"), "The plugin's commands and keys", "LLeMbas" },
+ -- Sessions
+ { "n", "sr", mod("llembas_ide.sessions", "restore"), "Restore this directory's session", "Session" },
+ { "n", "sw", mod("llembas_ide.sessions", "save"), "Save the session now", "Session" },
+ { "n", "sd", mod("llembas_ide.sessions", "delete"), "Forget this directory's session", "Session" },
+ -- Terminal
+ { "n", "tt", mod("llembas_ide.terminal", "toggle"), "Terminal, open and close", "Terminal" },
+ { { "n", "t" }, "", mod("llembas_ide.terminal", "toggle"), "Terminal, open and close", "Terminal" },
+ { { "n", "t" }, "", mod("llembas_ide.terminal", "toggle"), "The same, as some terminals send it", "Terminal" },
+ { "t", "", "", "Leave the terminal's typing mode", "Terminal" },
+ -- Look
+ { "n", "ut", function() vim.o.background = vim.o.background == "dark" and "light" or "dark" end, "Dark and light theme", "Look" },
+ { "n", "uw", function() vim.wo.wrap = not vim.wo.wrap end, "Wrap long lines, on and off", "Look" },
+ { "n", "un", function() vim.wo.relativenumber = not vim.wo.relativenumber end, "Relative line numbers, on and off", "Look" },
+ -- The IDE itself
+ { "n", "ih", mod("llembas_ide.dashboard", "open"), "Start screen", "IDE" },
+ { "n", "ik", function() M.show() end, "This list of keys", "IDE" },
+ { "n", "id", "LLeMbasIdeDoctor", "Check the installation", "IDE" },
+ { "n", "iu", "LLeMbasIdeConfig", "Open your own settings file", "IDE" },
+ { "n", "iv", "LLeMbasIdeVersion", "Versions", "IDE" },
+}
+
+-- Added to a buffer when a language server attaches to it.
+M.lsp = {
+ { "n", "gd", function() vim.lsp.buf.definition() end, "Go to the definition" },
+ { "n", "gD", function() vim.lsp.buf.declaration() end, "Go to the declaration" },
+ { "n", "gI", function() vim.lsp.buf.implementation() end, "Go to the implementation" },
+ { "n", "gy", function() vim.lsp.buf.type_definition() end, "Go to the type's definition" },
+}
+
+-- Keys that are not the IDE's mappings but belong on the cheat sheet: plugins' and Neovim's own.
+M.also = {
+ { "i", "", "Accept LLeMbas's suggestion (the grey text)", "Typing" },
+ { "i", "", "Accept one word of it", "Typing" },
+ { "i", "", "Ask for a suggestion now", "Typing" },
+ { "i", " ", "Move in the completion menu (also )", "Typing" },
+ { "i", "", "Take the menu entry you moved to; otherwise a new line", "Typing" },
+ { "i", "", "Take the menu's first entry", "Typing" },
+ { "i", "", "Close the menu", "Typing" },
+ { "i", "", "Open the menu, or the entry's documentation", "Typing" },
+ { "n", "gcc", "Comment the line, on and off (gc with a motion or a selection)", "Editing" },
+ { "n", "sa sd sr", "Surround: add (saiw\"), delete (sd\"), replace (sr\"')", "Editing" },
+ { "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" },
+}
+
+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 = {}, {}
+ for _, list in ipairs({ M.map, M.lsp }) do
+ for _, k in ipairs(list) do
+ for _, mode in ipairs(modes(k[1])) do
+ local id = mode .. " " .. vim.api.nvim_replace_termcodes(k[2], true, true, true)
+ if seen[id] then table.insert(dup, mode .. " " .. k[2]) end
+ seen[id] = true
+ end
+ end
+ end
+ return dup
+end
+
+function M.setup()
+ for _, k in ipairs(M.map) do
+ vim.keymap.set(k[1], k[2], k[3], { desc = k[4], silent = type(k[3]) ~= "string" or k[3]:sub(1, 1) ~= ":" })
+ end
+end
+
+local function shown(lhs) return (lhs:gsub("", "")) end
+local mode_names = { n = "normal", x = "visual", i = "insert", t = "terminal" }
+local function mode_text(m)
+ local out = {}
+ for _, mode in ipairs(modes(m)) do table.insert(out, mode_names[mode] or mode) end
+ return table.concat(out, ", ")
+end
+
+--- The sections of the cheat sheet in order: { name, { {keys, modes, text}, … } }.
+function M.sections()
+ local order, by = {}, {}
+ local function add(section, keys, mode, text)
+ if not by[section] then
+ by[section] = {}
+ table.insert(order, section)
+ end
+ table.insert(by[section], { shown(keys), mode_text(mode), text })
+ end
+ for _, k in ipairs(M.also) do if k[4] == "Typing" or k[4] == "Editing" then add(k[4], k[2], k[1], k[3]) end end
+ 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
+ return out
+end
+
+--- The cheat sheet as the README has it.
+function M.markdown()
+ local out = {}
+ for _, s in ipairs(M.sections()) do
+ vim.list_extend(out, { "**" .. s[1] .. "**", "", "| Keys | In | What it does |", "|---|---|---|" })
+ for _, r in ipairs(s[2]) do
+ table.insert(out, ("| `%s` | %s | %s |"):format(r[1]:gsub("|", "\\|"), r[2], (r[3]:gsub("|", "\\|"))))
+ end
+ table.insert(out, "")
+ end
+ return out
+end
+
+--- :LLeMbasIdeKeys
+function M.show()
+ local lines, titles = { "The leader key is . Press it and wait: the next keys are shown.", "" }, {}
+ for _, s in ipairs(M.sections()) do
+ table.insert(lines, s[1])
+ table.insert(titles, #lines - 1)
+ for _, r in ipairs(s[2]) do
+ table.insert(lines, (" %-16s %-16s %s"):format(r[1], r[2], 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
+ end
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/llembas.lua b/ide/config/lua/llembas_ide/llembas.lua
new file mode 100644
index 0000000..10f729f
--- /dev/null
+++ b/ide/config/lua/llembas_ide/llembas.lua
@@ -0,0 +1,92 @@
+-- LLeMbas, built in. The plugin is the one in this repository's nvim/ directory, used through
+-- its documented commands and setup; the agent is the LLeMbas CLI. Nothing about a server, a
+-- model or a key is set here: they come from the CLI's sign-in.
+local M = {}
+
+M.loaded = false
+
+function M.has_cli() return vim.fn.executable("lembas") == 1 end
+
+function M.setup()
+ local ok, llembas = pcall(require, "llembas")
+ if not ok then
+ table.insert(require("llembas_ide").problems, "llembas: the LLeMbas plugin is not installed")
+ return
+ end
+ llembas.setup({
+ -- Without the CLI the IDE is an editor and stays quiet: no suggestions are asked for.
+ complete = { auto = M.has_cli() },
+ })
+ M.loaded = true
+end
+
+--- The plugin's version, or nil.
+function M.version()
+ local ok, llembas = pcall(require, "llembas")
+ return ok and llembas.version or nil
+end
+
+--- Whether suggestions as you type are on.
+function M.autocomplete_on()
+ local ok, llembas = pcall(require, "llembas")
+ 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
+ if not M.has_cli() then return "◈ no CLI", false end
+ local ok, text = pcall(function() return require("llembas").statusline() end)
+ text = (ok and type(text) == "string" and text ~= "") and text or "◈ LLeMbas"
+ return text .. (M.autocomplete_on() and " · suggest on" or " · suggest off"), true
+end
+
+--- Signing in is the CLI's. With a plugin that offers :LLeMbasLogin that is used; otherwise the
+--- one command to type is shown.
+function M.sign_in()
+ if vim.fn.exists(":LLeMbasLogin") == 2 then return vim.cmd("LLeMbasLogin") end
+ local lines
+ if M.has_cli() then
+ lines = {
+ "LLeMbas needs two things: a LLeMbas server, and a sign-in to it.",
+ "",
+ "In a terminal (tt opens one here), with your server's address:",
+ "",
+ " lembas login https://your-server.example.org",
+ "",
+ "It shows a code to confirm in the browser. After that the chat (ll),",
+ "asking about code and suggestions as you type work in this editor.",
+ "The models and the permissions are your account's; nothing is set here.",
+ }
+ else
+ lines = {
+ "The LLeMbas CLI (the `lembas` command) is not installed.",
+ "",
+ "It is the agent this editor talks to. Everything else in the IDE works without it.",
+ "To get it, run the installer again and answer yes to the CLI, or see",
+ "",
+ " https://github.com/LLeMbas/LLeMbas-CLI",
+ "",
+ "Then sign in to your LLeMbas server: lembas login https://your-server.example.org",
+ }
+ end
+ require("llembas_ide.ui").page("Sign in to LLeMbas", lines)
+end
+
+--- Run a plugin command only when the plugin and the CLI are there; otherwise say what is missing.
+function M.cmd(command)
+ return function()
+ 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(command)
+ end
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/lsp.lua b/ide/config/lua/llembas_ide/lsp.lua
new file mode 100644
index 0000000..099f9e1
--- /dev/null
+++ b/ide/config/lua/llembas_ide/lsp.lua
@@ -0,0 +1,91 @@
+-- Language servers through Neovim's own client. A server is a program of yours: the IDE starts
+-- the ones it finds on PATH and never downloads one. :LLeMbasIdeLsp says which are found and how
+-- each is installed.
+local M = {}
+
+-- name (nvim-lspconfig's), the program looked for, what it is for, how its own project says to install it.
+M.servers = {
+ { "lua_ls", "lua-language-server", "Lua", "your package manager, or github.com/LuaLS/lua-language-server releases" },
+ { "pyright", "pyright-langserver", "Python", "npm install -g pyright (or: pipx install pyright)" },
+ { "ruff", "ruff", "Python lint and format", "pipx install ruff" },
+ { "ts_ls", "typescript-language-server", "TypeScript, JavaScript", "npm install -g typescript typescript-language-server" },
+ { "rust_analyzer", "rust-analyzer", "Rust", "rustup component add rust-analyzer" },
+ { "gopls", "gopls", "Go", "go install golang.org/x/tools/gopls@latest" },
+ { "clangd", "clangd", "C, C++", "your package manager: clangd" },
+ { "bashls", "bash-language-server", "Shell", "npm install -g bash-language-server" },
+ { "jsonls", "vscode-json-language-server", "JSON", "npm install -g vscode-langservers-extracted" },
+ { "html", "vscode-html-language-server", "HTML", "npm install -g vscode-langservers-extracted" },
+ { "cssls", "vscode-css-language-server", "CSS", "npm install -g vscode-langservers-extracted" },
+ { "yamlls", "yaml-language-server", "YAML", "npm install -g yaml-language-server" },
+ { "marksman", "marksman", "Markdown", "your package manager, or github.com/artempyanykh/marksman releases" },
+}
+
+M.enabled = {}
+
+function M.setup()
+ local modern = vim.fn.has("nvim-0.11") == 1 and vim.lsp.enable ~= nil
+ -- Below 0.11 nvim-lspconfig's start-up file only announces that old Neovim is deprecated.
+ if not modern then vim.g.lspconfig = 1 end
+
+ local capabilities
+ local ok, blink = pcall(require, "blink.cmp")
+ if ok then capabilities = blink.get_lsp_capabilities() end
+
+ for _, s in ipairs(M.servers) do
+ local name, bin = s[1], s[2]
+ if vim.fn.executable(bin) == 1 then
+ if modern then
+ vim.lsp.enable(name)
+ table.insert(M.enabled, name)
+ else
+ local has, lspconfig = pcall(require, "lspconfig")
+ if has and lspconfig[name] then
+ lspconfig[name].setup({ capabilities = capabilities })
+ table.insert(M.enabled, name)
+ end
+ end
+ end
+ end
+
+ vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("llembas_ide_lsp", { clear = true }),
+ callback = function(ev)
+ for _, k in ipairs(require("llembas_ide.keys").lsp) do
+ vim.keymap.set(k[1], k[2], k[3], { buffer = ev.buf, desc = k[4] })
+ end
+ end,
+ })
+end
+
+--- The guide: every server the IDE knows, whether it is found, and how to get it.
+function M.guide()
+ local lines = {
+ "Language servers",
+ "",
+ "The IDE starts a server it finds on PATH when you open a file of its language.",
+ "It never downloads one: install the ones you want yourself, then restart the IDE.",
+ "",
+ }
+ local marks = {}
+ for _, s in ipairs(M.servers) do
+ local found = vim.fn.executable(s[2]) == 1
+ table.insert(lines, (" %s %-14s %-24s %s"):format(found and "found " or "missing", s[1], s[3], s[2]))
+ table.insert(marks, { #lines - 1, found and "LLeMbasIdeGood" or "LLeMbasIdeWarn" })
+ if not found then
+ table.insert(lines, " " .. s[4])
+ table.insert(marks, { #lines - 1, "LLeMbasIdeMuted" })
+ end
+ end
+ vim.list_extend(lines, {
+ "",
+ "Running in this buffer's window: :checkhealth vim.lsp",
+ "Another server: vim.lsp.enable(\"name\") in lua/user/init.lua (Neovim 0.11 or newer).",
+ })
+ local buf = require("llembas_ide.ui").page("LLeMbas IDE: language servers", lines)
+ for _, m in ipairs(marks) do
+ vim.api.nvim_buf_add_highlight(buf, -1, m[2], m[1], 2, 9)
+ end
+ vim.api.nvim_buf_add_highlight(buf, -1, "Title", 0, 0, -1)
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/options.lua b/ide/config/lua/llembas_ide/options.lua
new file mode 100644
index 0000000..9ecd919
--- /dev/null
+++ b/ide/config/lua/llembas_ide/options.lua
@@ -0,0 +1,89 @@
+-- The editor's options. Plain Neovim settings; lua/user/init.lua may change any of them.
+local M = {}
+
+function M.setup()
+ local o = vim.opt
+ vim.g.mapleader = " "
+ vim.g.maplocalleader = "\\"
+
+ -- What a file or a model writes is text, never settings or commands: no modelines, no
+ -- per-directory configuration files.
+ o.modeline = false
+ o.modelines = 0
+ o.exrc = false
+
+ o.number = true
+ o.relativenumber = false
+ o.cursorline = true
+ o.signcolumn = "yes"
+ o.termguicolors = true
+ o.showmode = false -- the statusline shows it
+ o.laststatus = 3
+ o.title = true
+ o.titlestring = "%t%( %M%) — LLeMbas IDE"
+ o.scrolloff = 4
+ o.sidescrolloff = 8
+ o.wrap = false
+ o.linebreak = true
+ o.list = true
+ o.listchars = { tab = "→ ", trail = "·", nbsp = "␣" }
+ o.fillchars = { eob = " " }
+ o.pumheight = 12
+ o.shortmess:append("I") -- the dashboard is the start screen
+
+ o.mouse = "a"
+ o.clipboard = "unnamedplus" -- the system clipboard, where a provider is installed
+ o.undofile = true
+ o.swapfile = true
+ o.updatetime = 300
+ o.timeoutlen = 400
+ o.confirm = true -- ask instead of failing on unsaved changes
+
+ o.splitright = true
+ o.splitbelow = true
+ o.splitkeep = "screen"
+
+ o.ignorecase = true
+ o.smartcase = true
+ o.incsearch = true
+ o.hlsearch = true
+ o.inccommand = "split"
+
+ o.expandtab = true
+ o.shiftwidth = 2
+ o.tabstop = 2
+ o.softtabstop = 2
+ o.smartindent = true
+ o.shiftround = true
+ o.breakindent = true
+
+ o.completeopt = { "menu", "menuone", "noselect" }
+ o.wildmode = { "longest:full", "full" }
+ -- A session holds windows and buffers, not options or variables.
+ o.sessionoptions = { "buffers", "curdir", "folds", "help", "tabpages", "winsize" }
+
+ vim.diagnostic.config({
+ severity_sort = true,
+ underline = true,
+ virtual_text = { spacing = 2, source = "if_many" },
+ float = { border = "rounded", source = "if_many" },
+ })
+
+ local group = vim.api.nvim_create_augroup("llembas_ide_options", { clear = true })
+ vim.api.nvim_create_autocmd("TextYankPost", {
+ group = group,
+ callback = function() pcall(vim.highlight.on_yank, { timeout = 150 }) end,
+ })
+ -- Back to where the cursor was when the file was last open.
+ vim.api.nvim_create_autocmd("BufReadPost", {
+ group = group,
+ callback = function(ev)
+ local mark = vim.api.nvim_buf_get_mark(ev.buf, '"')
+ if mark[1] > 0 and mark[1] <= vim.api.nvim_buf_line_count(ev.buf) then
+ pcall(vim.api.nvim_win_set_cursor, 0, mark)
+ end
+ end,
+ })
+end
+
+return M
diff --git a/ide/config/lua/llembas_ide/plugins.lua b/ide/config/lua/llembas_ide/plugins.lua
new file mode 100644
index 0000000..489f0a8
--- /dev/null
+++ b/ide/config/lua/llembas_ide/plugins.lua
@@ -0,0 +1,106 @@
+-- The third-party plugins, set up. Each is a package the installer placed at a pinned commit
+-- (ide/plugins.lock); a missing one is named as a problem and the rest still work.
+local M = {}
+
+local function mini(name, opts)
+ local ide = require("llembas_ide")
+ ide.try("mini." .. name, function() require("mini." .. name).setup(opts or {}) end)
+end
+
+function M.setup()
+ -- Icons as plain letters: a terminal's font is not ours to assume. With a Nerd Font, put
+ -- require("mini.icons").setup({ style = "glyph" }) in lua/user/init.lua.
+ mini("icons", { style = "ascii" })
+ mini("files", {
+ content = { prefix = function() end }, -- no icon column
+ windows = { preview = true, width_preview = 60 },
+ options = { use_as_default_explorer = true },
+ })
+ mini("pick", { window = { prompt_prefix = "› " } })
+ require("llembas_ide").try("mini.pick as vim.ui.select", function() vim.ui.select = require("mini.pick").ui_select end)
+ mini("extra")
+ mini("surround")
+ mini("pairs")
+ mini("bufremove")
+ mini("git")
+ mini("diff", {
+ view = { style = "sign", signs = { add = "▎", change = "▎", delete = "▁" } },
+ -- ]h and [h, ga and gr are the LLeMbas plugin's (its proposed changes): git hunks move on g.
+ mappings = {
+ apply = "", reset = "", textobject = "ih",
+ goto_first = "[G", goto_prev = "[g", goto_next = "]g", goto_last = "]G",
+ },
+ })
+
+ local keys = require("llembas_ide.keys")
+ local ok, clue = pcall(require, "mini.clue")
+ if ok then
+ local clues = {
+ clue.gen_clues.g(), clue.gen_clues.z(), clue.gen_clues.windows(),
+ clue.gen_clues.registers(), clue.gen_clues.marks(), clue.gen_clues.builtin_completion(),
+ }
+ for _, g in ipairs(keys.groups) do
+ table.insert(clues, { mode = "n", keys = g[1], desc = "+" .. g[2] })
+ table.insert(clues, { mode = "x", keys = g[1], desc = "+" .. g[2] })
+ end
+ mini("clue", {
+ triggers = {
+ { mode = "n", keys = "" }, { mode = "x", keys = "