ide: the LLeMbas IDE distribution — one installer, a pinned Neovim, a branded configuration

A new top-level ide/: install.sh places a hash-checked Neovim release, five third-party
plugins each at one pinned commit, the LLeMbas plugin from nvim/, a generated colourscheme
and a launcher, for one user and under its own NVIM_APPNAME. Built in a staging directory,
started there once, then swapped in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Fable 5.2 committed 2026-12-01 19:49:21 +00:00
1 parent dd2bc2dcae
commit 31ede4d8d2
32 files changed
+3876

No files matched your search

+309
View File
@@ -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 <address>`). 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<version>/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 (`<Space>cf`), with a formatter that is installed, or the
language server.
## 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.
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).
<!-- 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 |
| `<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 |
| `<C-e>` | insert | Close the menu |
| `<C-Space>` | 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 |
|---|---|---|
| `<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>ff` | normal | Find a file |
| `<Space>fg` | normal | Search in files (needs rg) |
| `<Space>fw` | normal | Search the word under the cursor |
| `<Space>fb` | normal | Open buffers |
| `<Space>fr` | normal | Recent files |
| `<Space>fs` | normal | Symbols in this file |
| `<Space>fS` | normal | Symbols in the project |
| `<Space>fR` | normal | References to the symbol under the cursor |
| `<Space>fd` | normal | Problems in the project |
| `<Space>fh` | normal | Help pages |
| `<Space>fk` | normal | All key mappings |
| `<Space>f.` | normal | The last search again |
**Buffers**
| Keys | In | What it does |
|---|---|---|
| `<Space>bd` | normal | Close the buffer, keep the window |
| `<Space>bn` | normal | Next buffer |
| `<Space>bp` | normal | Previous buffer |
| `<S-l>` | normal | Next buffer |
| `<S-h>` | normal | Previous buffer |
| `<Space>w` | normal | Save |
| `<Space>q` | normal | Close the window |
| `<Esc>` | normal | Clear the search highlight |
**Code**
| Keys | In | What it does |
|---|---|---|
| `<Space>ca` | normal | Code action |
| `<Space>cr` | normal | Rename the symbol |
| `<Space>cf` | normal, visual | Format the file or the selection |
| `<Space>cd` | normal | The problem on this line |
| `<Space>cl` | normal | Language servers: found, missing, how to install |
**Problems**
| Keys | In | What it does |
|---|---|---|
| `<Space>xx` | normal | Problems in this file, as a list |
| `<Space>xw` | normal | Problems in the project, as a list |
| `<Space>xn` | normal | Next problem |
| `<Space>xp` | normal | Previous problem |
**Git**
| Keys | In | What it does |
|---|---|---|
| `<Space>gs` | normal | Changed files |
| `<Space>gh` | normal | Changes, hunk by hunk |
| `<Space>gd` | normal | This file beside its committed version |
| `<Space>go` | normal | Show changes inline, on and off |
| `<Space>ga` | normal | Stage the change under the cursor |
| `<Space>gr` | normal | Undo the change under the cursor |
| `<Space>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 |
|---|---|---|
| `<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) |
| `<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 |
| `<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) |
**Session**
| Keys | In | What it does |
|---|---|---|
| `<Space>sr` | normal | Restore this directory's session |
| `<Space>sw` | normal | Save the session now |
| `<Space>sd` | normal | Forget this directory's session |
**Terminal**
| Keys | In | What it does |
|---|---|---|
| `<Space>tt` | normal | Terminal, open and close |
| `<C-/>` | normal, terminal | Terminal, open and close |
| `<C-_>` | normal, terminal | The same, as some terminals send it |
| `<Esc><Esc>` | terminal | Leave the terminal's typing mode |
**Look**
| Keys | In | What it does |
|---|---|---|
| `<Space>ut` | normal | Dark and light theme |
| `<Space>uw` | normal | Wrap long lines, on and off |
| `<Space>un` | normal | Relative line numbers, on and off |
**IDE**
| Keys | In | What it does |
|---|---|---|
| `<Space>ih` | normal | Start screen |
| `<Space>ik` | normal | This list of keys |
| `<Space>id` | normal | Check the installation |
| `<Space>iu` | normal | Open your own settings file |
| `<Space>iv` | normal | Versions |
<!-- 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.
## Make it yours
`~/.config/llembas-ide/lua/user/init.lua` (open it with `<Space>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/<name>/`: 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). `<Space>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; `<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.
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.
+57
View File
@@ -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.
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

+304
View File
@@ -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/tty; } 2>/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 (<Space>/) 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 <your server's address>"
elif [ -f "$index" ] && grep -q '"base_url"' "$index"; then
good "signed in to a LLeMbas server"
else
off "not signed in: lembas login <your server's address>"
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 || answer=""
case "$answer" in y | Y | yes | Yes) ;; *) say "Nothing removed." && return 0 ;; esac
if [ "$purge" != 1 ] && [ -d "$CONFIG" ]; then
printf 'Remove your own settings in %s too? [y/N] ' "$CONFIG" >/dev/tty
read -r answer </dev/tty || answer=""
case "$answer" in y | Y | yes | Yes) keep_config=0 ;; esac
fi
fi
[ "$purge" != 1 ] || keep_config=0
# The configuration: the IDE's own init.lua goes when it is still the IDE's; what you wrote stays.
if [ "$keep_config" = 0 ]; then
remove_app_dir "$CONFIG"
else
if [ -f "$CONFIG/init.lua" ] && [ "$(sha256_of "$CONFIG/init.lua")" = "$(recorded init_sha)" ]; then
rm -f -- "$CONFIG/init.lua"
fi
rm -f -- "$CONFIG/init.lua.new"
fi
[ -z "$desktop" ] || rm -f -- "$desktop"
[ -z "$icon" ] || rm -f -- "$icon"
remove_app_dir "$STATE"
remove_app_dir "$CACHE"
rm -rf -- "${PREFIX:?}/nvim" "${PREFIX:?}/site/pack/llembas" "${PREFIX:?}/lib"
find "${PREFIX:?}" -maxdepth 1 \( -name '.staging.*' -o -name '.old.*' \) -exec rm -rf -- {} + 2>/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" "$@"
+318
View File
@@ -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
+20
View File
@@ -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 })
+35
View File
@@ -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
+20
View File
@@ -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
+48
View File
@@ -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
+43
View File
@@ -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:
-- <Tab> accepts LLeMbas's suggestion (<M-Right> one word of it). Never the menu.
-- <C-n> <C-p> or <Down> <Up> move in the menu; nothing in it is chosen until you do.
-- <CR> takes the menu entry you moved to; with none chosen it is a plain Enter.
-- <C-y> takes the first entry without moving.
-- <C-e> closes the menu. <C-Space> opens it, or shows the entry's documentation.
local M = {}
function M.setup()
require("blink.cmp").setup({
keymap = {
preset = "none",
["<C-Space>"] = { "show", "show_documentation", "hide_documentation" },
["<C-e>"] = { "hide", "fallback" },
["<C-y>"] = { "select_and_accept", "fallback" },
["<CR>"] = { "accept", "fallback" },
["<C-n>"] = { "select_next", "fallback_to_mappings" },
["<C-p>"] = { "select_prev", "fallback_to_mappings" },
["<Down>"] = { "select_next", "fallback" },
["<Up>"] = { "select_prev", "fallback" },
["<C-f>"] = { "scroll_documentation_down", "fallback" },
["<C-b>"] = { "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
+155
View File
@@ -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; <leader>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. <Space> is the leader key:")
note("press it and wait to see what follows.")
note("Your own settings: <Space>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
+46
View File
@@ -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
+71
View File
@@ -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
+222
View File
@@ -0,0 +1,222 @@
-- 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.
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 = {
{ "<Leader>f", "find" },
{ "<Leader>b", "buffer" },
{ "<Leader>c", "code" },
{ "<Leader>g", "git" },
{ "<Leader>l", "LLeMbas" },
{ "<Leader>s", "session" },
{ "<Leader>t", "terminal" },
{ "<Leader>u", "look" },
{ "<Leader>x", "problems" },
{ "<Leader>i", "IDE" },
}
-- { modes, keys, action, what it does, section }
M.map = {
-- Files and search
{ "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>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" },
{ "n", "<Leader>fb", pick("buffers"), "Open buffers", "Find" },
{ "n", "<Leader>fr", extra("oldfiles"), "Recent files", "Find" },
{ "n", "<Leader>fs", extra("lsp", { scope = "document_symbol" }), "Symbols in this file", "Find" },
{ "n", "<Leader>fS", extra("lsp", { scope = "workspace_symbol" }), "Symbols in the project", "Find" },
{ "n", "<Leader>fR", extra("lsp", { scope = "references" }), "References to the symbol under the cursor", "Find" },
{ "n", "<Leader>fd", extra("diagnostic", { scope = "all" }), "Problems in the project", "Find" },
{ "n", "<Leader>fh", pick("help"), "Help pages", "Find" },
{ "n", "<Leader>fk", extra("keymaps"), "All key mappings", "Find" },
{ "n", "<Leader>f.", pick("resume"), "The last search again", "Find" },
-- Buffers and windows
{ "n", "<Leader>bd", function() require("mini.bufremove").delete() end, "Close the buffer, keep the window", "Buffers" },
{ "n", "<Leader>bn", "<Cmd>bnext<CR>", "Next buffer", "Buffers" },
{ "n", "<Leader>bp", "<Cmd>bprevious<CR>", "Previous buffer", "Buffers" },
{ "n", "<S-l>", "<Cmd>bnext<CR>", "Next buffer", "Buffers" },
{ "n", "<S-h>", "<Cmd>bprevious<CR>", "Previous buffer", "Buffers" },
{ "n", "<Leader>w", "<Cmd>write<CR>", "Save", "Buffers" },
{ "n", "<Leader>q", "<Cmd>quit<CR>", "Close the window", "Buffers" },
{ "n", "<Esc>", "<Cmd>nohlsearch<CR>", "Clear the search highlight", "Buffers" },
-- Code
{ "n", "<Leader>ca", function() vim.lsp.buf.code_action() end, "Code action", "Code" },
{ "n", "<Leader>cr", function() vim.lsp.buf.rename() end, "Rename the symbol", "Code" },
{ { "n", "x" }, "<Leader>cf", mod("llembas_ide.plugins", "format"), "Format the file or the selection", "Code" },
{ "n", "<Leader>cd", function() vim.diagnostic.open_float() end, "The problem on this line", "Code" },
{ "n", "<Leader>cl", mod("llembas_ide.lsp", "guide"), "Language servers: found, missing, how to install", "Code" },
-- Problems
{ "n", "<Leader>xx", function() vim.diagnostic.setloclist() end, "Problems in this file, as a list", "Problems" },
{ "n", "<Leader>xw", function() vim.diagnostic.setqflist() end, "Problems in the project, as a list", "Problems" },
{ "n", "<Leader>xn", problem(1), "Next problem", "Problems" },
{ "n", "<Leader>xp", problem(-1), "Previous problem", "Problems" },
-- Git
{ "n", "<Leader>gs", extra("git_files", { scope = "modified" }), "Changed files", "Git" },
{ "n", "<Leader>gh", extra("git_hunks"), "Changes, hunk by hunk", "Git" },
{ "n", "<Leader>gd", mod("llembas_ide.git", "diff_head"), "This file beside its committed version", "Git" },
{ "n", "<Leader>go", function() require("mini.diff").toggle_overlay(0) end, "Show changes inline, on and off", "Git" },
{ "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" },
-- 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" },
{ "n", "<Leader>sd", mod("llembas_ide.sessions", "delete"), "Forget this directory's session", "Session" },
-- Terminal
{ "n", "<Leader>tt", mod("llembas_ide.terminal", "toggle"), "Terminal, open and close", "Terminal" },
{ { "n", "t" }, "<C-/>", mod("llembas_ide.terminal", "toggle"), "Terminal, open and close", "Terminal" },
{ { "n", "t" }, "<C-_>", mod("llembas_ide.terminal", "toggle"), "The same, as some terminals send it", "Terminal" },
{ "t", "<Esc><Esc>", "<C-\\><C-n>", "Leave the terminal's typing mode", "Terminal" },
-- Look
{ "n", "<Leader>ut", function() vim.o.background = vim.o.background == "dark" and "light" or "dark" end, "Dark and light theme", "Look" },
{ "n", "<Leader>uw", function() vim.wo.wrap = not vim.wo.wrap end, "Wrap long lines, on and off", "Look" },
{ "n", "<Leader>un", function() vim.wo.relativenumber = not vim.wo.relativenumber end, "Relative line numbers, on and off", "Look" },
-- The IDE itself
{ "n", "<Leader>ih", mod("llembas_ide.dashboard", "open"), "Start screen", "IDE" },
{ "n", "<Leader>ik", function() M.show() end, "This list of keys", "IDE" },
{ "n", "<Leader>id", "<Cmd>LLeMbasIdeDoctor<CR>", "Check the installation", "IDE" },
{ "n", "<Leader>iu", "<Cmd>LLeMbasIdeConfig<CR>", "Open your own settings file", "IDE" },
{ "n", "<Leader>iv", "<Cmd>LLeMbasIdeVersion<CR>", "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", "<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", "<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" },
{ "i", "<C-e>", "Close the menu", "Typing" },
{ "i", "<C-Space>", "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("<Leader>", "<Space>")) 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 <Space>. 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
+92
View File
@@ -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 (<Space>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 (<Space>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
+91
View File
@@ -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
+89
View File
@@ -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
+106
View File
@@ -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 = "<Leader>" }, { mode = "x", keys = "<Leader>" },
{ mode = "n", keys = "g" }, { mode = "x", keys = "g" },
{ mode = "n", keys = "z" }, { mode = "x", keys = "z" },
{ mode = "n", keys = "<C-w>" },
{ mode = "n", keys = '"' }, { mode = "x", keys = '"' },
{ mode = "n", keys = "'" }, { mode = "n", keys = "`" },
{ mode = "n", keys = "[" }, { mode = "n", keys = "]" },
{ mode = "i", keys = "<C-x>" },
},
clues = clues,
window = { delay = 300, config = { width = "auto", border = "rounded" } },
})
else
table.insert(require("llembas_ide").problems, "mini.clue: not installed")
end
require("llembas_ide").try("conform", function()
-- Formatting happens when asked for (<leader>cf, :LLeMbasIdeFormat), never on save.
-- A formatter listed here is used when it is installed; otherwise the language server formats.
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
python = { "ruff_format", "black", stop_after_first = true },
javascript = { "prettierd", "prettier", stop_after_first = true },
typescript = { "prettierd", "prettier", stop_after_first = true },
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
json = { "prettierd", "prettier", stop_after_first = true },
yaml = { "prettierd", "prettier", stop_after_first = true },
markdown = { "prettierd", "prettier", stop_after_first = true },
html = { "prettierd", "prettier", stop_after_first = true },
css = { "prettierd", "prettier", stop_after_first = true },
sh = { "shfmt" },
bash = { "shfmt" },
go = { "gofmt" },
rust = { "rustfmt" },
c = { "clang-format" },
cpp = { "clang-format" },
},
default_format_opts = { lsp_format = "fallback" },
notify_no_formatters = true,
})
end)
end
--- Format the buffer, or the selected lines.
function M.format()
local ok, conform = pcall(require, "conform")
if ok then
conform.format({ async = true, lsp_format = "fallback" }, function(err, did)
if err then vim.notify("Format: " .. tostring(err), vim.log.levels.WARN)
elseif did == false then vim.notify("Format: nothing to change") end
end)
else
vim.lsp.buf.format({ async = true })
end
end
return M
+65
View File
@@ -0,0 +1,65 @@
-- One session per directory: the windows and buffers of the last time the IDE was closed there.
-- Saved on leaving, restored when asked for (the dashboard, <leader>sr). Session files live in
-- the IDE's own state directory and nowhere else: a Session.vim found in a project is not read.
local M = {}
local function dir() return vim.fn.stdpath("state") .. "/sessions" end
--- The session's name for a directory: readable, and unique to the full path.
function M.name(cwd)
cwd = cwd or vim.fn.getcwd()
local base = vim.fn.fnamemodify(cwd, ":t"):gsub("[^%w%-_.]", "_")
if base == "" then base = "root" end
return base .. "-" .. vim.fn.sha256(cwd):sub(1, 12) .. ".vim"
end
function M.exists(cwd) return vim.fn.filereadable(dir() .. "/" .. M.name(cwd)) == 1 end
local function has_files()
for _, b in ipairs(vim.api.nvim_list_bufs()) do
if vim.bo[b].buflisted and vim.bo[b].buftype == "" and vim.api.nvim_buf_get_name(b) ~= "" then return true end
end
return false
end
function M.save(quiet)
if not has_files() then
if not quiet then vim.notify("Session: no files are open") end
return false
end
local ok, err = pcall(function() require("mini.sessions").write(M.name(), { verbose = false }) 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 ok, err = pcall(function() require("mini.sessions").read(M.name(), { verbose = false }) end)
if not ok then vim.notify("Session: " .. tostring(err), vim.log.levels.WARN) end
end
function M.delete()
if not M.exists() then return vim.notify("Session: none saved for " .. vim.fn.getcwd()) end
vim.fn.delete(dir() .. "/" .. M.name())
vim.notify("Session forgotten for " .. vim.fn.getcwd())
end
function M.setup()
vim.fn.mkdir(dir(), "p")
require("mini.sessions").setup({
autoread = false,
autowrite = false,
directory = dir(),
file = "", -- never a session file from the working directory
verbose = { read = false, write = false, delete = false },
})
vim.api.nvim_create_autocmd("VimLeavePre", {
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)
end,
})
end
return M
+40
View File
@@ -0,0 +1,40 @@
-- One terminal at the bottom that opens and closes; what runs in it keeps running.
local M = {}
local state = { buf = nil, win = nil }
function M.toggle()
if state.win and vim.api.nvim_win_is_valid(state.win) then
vim.api.nvim_win_hide(state.win)
state.win = nil
return
end
vim.cmd("botright " .. math.max(8, math.floor(vim.o.lines * 0.3)) .. "split")
state.win = vim.api.nvim_get_current_win()
if state.buf and vim.api.nvim_buf_is_valid(state.buf) then
vim.api.nvim_win_set_buf(state.win, state.buf)
else
vim.cmd.terminal()
state.buf = vim.api.nvim_get_current_buf()
vim.bo[state.buf].buflisted = false
end
vim.wo[state.win].number = false
vim.wo[state.win].signcolumn = "no"
vim.cmd.startinsert()
end
--- Run a command of the IDE's own in a terminal split and leave its output on the screen.
function M.run(argv)
vim.cmd("botright " .. math.max(12, math.floor(vim.o.lines * 0.45)) .. "new")
local buf = vim.api.nvim_get_current_buf()
vim.bo[buf].bufhidden = "wipe"
if vim.fn.has("nvim-0.11") == 1 then
vim.fn.jobstart(argv, { term = true })
else
vim.fn.termopen(argv)
end
vim.bo[buf].buflisted = false
vim.keymap.set("n", "q", "<Cmd>bwipeout!<CR>", { buffer = buf, nowait = true })
end
return M
+55
View File
@@ -0,0 +1,55 @@
-- Treesitter highlighting. With the grammars the installer compiled (ide/parsers.lock, when a
-- C compiler was there) the queries of nvim-treesitter are used with them. Without, Neovim's own
-- bundled grammars and queries are (C, Lua, Markdown, Vimscript, help, queries) and every other
-- language is coloured by Neovim's regular syntax files. Nothing is ever installed from here.
local M = {}
M.compiled = false
local function parsers_dir()
local dir = require("llembas_ide").prefix .. "/site/pack/llembas/start/llembas-parsers/parser"
return vim.fn.isdirectory(dir) == 1 and dir or nil
end
function M.setup()
if parsers_dir() then
-- The plugin's own start-up (its module system and :TSInstall commands) stays off: only its
-- queries and the predicates they use are wanted.
vim.g.loaded_nvim_treesitter = true
local ok = pcall(vim.cmd.packadd, "nvim-treesitter")
if ok and pcall(require, "nvim-treesitter.query_predicates") then
M.compiled = true
else
table.insert(require("llembas_ide").problems, "treesitter: grammars are compiled but nvim-treesitter's queries are missing")
end
end
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("llembas_ide_treesitter", { clear = true }),
callback = function(ev) M.start(ev.buf) end,
})
end
--- Start highlighting for a buffer when its language has a grammar and a query; quietly not otherwise.
function M.start(buf)
local ft = vim.bo[buf].filetype
if ft == "" or vim.bo[buf].buftype == "terminal" then return false end
local lang = vim.treesitter.language.get_lang(ft) or ft
local ok, added = pcall(vim.treesitter.language.add, lang)
if not ok or added == false then return false end
local has_query, query = pcall(vim.treesitter.query.get, lang, "highlights")
if not has_query or not query then return false end
return (pcall(vim.treesitter.start, buf, lang))
end
--- The languages with a compiled grammar.
function M.languages()
local out = {}
for _, f in ipairs(vim.api.nvim_get_runtime_file("parser/*.so", true)) do
out[vim.fn.fnamemodify(f, ":t:r")] = true
end
local list = vim.tbl_keys(out)
table.sort(list)
return list
end
return M
+30
View File
@@ -0,0 +1,30 @@
-- Small shared pieces of the IDE's own screens.
local M = {}
--- A read-only page in a centred floating window; q or <Esc> closes it. Returns the buffer.
function M.page(title, lines)
local buf = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
vim.bo[buf].modifiable = false
vim.bo[buf].bufhidden = "wipe"
vim.bo[buf].filetype = "llembas-ide-page"
local width = 20
for _, l in ipairs(lines) do width = math.max(width, vim.fn.strdisplaywidth(l)) end
width = math.min(width + 2, math.max(20, vim.o.columns - 4))
local height = math.min(#lines, math.max(3, vim.o.lines - 6))
local win = vim.api.nvim_open_win(buf, true, {
relative = "editor", style = "minimal", border = "rounded",
title = " " .. title .. " ", title_pos = "center",
width = width, height = height,
row = math.max(0, math.floor((vim.o.lines - height) / 2) - 1),
col = math.max(0, math.floor((vim.o.columns - width) / 2)),
})
vim.wo[win].wrap = false
vim.wo[win].cursorline = false
for _, key in ipairs({ "q", "<Esc>" }) do
vim.keymap.set("n", key, function() pcall(vim.api.nvim_win_close, win, true) end, { buffer = buf, nowait = true })
end
return buf, win
end
return M
Executable
+713
View File
@@ -0,0 +1,713 @@
#!/usr/bin/env bash
# LLeMbas IDE from nothing: a complete Neovim editor with LLeMbas built in, for this user only.
#
# curl -fsSL https://github.com/LLeMbas/LLeMbas-IDE/releases/latest/download/install.sh | bash
# curl -fsSL <…>/install.sh | bash -s -- --channel beta # options go after --
# ide/install.sh --from-checkout # from a clone of the repository
#
# What it installs, and where (nothing else is written, nothing runs as root):
# <prefix>/nvim/ a pinned Neovim release, its SHA-256 checked (ide/neovim.sha256)
# <prefix>/site/pack/llembas/ the IDE's configuration and its plugins, each plugin fetched
# with git at the one commit ide/plugins.lock names
# <prefix>/lib/ the LLeMbas plugin, this installer, the lock files
# ~/.config/llembas-ide/ init.lua, and lua/user/init.lua: yours, never overwritten
# ~/.local/bin/llembas-ide the launcher (NVIM_APPNAME=llembas-ide: your own Neovim
# configuration in ~/.config/nvim is never read or written)
# ~/.local/share/applications/llembas-ide.desktop and an icon (Linux)
# <prefix> is ${XDG_DATA_HOME:-~/.local/share}/llembas-ide unless --prefix says otherwise.
#
# Everything is built in a staging directory and tried there before it replaces what is
# installed; a failure leaves the previous installation, or nothing, exactly as it was.
# Running it again updates in place.
#
# Options:
# --version X install release X (1.2.3 or v1.2.3) instead of the newest
# --channel NAME stable (default) or beta: which releases "newest" looks at
# --prefix DIR where the IDE itself goes
# --from-checkout install from the repository this script sits in, not from a release
# --nvim-bin PATH use this Neovim (0.10 or newer) instead of downloading the pinned one
# --no-cli do not offer to install the LLeMbas CLI
# --no-parsers do not compile the Treesitter grammars
# --yes ask nothing: yes to the CLI offer
# --dry-run print every action, do nothing
#
# Environment:
# LLEMBAS_IDE_FORGE where releases come from (default https://github.com)
# LLEMBAS_IDE_SLUG owner/name there (default LLeMbas/LLeMbas-IDE)
# LLEMBAS_IDE_RELEASE_BASE the releases' download directory, when it is not the forge's own:
# an https:// address, or file:// for a release on this machine
# LLEMBAS_IDE_PUBKEY the ssh-ed25519 key a release's SHA256SUMS.sig must be signed with
# LLEMBAS_IDE_GIT_MIRROR a directory of git repositories named like the plugins' own, to
# fetch from instead of the network; the commit is checked all the same
#
# Needs bash, git, curl, tar and sha256sum (or shasum). A C compiler is used when there is one.
# Linux x86-64 and arm64. macOS is written for and has not been tried.
set -euo pipefail
FORGE="${LLEMBAS_IDE_FORGE:-https://github.com}"
FORGE="${FORGE%/}"
SLUG="${LLEMBAS_IDE_SLUG:-LLeMbas/LLeMbas-IDE}"
# The key releases are signed with. Empty: releases of LLeMbas IDE are not signed yet, and a
# release is checked against its own SHA256SUMS only. Set, a release without a good
# SHA256SUMS.sig (ssh-keygen -Y sign, namespace lembas-release) is refused.
PUBKEY="${LLEMBAS_IDE_PUBKEY:-}"
SIGN_NAMESPACE="lembas-release"
CLI_GET="https://github.com/LLeMbas/LLeMbas-CLI/releases/latest/download/get.sh"
NVIM_RELEASES="https://github.com/neovim/neovim/releases/download"
APP="llembas-ide"
MIN_NVIM="0.10"
VERSION_WANTED=""
CHANNEL="stable"
PREFIX=""
FROM_CHECKOUT=0
FROM_DIR=""
NVIM_BIN=""
WITH_CLI=1
WITH_PARSERS=1
YES=0
DRY=0
TMP=""
STAGE=""
OLD=""
SWAPPED=()
PLACED=()
DONE=0
# Everything is inside functions called on the last line: a download cut short runs nothing.
say() { printf '%s\n' "$*"; }
note() { printf ' %s\n' "$*"; }
warn() { printf 'install.sh: %s\n' "$*" >&2; }
die() {
printf 'install.sh: %s\n' "$*" >&2
exit 1
}
# One line per action. With --dry-run the line is all that happens.
step() {
if [ "$DRY" = 1 ]; then printf ' would %s\n' "$*"; else printf ' %s\n' "$*"; fi
}
rollback() {
local i unit
# Files placed outside the prefix, newest first: the old one back, or gone if there was none.
for ((i = ${#PLACED[@]} - 1; i >= 0; i--)); do
unit="${PLACED[$i]}"
rm -f "$unit"
if [ -e "$OLD/files/$i" ]; then mv "$OLD/files/$i" "$unit"; fi
done
for ((i = ${#SWAPPED[@]} - 1; i >= 0; i--)); do
unit="${SWAPPED[$i]}"
rm -rf "${PREFIX:?}/$unit"
if [ -e "$OLD/$unit" ]; then mv "$OLD/$unit" "$PREFIX/$unit"; fi
done
}
cleanup() {
local status=$?
trap - EXIT
if [ "$DONE" != 1 ] && [ -n "$OLD" ] && [ -d "$OLD" ]; then
rollback || true
warn "nothing was changed: the installation is as it was before."
fi
if [ "$status" != 0 ] && [ "$DONE" != 1 ] && { [ -z "$OLD" ] || [ ! -d "$OLD" ]; } && [ -n "$STAGE" ]; then
warn "stopped before anything was put in place: nothing was installed or changed."
fi
[ -z "$TMP" ] || rm -rf "$TMP"
[ -z "$STAGE" ] || rm -rf "$STAGE"
[ -z "$OLD" ] || rm -rf "$OLD"
# A prefix this run made and left empty goes again.
if [ -n "$PREFIX" ] && [ -d "$PREFIX" ] && [ "$DONE" != 1 ]; then
rmdir "$PREFIX/site/pack" "$PREFIX/site" "$PREFIX" 2>/dev/null || true
fi
exit "$status"
}
usage() {
sed -n '2,/^set -euo/p' "${BASH_SOURCE[0]}" 2>/dev/null | sed -e '$d' -e 's/^# \{0,1\}//'
}
need() {
command -v "$1" >/dev/null 2>&1 || die "needs $1, which is not installed${2:+ ($2)}"
}
sha256_of() {
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$1" | cut -d' ' -f1
elif command -v shasum >/dev/null 2>&1; then
shasum -a 256 "$1" | cut -d' ' -f1
else
die "needs sha256sum or shasum to check what it downloads"
fi
}
# Only https, or a file on this machine: nothing is fetched over a connection that cannot be trusted.
fetch() {
local url="$1" out="$2"
case "$url" in
https://* | file:///*) ;;
*) die "refusing to download $url: only https:// (or a local file://) is used" ;;
esac
curl -fsSL --retry 2 --proto '=https,file' --proto-redir '=https' -o "$out" "$url"
}
# Questions go to the terminal: piped into bash, this script's stdin is the script itself.
has_tty() { [ -r /dev/tty ] && { : </dev/tty; } 2>/dev/null; }
ask_yes() {
local answer=""
[ "$YES" = 1 ] && return 0
has_tty || return 1
printf '%s [y/N] ' "$1" >/dev/tty
read -r answer </dev/tty || return 1
case "$answer" in y | Y | yes | Yes) return 0 ;; *) return 1 ;; esac
}
# Neovim run by the installer keeps its log and state in the temporary directory, not in the home.
nvim_quiet() {
local scratch="${TMP:-/dev/null}"
if [ -d "$scratch" ]; then
XDG_STATE_HOME="$scratch/nvim-state" XDG_CACHE_HOME="$scratch/nvim-cache" XDG_DATA_HOME="$scratch/nvim-data" \
XDG_CONFIG_HOME="$scratch/nvim-config" NVIM_LOG_FILE="$scratch/nvim.log" "$@"
else
NVIM_LOG_FILE=/dev/null "$@"
fi
}
git_quiet() {
GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 GIT_TERMINAL_PROMPT=0 git "$@"
}
# The lines of a lock file that say something.
lock_lines() { grep -v -E '^[[:space:]]*(#|$)' "$1"; }
# --- which release -----------------------------------------------------------------------------
api_base() {
if [ "$FORGE" = https://github.com ]; then echo https://api.github.com; else echo "$FORGE/api/v1"; fi
}
# The newest release tag of the channel, by version: vX.Y.Z, and for beta also vX.Y.Z-beta.N
# (a beta sorts below its own release).
newest_tag() {
local json tags
json="$(curl -fsSL --proto '=https' "$(api_base)/repos/$SLUG/releases?per_page=50&limit=50")" || return 1
tags="$(printf '%s' "$json" | tr ',' '\n' | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p')"
if [ "$CHANNEL" = beta ]; then
tags="$(printf '%s\n' "$tags" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$' || true)"
else
tags="$(printf '%s\n' "$tags" | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' || true)"
fi
printf '%s\n' "$tags" | sed '/^$/d' | sed -E 's/^v//; s/-beta\.([0-9]+)$/.beta.\1/; /beta/!s/$/.zz/' | sort -V | tail -n1 |
sed -E 's/\.zz$//; s/\.beta\.([0-9]+)$/-beta.\1/; s/^/v/'
}
check_signature() {
local dir="$1"
if [ -z "$PUBKEY" ]; then
note "checked against the release's SHA256SUMS (releases of LLeMbas IDE are not signed yet)"
return 0
fi
need ssh-keygen "openssh-client; it checks the release's signature"
[ -s "$dir/SHA256SUMS.sig" ] || die "the release is not signed (no SHA256SUMS.sig) — nothing installed"
printf '%s %s\n' "$SIGN_NAMESPACE" "$PUBKEY" >"$dir/allowed"
ssh-keygen -Y verify -f "$dir/allowed" -I "$SIGN_NAMESPACE" -n "$SIGN_NAMESPACE" -s "$dir/SHA256SUMS.sig" <"$dir/SHA256SUMS" >/dev/null 2>&1 ||
die "SHA256SUMS is not signed by the release key — nothing installed"
note "signature good (release key)"
}
# No release in hand: fetch one, check it, and hand over to the installer inside it.
from_release() {
local tag version base tarball top listed
need curl
need tar
if [ -n "$VERSION_WANTED" ]; then
tag="v${VERSION_WANTED#v}"
elif [ "$DRY" = 1 ]; then
say "LLeMbas IDE (dry run: nothing is downloaded or written)"
step "ask $(api_base)/repos/$SLUG/releases for the newest $CHANNEL release"
step "download its llembas-ide-<version>.tar.gz and SHA256SUMS, and check the one against the other"
step "unpack it in a temporary directory and run the installer inside it with the same options"
note "what that installer does is listed by: ide/install.sh --from-checkout --dry-run"
return 0
else
tag="$(newest_tag)" || die "could not list the releases at $FORGE/$SLUG (network, or a rate limit) — nothing installed"
if [ -z "$tag" ]; then
[ "$CHANNEL" = stable ] && die "there is no stable release of LLeMbas IDE yet — nothing installed. The betas: add --channel beta"
die "there is no release at $FORGE/$SLUG — nothing installed"
fi
fi
version="${tag#v}"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-beta\.[0-9]+)?$ ]] || die "not a version: $version"
base="${LLEMBAS_IDE_RELEASE_BASE:-$FORGE/$SLUG/releases/download}"
base="${base%/}/$tag"
tarball="llembas-ide-$version.tar.gz"
if [ "$DRY" = 1 ]; then
say "LLeMbas IDE $version (dry run: nothing is downloaded or written)"
step "download $base/$tarball and $base/SHA256SUMS, and check the one against the other"
step "unpack it in a temporary directory and run the installer inside it with the same options"
note "what that installer does is listed by: ide/install.sh --from-checkout --dry-run"
return 0
fi
TMP="$(mktemp -d)"
say "LLeMbas IDE $version"
note "downloading $tarball"
fetch "$base/$tarball" "$TMP/$tarball" || die "could not download $tarball from release $tag — nothing installed"
fetch "$base/SHA256SUMS" "$TMP/SHA256SUMS" || die "could not download SHA256SUMS from release $tag — nothing installed"
if [ -n "$PUBKEY" ]; then fetch "$base/SHA256SUMS.sig" "$TMP/SHA256SUMS.sig" 2>/dev/null || rm -f "$TMP/SHA256SUMS.sig"; fi
check_signature "$TMP"
listed="$(awk -v f="$tarball" '$2 == f || $2 == "*" f { print $1 }' "$TMP/SHA256SUMS")"
[ "$(printf '%s\n' "$listed" | sed '/^$/d' | wc -l | tr -d ' ')" = 1 ] || die "SHA256SUMS does not list $tarball exactly once — nothing installed"
[ "$listed" = "$(sha256_of "$TMP/$tarball")" ] || die "$tarball does not match SHA256SUMS — nothing installed"
note "checksum good"
# Nothing in the archive may land outside the directory it is unpacked into.
top="llembas-ide-$version"
if tar -tzf "$TMP/$tarball" | grep -v -E "^$top(/|\$)" | grep -q .; then die "$tarball holds files outside $top/ — nothing installed"; fi
if tar -tzf "$TMP/$tarball" | grep -q -E '(^|/)\.\.(/|$)'; then die "$tarball holds a path with .. — nothing installed"; fi
mkdir "$TMP/payload"
tar -xzf "$TMP/$tarball" -C "$TMP/payload"
[ "$(tr -d '[:space:]' <"$TMP/payload/$top/VERSION")" = "$version" ] || die "release $tag carries the files of another version — nothing installed"
[ -f "$TMP/payload/$top/ide/install.sh" ] || die "release $tag has no installer in it — nothing installed"
local args=(--from-dir "$TMP/payload/$top")
[ -z "$PREFIX" ] || args+=(--prefix "$PREFIX")
[ -z "$NVIM_BIN" ] || args+=(--nvim-bin "$NVIM_BIN")
[ "$WITH_CLI" = 1 ] || args+=(--no-cli)
[ "$WITH_PARSERS" = 1 ] || args+=(--no-parsers)
[ "$YES" = 0 ] || args+=(--yes)
bash "$TMP/payload/$top/ide/install.sh" "${args[@]}"
}
# --- the parts ---------------------------------------------------------------------------------
nvim_asset() {
case "$(uname -s)-$(uname -m)" in
Linux-x86_64) echo nvim-linux-x86_64 ;;
Linux-aarch64 | Linux-arm64) echo nvim-linux-arm64 ;;
Darwin-arm64) echo nvim-macos-arm64 ;;
Darwin-x86_64) echo nvim-macos-x86_64 ;;
*) return 1 ;;
esac
}
# "NVIM v0.10.4" is at least MIN_NVIM.
nvim_new_enough() {
local v major minor
v="$(nvim_quiet "$1" --version 2>/dev/null | sed -n '1s/^NVIM v\([0-9][0-9.]*\).*/\1/p')"
[ -n "$v" ] || return 1
major="${v%%.*}"
minor="${v#*.}"
minor="${minor%%.*}"
[ "$major" -gt "${MIN_NVIM%%.*}" ] || { [ "$major" -eq "${MIN_NVIM%%.*}" ] && [ "$minor" -ge "${MIN_NVIM#*.}" ]; }
}
# A git repository at exactly one commit: fetched by its hash, and the hash is the check.
fetch_commit() {
local url="$1" commit="$2" dest="$3" from="$1" mirror="${LLEMBAS_IDE_GIT_MIRROR:-}"
if [ -n "$mirror" ] && [ -d "$mirror/$(basename "$url")" ]; then from="$mirror/$(basename "$url")"; fi
mkdir -p "$dest"
git_quiet -C "$dest" init -q
git_quiet -C "$dest" remote add origin "$url"
git_quiet -C "$dest" fetch -q --depth 1 "$from" "$commit" 2>/dev/null ||
die "could not fetch $url at $commit (network?) — nothing installed"
git_quiet -C "$dest" -c advice.detachedHead=false checkout -q --detach FETCH_HEAD
[ "$(git_quiet -C "$dest" rev-parse HEAD)" = "$commit" ] || die "$url did not give commit $commit — nothing installed"
}
# An installed plugin is at its pin and nobody changed its files.
at_pin() {
local dir="$1" commit="$2"
[ -d "$dir/.git" ] || return 1
[ "$(git_quiet -C "$dir" rev-parse HEAD 2>/dev/null)" = "$commit" ] || return 1
[ -z "$(git_quiet -C "$dir" status --porcelain --untracked-files=no 2>/dev/null)" ]
}
stage_neovim() {
local src="$1" version asset want got dir="$STAGE/nvim"
if [ -n "$NVIM_BIN" ]; then
step "use the Neovim at $NVIM_BIN instead of the pinned release"
[ "$DRY" = 1 ] && return 0
printf '%s\n' "$NVIM_BIN" >"$STAGE/lib/nvim-path"
printf 'own %s\n' "$NVIM_BIN" >"$STAGE/lib/nvim-source"
return 0
fi
version="$(tr -d '[:space:]' <"$src/ide/neovim.version")"
asset="$(nvim_asset)" || die "there is no Neovim release build for $(uname -s) $(uname -m); install Neovim $MIN_NVIM or newer yourself and pass --nvim-bin <path>"
want="$(awk -v f="$asset.tar.gz" '$2 == f { print $1 }' "$src/ide/neovim.sha256")"
[ -n "$want" ] || die "ide/neovim.sha256 has no checksum for $asset.tar.gz"
if [ -f "$PREFIX/lib/nvim-source" ] && [ "$(cat "$PREFIX/lib/nvim-source")" = "release $version $want" ] && [ -x "$PREFIX/nvim/bin/nvim" ]; then
step "keep Neovim $version (already installed, checksum $want)"
[ "$DRY" = 1 ] && return 0
cp -a "$PREFIX/nvim" "$dir"
else
step "download $NVIM_RELEASES/v$version/$asset.tar.gz"
step "check its SHA-256 is $want, and unpack it to $PREFIX/nvim"
[ "$DRY" = 1 ] && return 0
fetch "$NVIM_RELEASES/v$version/$asset.tar.gz" "$TMP/$asset.tar.gz" || die "could not download Neovim $version — nothing installed"
got="$(sha256_of "$TMP/$asset.tar.gz")"
[ "$got" = "$want" ] || die "Neovim $version's download has SHA-256 $got, not the pinned $want — nothing installed"
if tar -tzf "$TMP/$asset.tar.gz" | grep -v -E "^$asset(/|\$)" | grep -q .; then die "the Neovim archive holds files outside $asset/ — nothing installed"; fi
mkdir "$TMP/nvim"
tar -xzf "$TMP/$asset.tar.gz" -C "$TMP/nvim"
mv "$TMP/nvim/$asset" "$dir"
fi
printf '%s\n' "$PREFIX/nvim/bin/nvim" >"$STAGE/lib/nvim-path"
printf 'release %s %s\n' "$version" "$want" >"$STAGE/lib/nvim-source"
}
stage_plugins() {
local src="$1" name where url commit licence rest dest have
while read -r name where url commit licence rest; do
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || die "ide/plugins.lock: $name is not pinned to a full commit"
case "$url" in https://*) ;; *) die "ide/plugins.lock: $name does not come over https" ;; esac
case "$where" in start | opt) ;; *) die "ide/plugins.lock: $name is neither start nor opt" ;; esac
dest="$STAGE/site/pack/llembas/$where/$name"
have="$PREFIX/site/pack/llembas/$where/$name"
if at_pin "$have" "$commit"; then
step "keep $name at $commit (already installed, unchanged)"
[ "$DRY" = 1 ] || { mkdir -p "$(dirname "$dest")" && cp -a "$have" "$dest"; }
else
step "fetch $name from $url at commit $commit ($licence)"
[ "$DRY" = 1 ] || fetch_commit "$url" "$commit" "$dest"
fi
done < <(lock_lines "$src/ide/plugins.lock")
}
stage_own() {
local src="$1" dest="$STAGE/site/pack/llembas/start/llembas-ide"
step "place the IDE's configuration (ide/config) as the package llembas-ide"
step "place the LLeMbas plugin (nvim/) $(tr -d '[:space:]' <"$src/VERSION")"
[ "$DRY" = 1 ] && return 0
mkdir -p "$dest" "$STAGE/lib/llembas"
cp -R "$src/ide/config/lua" "$src/ide/config/colors" "$dest/"
[ -f "$src/nvim/plugin/llembas.lua" ] || die "the LLeMbas plugin (nvim/) is not in $src — nothing installed"
cp -R "$src/nvim" "$STAGE/lib/llembas/nvim"
rm -rf "$STAGE/lib/llembas/nvim/tests"
# The plugin reads its version from the VERSION file beside its directory.
cp "$src/VERSION" "$STAGE/lib/llembas/VERSION"
cp "$src/VERSION" "$STAGE/lib/VERSION"
mkdir -p "$STAGE/lib/ide"
cp "$src/ide/install.sh" "$src/ide/plugins.lock" "$src/ide/parsers.lock" "$src/ide/neovim.version" \
"$src/ide/neovim.sha256" "$src/ide/user-init.lua" "$src/ide/THIRD_PARTY.md" "$STAGE/lib/ide/"
cp -R "$src/ide/bin" "$src/ide/assets" "$src/ide/config" "$STAGE/lib/ide/"
[ ! -f "$src/LICENSE" ] || cp "$src/LICENSE" "$STAGE/lib/LICENSE"
}
c_compiler() {
local c
for c in cc gcc clang; do
if command -v "$c" >/dev/null 2>&1; then
echo "$c"
return 0
fi
done
return 1
}
# The Treesitter grammars, all or none: a half set would colour some files by one rule and some
# by another. Without them the IDE uses the grammars Neovim itself carries.
stage_parsers() {
local src="$1" cc lang url commit dir licence rest sources out have="$PREFIX/site/pack/llembas/start/llembas-parsers"
local dest="$STAGE/site/pack/llembas/start/llembas-parsers" shared="-shared" count
count="$(lock_lines "$src/ide/parsers.lock" | wc -l | tr -d ' ')"
if [ "$WITH_PARSERS" != 1 ]; then
step "leave the Treesitter grammars out (--no-parsers): Neovim's bundled ones are used"
return 0
fi
if ! cc="$(c_compiler)"; then
step "leave the Treesitter grammars out: no C compiler here (cc, gcc or clang). Neovim's bundled ones are used; install a compiler and run this again for all $count"
return 0
fi
if [ -f "$PREFIX/lib/ide/parsers.lock" ] && cmp -s "$PREFIX/lib/ide/parsers.lock" "$src/ide/parsers.lock" &&
[ "$(find "$have/parser" -name '*.so' 2>/dev/null | wc -l | tr -d ' ')" = "$count" ]; then
step "keep the $count compiled Treesitter grammars (already installed, same pins)"
[ "$DRY" = 1 ] || { mkdir -p "$(dirname "$dest")" && cp -a "$have" "$dest"; }
return 0
fi
[ "$(uname -s)" != Darwin ] || shared="-bundle"
if [ "$DRY" = 1 ]; then
while read -r lang url commit dir licence rest; do
step "fetch the $lang grammar from $url at commit $commit ($licence) and compile it with $cc"
done < <(lock_lines "$src/ide/parsers.lock")
return 0
fi
note "compiling $count Treesitter grammars with $cc (a minute or two)"
mkdir -p "$dest/parser" "$TMP/grammars"
while read -r lang url commit dir licence rest; do
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || die "ide/parsers.lock: $lang is not pinned to a full commit"
case "$url" in https://*) ;; *) die "ide/parsers.lock: $lang does not come over https" ;; esac
[ -d "$TMP/grammars/$commit" ] || fetch_commit "$url" "$commit" "$TMP/grammars/$commit"
out="$TMP/grammars/$commit/$dir/src"
sources=("$out/parser.c")
[ ! -f "$out/scanner.c" ] || sources+=("$out/scanner.c")
if [ ! -f "$out/parser.c" ] || [ -f "$out/scanner.cc" ] ||
! "$cc" -o "$dest/parser/$lang.so" -I "$out" "${sources[@]}" -Os -fPIC "$shared" 2>"$TMP/cc.log"; then
warn "the $lang grammar did not compile with $cc ($(head -n1 "$TMP/cc.log" 2>/dev/null)); the IDE is installed without compiled grammars and uses Neovim's bundled ones."
rm -rf "$dest"
return 0
fi
done < <(lock_lines "$src/ide/parsers.lock")
step "compiled $count Treesitter grammars"
}
# Help tags for every plugin that has documentation and no tags yet, so :help finds them.
stage_helptags() {
local nvim="$1" d
[ "$DRY" = 1 ] && return 0
for d in "$STAGE"/site/pack/llembas/*/*/doc "$STAGE/lib/llembas/nvim/doc"; do
if [ ! -d "$d" ] || [ -f "$d/tags" ]; then continue; fi
nvim_quiet "$nvim" --headless -u NONE -i NONE -c "silent! helptags $d" -c qa >/dev/null 2>&1 || true
done
}
# The whole thing started once where it was built, away from the person's own files: a
# configuration that does not start is never swapped in.
try_staged() {
local src="$1" nvim="$2" out
step "start the staged IDE once, headless, to see that every part loads"
[ "$DRY" = 1 ] && return 0
mkdir -p "$TMP/try/config/$APP" "$TMP/try/state" "$TMP/try/cache" "$TMP/try/data"
cp "$src/ide/config/init.lua" "$TMP/try/config/$APP/init.lua"
out="$(XDG_CONFIG_HOME="$TMP/try/config" XDG_STATE_HOME="$TMP/try/state" XDG_CACHE_HOME="$TMP/try/cache" XDG_DATA_HOME="$TMP/try/data" \
NVIM_LOG_FILE="$TMP/nvim.log" NVIM_APPNAME="$APP" LLEMBAS_IDE_PREFIX="$STAGE" "$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)" || die "the staged IDE did not start ($out) — nothing installed"
case "$out" in
*"problems=0"*) ;;
*) die "the staged IDE did not start cleanly (${out#*problems=}) — nothing installed" ;;
esac
}
# Put one of the three managed directories in place, keeping the old one until the end.
swap_unit() {
local unit="$1"
[ -e "$STAGE/$unit" ] || {
# Nothing staged (no Neovim of our own with --nvim-bin): the old one still goes.
if [ -e "$PREFIX/$unit" ]; then
mkdir -p "$(dirname "$OLD/$unit")"
mv "$PREFIX/$unit" "$OLD/$unit"
SWAPPED+=("$unit")
fi
return 0
}
mkdir -p "$(dirname "$OLD/$unit")" "$(dirname "$PREFIX/$unit")"
SWAPPED+=("$unit")
if [ -e "$PREFIX/$unit" ]; then mv "$PREFIX/$unit" "$OLD/$unit"; fi
mv "$STAGE/$unit" "$PREFIX/$unit"
}
# Put one file in place outside the prefix, keeping what was there until the end.
place_file() {
local from="$1" to="$2" mode="$3" n="${#PLACED[@]}"
mkdir -p "$(dirname "$to")" "$OLD/files"
PLACED+=("$to")
if [ -e "$to" ] || [ -L "$to" ]; then mv "$to" "$OLD/files/$n"; fi
cp "$from" "$to.tmp.$$"
chmod "$mode" "$to.tmp.$$"
mv "$to.tmp.$$" "$to"
}
install_cli() {
local channel=stable version="$1"
[ "$WITH_CLI" = 1 ] || return 0
if command -v lembas >/dev/null 2>&1 || [ -x "$HOME/.local/bin/lembas" ]; then
step "leave the LLeMbas CLI alone: it is installed ($(command -v lembas 2>/dev/null || echo "$HOME/.local/bin/lembas"))"
return 0
fi
# A beta of the IDE goes with a beta of the CLI.
case "$version" in *-beta.*) channel=beta ;; esac
if [ "$(uname -s)" != Linux ]; then
step "leave the LLeMbas CLI out: its installer is for Linux. See https://github.com/LLeMbas/LLeMbas-CLI"
return 0
fi
if [ "$DRY" = 1 ]; then
step "offer to install the LLeMbas CLI ($channel) with its own installer: $CLI_GET (it checks the release's signature itself)"
return 0
fi
say ""
say "The LLeMbas CLI (the lembas command) is the agent the IDE talks to, and it is not installed."
if ! ask_yes "Install it now with its own installer?"; then
note "not installed. Later: curl -fsSL $CLI_GET | LEMBAS_CHANNEL=$channel bash"
return 0
fi
# Its own installer, whole, then run: it checks the CLI's release signature itself.
if ! fetch "$CLI_GET" "$TMP/get.sh"; then
warn "could not download the CLI's installer; the IDE is installed and works as an editor. Later: curl -fsSL $CLI_GET | LEMBAS_CHANNEL=$channel bash"
return 0
fi
if [ "$YES" = 1 ] || ! has_tty; then
LEMBAS_CHANNEL="$channel" bash "$TMP/get.sh" --yes || warn "the CLI's installer failed; the IDE itself is installed."
else
LEMBAS_CHANNEL="$channel" bash "$TMP/get.sh" </dev/tty || warn "the CLI's installer failed; the IDE itself is installed."
fi
}
# --- the installation --------------------------------------------------------------------------
install_from() {
local src="$1" version config bin data desktop icon nvim old_init_sha="" init_state launcher
if [ ! -f "$src/VERSION" ] || [ ! -f "$src/ide/plugins.lock" ] || [ ! -d "$src/ide/config" ] || [ ! -d "$src/nvim" ]; then
die "$src is not LLeMbas IDE (it needs VERSION, ide/ and nvim/)"
fi
version="$(tr -d '[:space:]' <"$src/VERSION")"
data="${XDG_DATA_HOME:-$HOME/.local/share}"
config="${XDG_CONFIG_HOME:-$HOME/.config}/$APP"
bin="$HOME/.local/bin"
[ -n "$PREFIX" ] || PREFIX="$data/$APP"
case "$PREFIX" in /*) ;; *) die "--prefix must be an absolute path" ;; esac
PREFIX="${PREFIX%/}"
case "$PREFIX" in /*/*) ;; *) die "--prefix must be a directory of the IDE's own, not $PREFIX" ;; esac
[ "$PREFIX" != "${HOME%/}" ] || die "--prefix must be a directory of the IDE's own, not your home directory"
launcher="$bin/$APP"
desktop="$data/applications/$APP.desktop"
icon="$data/icons/hicolor/256x256/apps/$APP.png"
need git "the plugins are fetched with it"
need tar
[ -n "$NVIM_BIN" ] || need curl
if [ -n "$NVIM_BIN" ]; then
case "$NVIM_BIN" in /*) ;; *) die "--nvim-bin must be an absolute path" ;; esac
[ -x "$NVIM_BIN" ] || die "--nvim-bin $NVIM_BIN is not a program"
nvim_new_enough "$NVIM_BIN" || die "$NVIM_BIN is older than Neovim $MIN_NVIM, the oldest the IDE runs on"
else
nvim_asset >/dev/null || die "there is no Neovim release build for $(uname -s) $(uname -m); install Neovim $MIN_NVIM or newer yourself and pass --nvim-bin <path>"
fi
[ ! -f "$PREFIX/lib/installed" ] || old_init_sha="$(sed -n 's/^init_sha=//p' "$PREFIX/lib/installed")"
if [ "$DRY" = 1 ]; then
say "LLeMbas IDE $version (dry run: nothing is downloaded or written)"
else
say "LLeMbas IDE $version"
mkdir -p "$PREFIX"
TMP="$(mktemp -d)"
STAGE="$(mktemp -d "$PREFIX/.staging.XXXXXX")"
mkdir -p "$STAGE/lib" "$STAGE/site/pack/llembas"
fi
step "build everything in a staging directory inside $PREFIX"
stage_neovim "$src"
stage_plugins "$src"
stage_own "$src"
stage_parsers "$src"
if [ "$DRY" != 1 ]; then
if [ -n "$NVIM_BIN" ]; then nvim="$NVIM_BIN"; else nvim="$STAGE/nvim/bin/nvim"; fi
nvim_quiet "$nvim" --version >/dev/null 2>&1 || die "the Neovim at $nvim does not run on this machine — nothing installed"
stage_helptags "$nvim"
fi
try_staged "$src" "${nvim:-}"
step "swap the staged nvim/, site/pack/llembas/ and lib/ into $PREFIX"
if [ -f "$config/init.lua" ] && [ "$(sha256_of "$config/init.lua")" != "$(sha256_of "$src/ide/config/init.lua")" ] &&
[ "$(sha256_of "$config/init.lua")" != "$old_init_sha" ]; then
init_state=edited
step "keep your edited $config/init.lua; the IDE's own goes beside it as init.lua.new"
else
init_state=ours
step "write $config/init.lua"
fi
if [ -f "$config/lua/user/init.lua" ]; then
step "keep your $config/lua/user/init.lua as it is"
else
step "create $config/lua/user/init.lua, yours: comments only"
fi
step "write the launcher $launcher"
if [ "$(uname -s)" = Linux ]; then
step "write the menu entry $desktop and its icon $icon"
fi
if [ "$DRY" = 1 ]; then
install_cli "$version"
say "Dry run: nothing was changed."
return 0
fi
{
printf 'version=%s\n' "$version"
printf 'config=%s\n' "$config"
printf 'launcher=%s\n' "$launcher"
printf 'init_sha=%s\n' "$(sha256_of "$src/ide/config/init.lua")"
printf 'user_sha=%s\n' "$(sha256_of "$src/ide/user-init.lua")"
if [ "$(uname -s)" = Linux ]; then
printf 'desktop=%s\n' "$desktop"
printf 'icon=%s\n' "$icon"
fi
} >"$STAGE/lib/installed"
OLD="$(mktemp -d "$PREFIX/.old.XXXXXX")"
swap_unit nvim
swap_unit site/pack/llembas
swap_unit lib
if [ "$init_state" = edited ]; then
place_file "$src/ide/config/init.lua" "$config/init.lua.new" 644
else
place_file "$src/ide/config/init.lua" "$config/init.lua" 644
fi
if [ ! -f "$config/lua/user/init.lua" ]; then
place_file "$src/ide/user-init.lua" "$config/lua/user/init.lua" 644
fi
sed "s|^PREFIX=.*# set by install.sh\$|PREFIX='$(printf '%s' "$PREFIX" | sed "s/'/'\\\\\\\\''/g; s/[|&]/\\\\&/g")' # set by install.sh|" \
"$src/ide/bin/llembas-ide" >"$TMP/launcher"
grep -q "^PREFIX='" "$TMP/launcher" || die "the launcher could not be written — nothing installed"
place_file "$TMP/launcher" "$launcher" 755
if [ "$(uname -s)" = Linux ]; then
{
printf '[Desktop Entry]\nType=Application\nName=LLeMbas IDE\nGenericName=Text Editor\n'
printf 'Comment=A complete Neovim editor with LLeMbas built in\n'
printf 'Exec=%s %%F\nTryExec=%s\nIcon=%s\nTerminal=true\n' "$launcher" "$launcher" "$APP"
printf 'Categories=Development;TextEditor;IDE;\nKeywords=editor;code;neovim;llembas;\n'
printf 'MimeType=text/plain;\nStartupNotify=false\n'
} >"$TMP/desktop"
place_file "$TMP/desktop" "$desktop" 644
place_file "$src/ide/assets/llembas-ide.png" "$icon" 644
fi
"$launcher" --version >/dev/null 2>&1 || die "the launcher does not run — nothing installed"
DONE=1
say ""
say "LLeMbas IDE $version is installed. Start it with: $APP"
case ":$PATH:" in
*":$bin:"*) ;;
*) note "$bin is not on your PATH: add it (export PATH=\"\$HOME/.local/bin:\$PATH\"), or run $launcher" ;;
esac
[ "$init_state" != edited ] || note "your edited init.lua was kept; compare it with init.lua.new. Your own settings are safer in lua/user/init.lua"
note "check it any time: $APP doctor update: $APP update remove: $APP uninstall"
install_cli "$version"
}
main() {
trap cleanup EXIT
while [ $# -gt 0 ]; do
case "$1" in
--version) VERSION_WANTED="${2:?--version needs a version}" && shift ;;
--channel) CHANNEL="${2:?--channel needs stable or beta}" && shift ;;
--prefix) PREFIX="${2:?--prefix needs a directory}" && shift ;;
--from-checkout) FROM_CHECKOUT=1 ;;
--from-dir) FROM_DIR="${2:?--from-dir needs a directory}" && shift ;;
--nvim-bin) NVIM_BIN="${2:?--nvim-bin needs a path}" && shift ;;
--no-cli) WITH_CLI=0 ;;
--no-parsers) WITH_PARSERS=0 ;;
--yes | -y) YES=1 ;;
--dry-run) DRY=1 ;;
-h | --help)
usage
return 0
;;
*) die "unknown option $1 (--help lists them)" ;;
esac
shift
done
case "$CHANNEL" in stable | beta) ;; *) die "--channel is stable or beta" ;; esac
if [ -z "${HOME:-}" ] || [ ! -d "$HOME" ]; then die "HOME is not set to a directory"; fi
[ "$(id -u)" != 0 ] || warn "running as root: LLeMbas IDE is installed for one user and needs no root."
if [ -n "$FROM_DIR" ]; then
install_from "$(cd "$FROM_DIR" && pwd)"
elif [ "$FROM_CHECKOUT" = 1 ]; then
[ -f "${BASH_SOURCE[0]:-}" ] || die "--from-checkout needs this script run as a file inside a clone of the repository"
install_from "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
else
from_release
fi
}
main "$@"
+6
View File
@@ -0,0 +1,6 @@
# SHA-256 of the official Neovim release tarballs for the version in neovim.version, as published
# with the release at https://github.com/neovim/neovim/releases. install.sh refuses anything else.
bb488a65a18b75c4bf35f128ac91b962eab845ba0e89685f33609b70f6090a12 nvim-linux-x86_64.tar.gz
30a7b798b35426f6d3197c6b780f6f3860125c14f8cc12d10df1d43e60aee4eb nvim-linux-arm64.tar.gz
465d836c7a5bf950f026c4f2debc4764f5699a26e56f431da098bcbbfeab2c70 nvim-macos-arm64.tar.gz
1a50e1483158dd5a12e7ebdbdef194848950e25589e948ddfa00ec02fd49c7b5 nvim-macos-x86_64.tar.gz
+1
View File
@@ -0,0 +1 @@
0.12.7
+23
View File
@@ -0,0 +1,23 @@
# The Treesitter grammars compiled at install when a C compiler is there, each at exactly one
# commit: the revisions nvim-treesitter's own lockfile.json names at the commit in plugins.lock,
# so the grammars and its queries belong together. All of them or none.
# language url commit directory licence
bash https://github.com/tree-sitter/tree-sitter-bash 0c46d792d54c536be5ff7eb18eb95c70fccdb232 . MIT
c https://github.com/tree-sitter/tree-sitter-c 2a265d69a4caf57108a73ad2ed1e6922dd2f998c . MIT
css https://github.com/tree-sitter/tree-sitter-css 6e327db434fec0ee90f006697782e43ec855adf5 . MIT
go https://github.com/tree-sitter/tree-sitter-go 5e73f476efafe5c768eda19bbe877f188ded6144 . MIT
html https://github.com/tree-sitter/tree-sitter-html cbb91a0ff3621245e890d1c50cc811bffb77a26b . MIT
javascript https://github.com/tree-sitter/tree-sitter-javascript 6fbef40512dcd9f0a61ce03a4c9ae7597b36ab5c . MIT
json https://github.com/tree-sitter/tree-sitter-json 46aa487b3ade14b7b05ef92507fdaa3915a662a3 . MIT
lua https://github.com/MunifTanjim/tree-sitter-lua db16e76558122e834ee214c8dc755b4a3edc82a9 . MIT
markdown https://github.com/MDeiml/tree-sitter-markdown 413285231ce8fa8b11e7074bbe265b48aa7277f9 tree-sitter-markdown MIT
markdown_inline https://github.com/MDeiml/tree-sitter-markdown 413285231ce8fa8b11e7074bbe265b48aa7277f9 tree-sitter-markdown-inline MIT
python https://github.com/tree-sitter/tree-sitter-python 710796b8b877a970297106e5bbc8e2afa47f86ec . MIT
query https://github.com/nvim-treesitter/tree-sitter-query 930202c2a80965a7a9ca018b5b2a08b25dfa7f12 . Apache-2.0
rust https://github.com/tree-sitter/tree-sitter-rust e86119bdb4968b9799f6a014ca2401c178d54b5f . MIT
toml https://github.com/tree-sitter-grammars/tree-sitter-toml 64b56832c2cffe41758f28e05c756a3a98d16f41 . MIT
tsx https://github.com/tree-sitter/tree-sitter-typescript 75b3874edb2dc714fb1fd77a32013d0f8699989f tsx MIT
typescript https://github.com/tree-sitter/tree-sitter-typescript 75b3874edb2dc714fb1fd77a32013d0f8699989f typescript MIT
vim https://github.com/neovim/tree-sitter-vim 11b688a1f0e97c0c4e3dbabf4a38016335f4d237 . MIT
vimdoc https://github.com/neovim/tree-sitter-vimdoc 2694c3d27e2ca98a0ccde72f33887394300d524e . Apache-2.0
yaml https://github.com/tree-sitter-grammars/tree-sitter-yaml 1805917414a9a8ba2473717fd69447277a175fae . MIT
+8
View File
@@ -0,0 +1,8 @@
# The third-party plugins of LLeMbas IDE, each at exactly one commit. install.sh fetches that
# commit with git and refuses anything else; nothing here is ever updated by the installed IDE.
# name where(start|opt) url commit licence version
mini.nvim start https://github.com/nvim-mini/mini.nvim 1345d191bb3da9c7b0e977f4387c5761f9bff68d MIT v0.18.0
blink.cmp start https://github.com/Saghen/blink.cmp 78336bc89ee5365633bcf754d93df01678b5c08f MIT v1.10.2
conform.nvim start https://github.com/stevearc/conform.nvim 3543d000dafbc41cc7761d860cfdb24e82154f75 MIT v9.1.0
nvim-lspconfig start https://github.com/neovim/nvim-lspconfig 4648fd8ba5c678d7e2db75ae44ffac269bb589d8 Apache-2.0 v2.13.0
nvim-treesitter opt https://github.com/nvim-treesitter/nvim-treesitter cf12346a3414fa1b06af75c79faebe7f76df080a Apache-2.0 master
+344
View File
@@ -0,0 +1,344 @@
-- The installed IDE, started headless through its own launcher, checked from the inside.
-- llembas-ide --headless -c "luafile ide/tests/headless.lua"
-- Environment: IDE_TEST_REPO (the repository), IDE_TEST_PARSERS (1 when the grammars were
-- compiled), IDE_TEST_BG_DARK / IDE_TEST_BG_LIGHT (the tokens' backgrounds, #RRGGBB),
-- IDE_TEST_FIRST (1 on the first start in a new home), IDE_TEST_USER (1 when lua/user/init.lua was given a marker line).
local repo = assert(vim.env.IDE_TEST_REPO, "IDE_TEST_REPO")
local passed, failed = 0, {}
local function check(name, fn)
local ok, err = pcall(fn)
if ok then
passed = passed + 1
else
table.insert(failed, name .. ": " .. tostring(err))
end
end
local function eq(a, b, what)
if not vim.deep_equal(a, b) then error((what or "") .. " expected " .. vim.inspect(b) .. ", got " .. vim.inspect(a), 2) end
end
local function lock(path)
local rows = {}
for line in io.lines(path) do
if not line:match("^%s*#") and line:match("%S") then table.insert(rows, vim.split(vim.trim(line), "%s+")) end
end
return rows
end
local function run()
local ide = require("llembas_ide")
local prefix = ide.prefix
check("starts with no error message", function()
for _, line in ipairs(vim.split(vim.fn.execute("messages"), "\n")) do
assert(not line:match("^E%d+:") and not line:match("^Error") and not line:lower():match("deprecated"), line)
end
end)
check("every part of the IDE started", function() eq(ide.problems, {}) end)
check("the version is the repository's", function()
eq(ide.version, vim.trim(table.concat(vim.fn.readfile(repo .. "/VERSION"), "")))
end)
check("its own NVIM_APPNAME", function()
eq(vim.env.NVIM_APPNAME, "llembas-ide")
assert(vim.fn.stdpath("config"):match("/llembas%-ide$"), vim.fn.stdpath("config"))
end)
-- Plugins: each at its pin, and what Lua loads comes from that directory.
local modules = {
["mini.nvim"] = "mini.pick", ["blink.cmp"] = "blink.cmp", ["conform.nvim"] = "conform",
["nvim-lspconfig"] = "lspconfig", ["nvim-treesitter"] = "nvim-treesitter.query_predicates",
}
local compiled = vim.env.IDE_TEST_PARSERS == "1"
for _, p in ipairs(lock(repo .. "/ide/plugins.lock")) do
local name, where, commit = p[1], p[2], p[4]
local dir = prefix .. "/site/pack/llembas/" .. where .. "/" .. name
check("plugin " .. name .. " is at its pinned commit", function()
eq(vim.trim(vim.fn.system({ "git", "-C", dir, "rev-parse", "HEAD" })), commit)
eq(vim.trim(vim.fn.system({ "git", "-C", dir, "status", "--porcelain", "--untracked-files=no" })), "", "changed files:")
end)
if name ~= "nvim-treesitter" or compiled then
check("plugin " .. name .. " loads from its pinned directory", function()
local module = assert(modules[name], "no module known for " .. name)
require(module)
local file = vim.api.nvim_get_runtime_file("lua/" .. module:gsub("%.", "/") .. ".lua", false)[1]
or vim.api.nvim_get_runtime_file("lua/" .. module:gsub("%.", "/") .. "/init.lua", false)[1]
assert(file and vim.startswith(vim.fn.resolve(file), vim.fn.resolve(dir)), tostring(file) .. " is not under " .. dir)
end)
end
end
check("no plugin manager, and nothing that installs", function()
for _, c in ipairs({ "Lazy", "PackerSync", "Mason", "TSInstall", "TSUpdate" }) do
eq(vim.fn.exists(":" .. c), 0, c)
end
end)
-- The colourscheme.
check("the LLeMbas colourscheme is applied (dark: moria)", function()
eq(vim.g.colors_name, "llembas")
eq(vim.o.background, "dark")
eq(("#%06X"):format(vim.api.nvim_get_hl(0, { name = "Normal" }).bg), vim.env.IDE_TEST_BG_DARK:upper())
end)
check("light is shire, and dark comes back", function()
vim.o.background = "light"
eq(vim.g.colors_name, "llembas")
eq(("#%06X"):format(vim.api.nvim_get_hl(0, { name = "Normal" }).bg), vim.env.IDE_TEST_BG_LIGHT:upper())
vim.o.background = "dark"
eq(("#%06X"):format(vim.api.nvim_get_hl(0, { name = "Normal" }).bg), vim.env.IDE_TEST_BG_DARK:upper())
end)
check("the plugin's and the IDE's own groups are coloured by the theme", function()
for _, g in ipairs({ "LLeMbasBrand", "LLeMbasGhost", "LLeMbasIdeLeaf", "MiniStatuslineModeNormal", "DiagnosticError" }) do
assert(next(vim.api.nvim_get_hl(0, { name = g, link = false })) ~= nil, g .. " has no colours")
end
end)
-- The start screen.
check("the dashboard is the start screen and shows its lines", function()
eq(vim.bo.filetype, "llembas-ide-dashboard")
local text = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n")
assert(text:find("LLeMbas IDE " .. ide.version, 1, true), "no name and version")
assert(text:find("▄▄███████", 1, true), "no mark")
for _, a in ipairs(require("llembas_ide.dashboard").actions) do
assert(text:find(a[1] .. " " .. a[2], 1, true), "no line for " .. a[2])
assert(vim.fn.maparg(a[1], "n", false, true).buffer == 1, "no key " .. a[1])
end
if vim.env.IDE_TEST_FIRST == "1" then assert(text:find("Welcome.", 1, true), "no first-run welcome") end
assert(text:find("The editor works", 1, true), "no line saying the editor works without LLeMbas")
end)
check("the dashboard's block shares one left edge", function()
local edge
for _, l in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, false)) do
if l:match("^%s*%a %u") then
local at = #l:match("^%s*")
edge = edge or at
eq(at, edge, l)
end
end
assert(edge, "no action lines")
end)
check("the dashboard's block is 38 columns and no line is over 52", function()
local rows = require("llembas_ide.dashboard").content(false)
assert(#rows > 15)
for _, r in ipairs(rows) do assert(vim.fn.strdisplaywidth(r[1]) <= 52, r[1]) end
for _, r in ipairs(rows) do
if r[3] then assert(vim.fn.strdisplaywidth(r[1]) <= 38, r[1]) end
end
end)
check("the window title names the IDE", function()
assert(vim.o.title and vim.o.titlestring:find("LLeMbas IDE", 1, true))
end)
-- LLeMbas built in.
check("the LLeMbas plugin's commands exist", function()
for _, c in ipairs({ "LLeMbas", "LLeMbasAsk", "LLeMbasEdit", "LLeMbasExplain", "LLeMbasFix", "LLeMbasGenerate",
"LLeMbasAutocomplete", "LLeMbasMode", "LLeMbasModel", "LLeMbasSessions", "LLeMbasNew", "LLeMbasStatus" }) do
eq(vim.fn.exists(":" .. c), 2, c)
end
eq(require("llembas").version, ide.version, "plugin version")
end)
check("the IDE's own commands exist", function()
for _, c in ipairs({ "LLeMbasIdeKeys", "LLeMbasIdeHome", "LLeMbasIdeLsp", "LLeMbasIdeFormat", "LLeMbasIdeTerminal",
"LLeMbasIdeDiff", "LLeMbasIdeSignIn", "LLeMbasIdeVersion", "LLeMbasIdeConfig", "LLeMbasIdeProblems", "LLeMbasIdeDoctor" }) do
eq(vim.fn.exists(":" .. c), 2, c)
end
end)
check("nothing predefined: the plugin starts the CLI by name, with no server or model", function()
local c = require("llembas").config
eq(c.cmd, { "lembas", "serve", "--stdio" })
eq(c.model, nil)
eq(c.complete.model, nil)
end)
check("without the CLI: no suggestions asked for, and the statusline says so", function()
if vim.fn.executable("lembas") == 1 then return end
eq(require("llembas_ide.llembas").autocomplete_on(), false)
local text, live = require("llembas_ide.llembas").status()
eq({ text, live }, { "◈ no CLI", false })
end)
check("sign in shows the one command when the plugin has no :LLeMbasLogin", function()
if vim.fn.exists(":LLeMbasLogin") == 2 then return end
vim.cmd("LLeMbasIdeSignIn")
local text = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n")
assert(text:find("lembas login", 1, true) or text:find("LLeMbas-CLI", 1, true), text)
vim.cmd("close")
end)
-- Keys.
local keys = require("llembas_ide.keys")
check("the key map has no binding twice", function() eq(keys.duplicates(), {}) end)
check("every key of the map is mapped", function()
for _, k in ipairs(keys.map) do
for _, mode in ipairs(type(k[1]) == "table" and k[1] or { k[1] }) do
assert(vim.fn.maparg(k[2], mode) ~= "" or vim.fn.maparg(k[2], mode, false, true).callback, mode .. " " .. k[2])
end
end
end)
check("the leader is <Space>, and <Tab> in insert mode is left to LLeMbas", function()
eq(vim.g.mapleader, " ")
-- Neovim 0.11 and newer map <Tab> themselves (to move in a snippet); nothing of the menu's may be on it.
local tab = vim.fn.maparg("<Tab>", "i", false, true)
assert(not tostring(tab.rhs or tab.callback and debug.getinfo(tab.callback, "S").source or ""):find("blink"), vim.inspect(tab))
local menu = require("blink.cmp.config").keymap
eq(menu.preset, "none")
eq(menu["<Tab>"], nil, "the menu's <Tab>")
assert(menu["<C-y>"] and menu["<CR>"], "the menu's own keys")
end)
check("the README's cheat sheet is the key map", function()
local readme = table.concat(vim.fn.readfile(repo .. "/ide/README.md"), "\n")
local block = readme:match("<!%-%- keys:begin %-%->\n(.-)\n<!%-%- keys:end %-%->")
assert(block, "no keys block in ide/README.md")
eq(vim.trim(block), vim.trim(table.concat(keys.markdown(), "\n")))
end)
check(":LLeMbasIdeKeys, :LLeMbasIdeLsp and :LLeMbasIdeProblems open", function()
for _, c in ipairs({ "LLeMbasIdeKeys", "LLeMbasIdeLsp", "LLeMbasIdeProblems" }) do
vim.cmd(c)
eq(vim.bo.filetype, "llembas-ide-page", c)
assert(vim.api.nvim_buf_line_count(0) > 0)
vim.cmd("close")
end
end)
-- Safety and options.
check("modelines and per-directory configuration are off", function()
eq({ vim.o.modeline, vim.o.modelines, vim.o.exrc }, { false, 0, false })
end)
check("the everyday options", function()
eq({ vim.go.number, vim.o.mouse, vim.o.undofile, vim.o.splitright, vim.o.ignorecase, vim.o.smartcase },
{ true, "a", true, true, true, true })
assert(vim.o.clipboard:find("unnamedplus"), vim.o.clipboard)
end)
-- Bars.
check("the statusline and the tabline draw", function()
local s = vim.api.nvim_eval_statusline(require("mini.statusline").active(), {})
assert(#s.str > 0)
assert(vim.o.tabline:find("MiniTabline", 1, true), vim.o.tabline)
end)
-- Treesitter.
check("a Lua buffer is highlighted by Treesitter", function()
vim.cmd("enew")
vim.api.nvim_buf_set_lines(0, 0, -1, false, { "local x = 1", "return x" })
vim.bo.filetype = "lua"
assert(vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()], "no highlighter")
vim.cmd("bwipeout!")
end)
if compiled then
local ft_of = { bash = "sh", tsx = "typescriptreact", vimdoc = "help", markdown_inline = false }
for _, p in ipairs(lock(repo .. "/ide/parsers.lock")) do
local lang = p[1]
check("grammar " .. lang .. " loads and its queries fit it", function()
local ok, added = pcall(vim.treesitter.language.add, lang)
assert(ok and added ~= false, "the grammar does not load: " .. tostring(added))
for _, q in ipairs({ "highlights", "injections" }) do
local good, err = pcall(vim.treesitter.query.get, lang, q)
assert(good, q .. ": " .. tostring(err))
end
local file = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", false)[1]
assert(file and file:find("llembas%-parsers"), "not the compiled one: " .. tostring(file))
local ft = ft_of[lang] == nil and lang or ft_of[lang]
if ft then
vim.cmd("enew")
vim.bo.filetype = ft
assert(vim.treesitter.highlighter.active[vim.api.nvim_get_current_buf()], "no highlighter for filetype " .. ft)
vim.cmd("bwipeout!")
end
end)
end
check("a Python buffer parses and draws with the compiled grammar", function()
vim.cmd("enew")
vim.api.nvim_buf_set_lines(0, 0, -1, false, { "def f(a):", " return 'x' + str(a) # note" })
vim.bo.filetype = "python"
local parser = vim.treesitter.get_parser(0, "python")
parser:parse(true)
eq(parser:trees()[1]:root():type(), "module")
local caps = vim.treesitter.get_captures_at_pos(0, 0, 0)
assert(#caps > 0 and caps[1].capture:find("keyword"), vim.inspect(caps))
vim.cmd("bwipeout!")
end)
end
-- Completion, LSP, formatting: set up, and quiet when nothing is installed for them.
check("the completion menu is set up with the Lua matcher and never downloads", function()
local c = require("blink.cmp.config")
local function value(v) if type(v) == "function" then return v() end return v end
eq(c.fuzzy.implementation, "lua")
eq(value(c.fuzzy.prebuilt_binaries.download), false)
eq(value(c.sources.default), { "lsp", "path", "buffer" })
eq(value(c.completion.ghost_text.enabled), false)
eq(value(c.cmdline.enabled), false)
end)
check("language servers: only those found on PATH are enabled", function()
local lsp = require("llembas_ide.lsp")
for _, name in ipairs(lsp.enabled) do
local found = false
for _, s in ipairs(lsp.servers) do
if s[1] == name then found = vim.fn.executable(s[2]) == 1 end
end
assert(found, name .. " is enabled without its program")
end
end)
check("format on demand does not fail without a formatter", function()
vim.cmd("enew")
vim.bo.filetype = "text"
vim.cmd("silent LLeMbasIdeFormat")
vim.cmd("bwipeout!")
end)
-- Sessions.
check("a session is per directory and round-trips", function()
local sessions = require("llembas_ide.sessions")
local dir = vim.fn.tempname()
vim.fn.mkdir(dir, "p")
vim.fn.writefile({ "one" }, dir .. "/a.txt")
vim.cmd("cd " .. vim.fn.fnameescape(dir))
assert(sessions.name(dir) ~= sessions.name(dir .. "x"))
eq(sessions.exists(), false)
vim.cmd("edit a.txt")
assert(sessions.save(true), "not saved")
eq(sessions.exists(), true)
assert(vim.startswith(vim.fn.stdpath("state"), vim.env.XDG_STATE_HOME or "\0") or true)
vim.cmd("bwipeout!")
sessions.restore()
eq(vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":t"), "a.txt")
sessions.delete()
eq(sessions.exists(), false)
vim.cmd("bwipeout!")
vim.fn.delete(dir, "rf")
end)
check("a Session.vim in the working directory is not read", function()
eq(require("mini.sessions").config.file, "")
eq(require("mini.sessions").config.autoread, false)
end)
-- The terminal and the diff.
check("the terminal opens and closes", function()
local n = #vim.api.nvim_list_wins()
vim.cmd("LLeMbasIdeTerminal")
eq(#vim.api.nvim_list_wins(), n + 1)
eq(vim.bo.buftype, "terminal")
vim.cmd("stopinsert")
require("llembas_ide.terminal").toggle()
eq(#vim.api.nvim_list_wins(), n)
end)
-- The person's own file.
check("lua/user/init.lua exists, and is loaded last when it says something", function()
eq(vim.fn.filereadable(vim.fn.stdpath("config") .. "/lua/user/init.lua"), 1)
if vim.env.IDE_TEST_USER == "1" then eq(vim.g.llembas_ide_test_user, 42) end
end)
vim.g.llembas_ide_no_session = true
for _, f in ipairs(failed) do io.stdout:write("FAIL " .. f .. "\n") end
io.stdout:write(("ide-headless: %d passed, %d failed (Neovim %s, %s)\n"):format(passed, #failed, tostring(vim.version()),
compiled and "compiled grammars" or "bundled grammars"))
if #failed > 0 then vim.cmd("cquit 1") else vim.cmd("qa!") end
end
vim.schedule(function()
local ok, err = xpcall(run, debug.traceback)
if not ok then
io.stdout:write("ide-headless: the checks themselves failed: " .. tostring(err) .. "\n")
vim.cmd("cquit 2")
end
end)
+73
View File
@@ -0,0 +1,73 @@
/*
The colours of LLeMbas, as the LLeMbas server's tokens.css declares them: its two themes,
moria (dark) and shire (light). A copy of the colour declarations only; the server's file is
the source. scripts/gen-ide-theme.py turns this into the editor's colourscheme.
*/
:root[data-theme="moria"] {
--bg: #0B0D10;
--bg-sunken: #07090B;
--surface: #11151A;
--surface-raised: #171C22;
--surface-hover: #1D232B;
--surface-active: #232B34;
--border: #26303A;
--border-strong: #5C6976;
--ink: #E2E8EC;
--ink-muted: #A6B2BC;
--ink-faint: #808D98;
--ink-inverse: #07090B;
--accent: #8FD8E8;
--accent-hover: #B4E6F1;
--accent-ink: #061418;
--accent-soft: rgba(143, 216, 232, 0.12);
--selection: rgba(143, 216, 232, 0.32);
--leaf: #7EE081;
--leaf-hover: #A2EAA3;
--leaf-soft: rgba(126, 224, 129, 0.12);
--danger: #F0735F;
--danger-hover: #F4907F;
--danger-soft: rgba(240, 115, 95, 0.13);
--success: #5FD6B0;
--success-soft: rgba(95, 214, 176, 0.13);
--warning: #F0A840;
--warning-soft: rgba(240, 168, 64, 0.13);
--bubble-user: #161C23;
--bubble-assistant: transparent;
--code-bg: #07090B;
--code-border: #26303A;
}
:root[data-theme="shire"] {
--bg: #F1EAD6;
--bg-sunken: #E7DEC6;
--surface: #F8F3E5;
--surface-raised: #FCF9F0;
--surface-hover: #ECE4CF;
--surface-active: #E2D8BD;
--border: #CBBF9D;
--border-strong: #2A2E22;
--ink: #1F2418;
--ink-muted: #474D3B;
--ink-faint: #5E6250;
--ink-inverse: #F8F3E5;
--accent: #285F3C;
--accent-hover: #1F4D30;
--accent-ink: #F8F3E5;
--accent-soft: rgba(40, 95, 60, 0.1);
--selection: rgba(40, 95, 60, 0.24);
--leaf: #3D6B1C;
--leaf-hover: #2F5615;
--leaf-soft: rgba(61, 107, 28, 0.1);
--danger: #A3321F;
--danger-hover: #862818;
--danger-soft: rgba(163, 50, 31, 0.1);
--success: #2B6A55;
--success-soft: rgba(43, 106, 85, 0.1);
--warning: #7E5200;
--warning-soft: rgba(126, 82, 0, 0.1);
--bubble-user: #ECE4CF;
--bubble-assistant: transparent;
--code-bg: #F1EAD6;
--code-border: #CBBF9D;
}
+23
View File
@@ -0,0 +1,23 @@
-- Your own settings for LLeMbas IDE. This file is yours: an update never touches it.
-- It is loaded last, so anything set here wins. Open it from the IDE with <Space>iu.
--
-- Options:
-- vim.opt.relativenumber = true
-- vim.opt.wrap = true
-- vim.o.background = "light" -- the light theme (shire); "dark" is moria
--
-- Keys:
-- vim.keymap.set("n", "<Leader>W", "<Cmd>wall<CR>", { desc = "Save everything" })
--
-- LLeMbas (the plugin's own settings; see :help llembas-setup):
-- require("llembas").setup({ position = "bottom", complete = { auto = false } })
--
-- Icons, when your terminal's font is a Nerd Font:
-- require("mini.icons").setup({ style = "glyph" })
--
-- Another language server that is on your PATH (Neovim 0.11 or newer):
-- vim.lsp.enable("zls")
--
-- 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({})
+415
View File
@@ -0,0 +1,415 @@
#!/usr/bin/env python3
"""The colourscheme of LLeMbas IDE, generated from the family's design tokens.
scripts/gen-ide-theme.py writes ide/config/colors/llembas.lua
scripts/gen-ide-theme.py --check exits 1 when that file is not what the tokens give
scripts/gen-ide-theme.py --tokens FILE --out FILE
The tokens file is the LLeMbas server's tokens.css, or the copy of its colour declarations in
ide/tokens.css. Its two themes become the two halves of one colourscheme: `moria` when
'background' is dark, `shire` when it is light. Every colour the editor draws comes out of this
file's output; the configuration itself names highlight groups, never colours.
Standard library only.
"""
import argparse
import re
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
THEMES = {"dark": "moria", "light": "shire"}
NEEDED = [
"bg", "bg-sunken", "surface", "surface-raised", "surface-hover", "surface-active", "border",
"border-strong", "ink", "ink-muted", "ink-faint", "ink-inverse", "accent", "accent-hover",
"accent-ink", "accent-soft", "selection", "leaf", "leaf-hover", "leaf-soft", "danger",
"danger-soft", "success", "success-soft", "warning", "warning-soft",
]
def parse(css: str) -> dict:
"""{theme: {token: value}} for the theme blocks of a tokens file."""
out = {}
for match in re.finditer(r"([^{}]*)\{([^{}]*)\}", css):
names = re.findall(r'data-theme="([a-z0-9-]+)"', match.group(1))
if not names:
continue
decls = dict(re.findall(r"--([a-z0-9-]+):\s*([^;]+);", match.group(2)))
for name in names:
out.setdefault(name, {}).update({k: " ".join(v.split()) for k, v in decls.items()})
return out
def rgb(value: str):
value = value.strip()
m = re.fullmatch(r"#([0-9A-Fa-f]{6})", value)
if m:
h = m.group(1)
return tuple(int(h[i:i + 2], 16) for i in (0, 2, 4)), 1.0
m = re.fullmatch(r"rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([0-9.]+)\s*)?\)", value)
if m:
return (int(m.group(1)), int(m.group(2)), int(m.group(3))), float(m.group(4) or 1)
raise ValueError(f"not a colour this generator reads: {value!r}")
def mix(top, bottom, share):
"""`share` of top over bottom."""
return tuple(round(t * share + b * (1 - share)) for t, b in zip(top, bottom))
def hexa(c):
return "#{:02X}{:02X}{:02X}".format(*c)
def palette(tokens: dict) -> dict:
"""The tokens as opaque colours (a translucent one is laid over the background), plus the
few mixes an editor needs that a web page does not."""
missing = [n for n in NEEDED if n not in tokens]
if missing:
raise ValueError("the tokens file lacks: " + ", ".join(missing))
bg, _ = rgb(tokens["bg"])
p = {}
for name in NEEDED:
colour, alpha = rgb(tokens[name])
p[name.replace("-", "_")] = colour if alpha >= 1 else mix(colour, bg, alpha)
# What an editor needs between the tokens: all of them mixes of two tokens.
p["line"] = mix(p["surface_hover"], p["bg"], 0.55) # the cursor's line
p["ghost"] = mix(p["ink_faint"], p["bg"], 0.75) # text that is not there yet
p["guide"] = mix(p["border"], p["bg"], 0.7) # whitespace, indent guides
p["match"] = mix(p["warning"], p["bg"], 0.3) # a search match's background
p["add_bg"] = mix(p["leaf"], p["bg"], 0.16)
p["change_bg"] = mix(p["warning"], p["bg"], 0.14)
p["delete_bg"] = mix(p["danger"], p["bg"], 0.16)
p["text_bg"] = mix(p["warning"], p["bg"], 0.32)
return {k: hexa(v) for k, v in p.items()}
# group = (foreground, background, attributes) by palette name, or a link to another group.
# One table for both themes: the palettes differ, the roles do not.
GROUPS = [
# --- the editor ---
("Normal", "ink", "bg", ""),
("NormalNC", "ink", "bg", ""),
("NormalFloat", "ink", "surface", ""),
("FloatBorder", "border_strong", "surface", ""),
("FloatTitle", "leaf", "surface", "bold"),
("FloatFooter", "ink_faint", "surface", ""),
("Cursor", "bg", "ink", ""),
("CursorLine", None, "line", ""),
("CursorColumn", None, "line", ""),
("ColorColumn", None, "surface", ""),
("LineNr", "ink_faint", None, ""),
("CursorLineNr", "leaf", "line", "bold"),
("SignColumn", "ink_faint", "bg", ""),
("FoldColumn", "ink_faint", "bg", ""),
("Folded", "ink_muted", "surface", ""),
("WinSeparator", "border", None, ""),
("VertSplit", "border", None, ""),
("Visual", None, "selection", ""),
("VisualNOS", None, "selection", ""),
("Search", "ink", "match", ""),
("CurSearch", "ink_inverse", "warning", "bold"),
("IncSearch", "ink_inverse", "warning", "bold"),
("Substitute", "ink_inverse", "danger", ""),
("MatchParen", "accent", "surface_active", "bold"),
("NonText", "guide", None, ""),
("Whitespace", "guide", None, ""),
("SpecialKey", "guide", None, ""),
("EndOfBuffer", "bg", None, ""),
("Conceal", "ink_faint", None, ""),
("Directory", "accent", None, ""),
("Title", "leaf", None, "bold"),
("ErrorMsg", "danger", None, ""),
("WarningMsg", "warning", None, ""),
("MoreMsg", "accent", None, ""),
("ModeMsg", "ink_muted", None, ""),
("Question", "accent", None, ""),
("MsgArea", "ink", None, ""),
("MsgSeparator", "border", "bg", ""),
("QuickFixLine", None, "surface_active", "bold"),
("WildMenu", "accent_ink", "accent", ""),
("WinBar", "ink_muted", "bg", ""),
("WinBarNC", "ink_faint", "bg", ""),
("Pmenu", "ink", "surface_raised", ""),
("PmenuSel", "accent_ink", "accent", ""),
("PmenuKind", "ink_faint", "surface_raised", ""),
("PmenuExtra", "ink_faint", "surface_raised", ""),
("PmenuSbar", None, "surface_hover", ""),
("PmenuThumb", None, "border_strong", ""),
("PmenuMatch", "accent", None, "bold"),
("PmenuMatchSel", "accent_ink", None, "bold"),
("StatusLine", "ink", "surface_raised", ""),
("StatusLineNC", "ink_faint", "surface", ""),
("TabLine", "ink_muted", "surface", ""),
("TabLineSel", "ink", "bg", "bold"),
("TabLineFill", None, "bg_sunken", ""),
("SpellBad", None, None, "undercurl sp=danger"),
("SpellCap", None, None, "undercurl sp=warning"),
("SpellRare", None, None, "undercurl sp=accent"),
("SpellLocal", None, None, "undercurl sp=success"),
# --- syntax ---
("Comment", "ink_faint", None, "italic"),
("Constant", "warning", None, ""),
("String", "leaf", None, ""),
("Character", "leaf", None, ""),
("Number", "warning", None, ""),
("Boolean", "warning", None, ""),
("Float", "warning", None, ""),
("Identifier", "ink", None, ""),
("Function", "accent_hover", None, ""),
("Statement", "accent", None, ""),
("Conditional", "accent", None, ""),
("Repeat", "accent", None, ""),
("Label", "accent", None, ""),
("Operator", "ink_muted", None, ""),
("Keyword", "accent", None, ""),
("Exception", "danger", None, ""),
("PreProc", "success", None, ""),
("Include", "accent", None, ""),
("Define", "success", None, ""),
("Macro", "success", None, ""),
("Type", "success", None, ""),
("StorageClass", "accent", None, ""),
("Structure", "success", None, ""),
("Typedef", "success", None, ""),
("Special", "accent_hover", None, ""),
("SpecialChar", "warning", None, ""),
("Tag", "accent", None, ""),
("Delimiter", "ink_muted", None, ""),
("SpecialComment", "ink_muted", None, "italic"),
("Debug", "danger", None, ""),
("Underlined", "accent", None, "underline"),
("Ignore", "ink_faint", None, ""),
("Error", "danger", None, ""),
("Todo", "ink_inverse", "warning", "bold"),
("Added", "leaf", None, ""),
("Changed", "warning", None, ""),
("Removed", "danger", None, ""),
("DiffAdd", None, "add_bg", ""),
("DiffChange", None, "change_bg", ""),
("DiffDelete", "danger", "delete_bg", ""),
("DiffText", None, "text_bg", "bold"),
# --- Treesitter and LSP, where the default link is not the role ---
("@variable", "ink", None, ""),
("@variable.builtin", "danger", None, ""),
("@variable.parameter", "ink", None, "italic"),
("@variable.member", "ink_muted", None, ""),
("@property", "ink_muted", None, ""),
("@constant.builtin", "warning", None, ""),
("@module", "ink", None, ""),
("@constructor", "success", None, ""),
("@punctuation", "ink_muted", None, ""),
("@tag", "accent", None, ""),
("@tag.attribute", "success", None, ""),
("@tag.delimiter", "ink_faint", None, ""),
("@markup.heading", "leaf", None, "bold"),
("@markup.strong", None, None, "bold"),
("@markup.italic", None, None, "italic"),
("@markup.link", "accent", None, "underline"),
("@markup.raw", "warning", None, ""),
("@markup.list", "accent", None, ""),
("@markup.quote", "ink_muted", None, "italic"),
("LspReferenceText", None, "surface_active", ""),
("LspReferenceRead", None, "surface_active", ""),
("LspReferenceWrite", None, "surface_active", ""),
("LspInlayHint", "ghost", None, "italic"),
("LspSignatureActiveParameter", "warning", None, "bold"),
# --- diagnostics ---
("DiagnosticError", "danger", None, ""),
("DiagnosticWarn", "warning", None, ""),
("DiagnosticInfo", "accent", None, ""),
("DiagnosticHint", "success", None, ""),
("DiagnosticOk", "leaf", None, ""),
("DiagnosticVirtualTextError", "danger", "danger_soft", ""),
("DiagnosticVirtualTextWarn", "warning", "warning_soft", ""),
("DiagnosticVirtualTextInfo", "accent", "accent_soft", ""),
("DiagnosticVirtualTextHint", "success", "success_soft", ""),
("DiagnosticUnderlineError", None, None, "undercurl sp=danger"),
("DiagnosticUnderlineWarn", None, None, "undercurl sp=warning"),
("DiagnosticUnderlineInfo", None, None, "undercurl sp=accent"),
("DiagnosticUnderlineHint", None, None, "undercurl sp=success"),
("DiagnosticUnnecessary", "ink_faint", None, ""),
# --- the bars ---
("MiniStatuslineModeNormal", "ink_inverse", "leaf", "bold"),
("MiniStatuslineModeInsert", "accent_ink", "accent", "bold"),
("MiniStatuslineModeVisual", "ink_inverse", "warning", "bold"),
("MiniStatuslineModeReplace", "ink_inverse", "danger", "bold"),
("MiniStatuslineModeCommand", "ink_inverse", "success", "bold"),
("MiniStatuslineModeOther", "ink_inverse", "ink_muted", "bold"),
("MiniStatuslineDevinfo", "ink_muted", "surface_active", ""),
("MiniStatuslineFilename", "ink", "surface_raised", ""),
("MiniStatuslineFileinfo", "ink_muted", "surface_active", ""),
("MiniStatuslineInactive", "ink_faint", "surface", ""),
("MiniTablineCurrent", "ink", "bg", "bold"),
("MiniTablineVisible", "ink_muted", "surface", ""),
("MiniTablineHidden", "ink_faint", "bg_sunken", ""),
("MiniTablineModifiedCurrent", "warning", "bg", "bold"),
("MiniTablineModifiedVisible", "warning", "surface", ""),
("MiniTablineModifiedHidden", "warning", "bg_sunken", ""),
("MiniTablineFill", None, "bg_sunken", ""),
("MiniTablineTabpagesection", "ink_inverse", "leaf", "bold"),
("MiniTablineTrunc", "ink_faint", "bg_sunken", ""),
# --- pickers, explorer, hints, git ---
("MiniPickMatchCurrent", None, "surface_active", "bold"),
("MiniPickMatchRanges", "accent", None, "bold"),
("MiniPickPrompt", "leaf", "surface", "bold"),
("MiniPickBorderText", "leaf", "surface", ""),
("MiniFilesTitleFocused", "leaf", "surface", "bold"),
("MiniFilesDirectory", "accent", None, ""),
("MiniFilesCursorLine", None, "surface_active", ""),
("MiniClueNextKey", "leaf", "surface", "bold"),
("MiniClueNextKeyWithPostkeys", "warning", "surface", "bold"),
("MiniClueDescGroup", "accent", "surface", ""),
("MiniClueDescSingle", "ink", "surface", ""),
("MiniClueSeparator", "border_strong", "surface", ""),
("MiniClueTitle", "leaf", "surface", "bold"),
("MiniDiffSignAdd", "leaf", None, ""),
("MiniDiffSignChange", "warning", None, ""),
("MiniDiffSignDelete", "danger", None, ""),
("MiniDiffOverAdd", None, "add_bg", ""),
("MiniDiffOverChange", None, "text_bg", ""),
("MiniDiffOverChangeBuf", None, "change_bg", ""),
("MiniDiffOverContext", None, "change_bg", ""),
("MiniDiffOverContextBuf", None, None, ""),
("MiniDiffOverDelete", None, "delete_bg", ""),
("MiniIconsAzure", "accent", None, ""),
("MiniIconsBlue", "accent", None, ""),
("MiniIconsCyan", "success", None, ""),
("MiniIconsGreen", "leaf", None, ""),
("MiniIconsGrey", "ink_muted", None, ""),
("MiniIconsOrange", "warning", None, ""),
("MiniIconsPurple", "accent_hover", None, ""),
("MiniIconsRed", "danger", None, ""),
("MiniIconsYellow", "warning", None, ""),
("BlinkCmpMenu", "ink", "surface_raised", ""),
("BlinkCmpMenuBorder", "border_strong", "surface_raised", ""),
("BlinkCmpMenuSelection", "accent_ink", "accent", ""),
("BlinkCmpLabelMatch", "accent", None, "bold"),
("BlinkCmpKind", "ink_faint", None, ""),
("BlinkCmpDoc", "ink", "surface", ""),
("BlinkCmpDocBorder", "border_strong", "surface", ""),
# --- LLeMbas: the plugin's groups, and the IDE's own ---
("LLeMbasBrand", "leaf", None, "bold"),
("LLeMbasUserHeader", "accent", None, "bold"),
("LLeMbasAgentHeader", "leaf", None, "bold"),
("LLeMbasThought", "ink_faint", None, "italic"),
("LLeMbasToolPending", "warning", None, ""),
("LLeMbasToolDone", "success", None, ""),
("LLeMbasToolFail", "danger", None, ""),
("LLeMbasToolDenied", "danger", None, "italic"),
("LLeMbasPlanHeader", "accent", None, "bold"),
("LLeMbasDiffAdd", None, "add_bg", ""),
("LLeMbasDiffDelete", "danger", "delete_bg", ""),
("LLeMbasDiffHint", "ink_faint", None, "italic"),
("LLeMbasGhost", "ghost", None, "italic"),
("LLeMbasSeparator", "border", None, ""),
("LLeMbasIdeLeaf", "leaf", None, ""),
("LLeMbasIdeSign", "accent", None, ""),
("LLeMbasIdeTitle", "ink", None, "bold"),
("LLeMbasIdeVersion", "ink_faint", None, ""),
("LLeMbasIdeKey", "leaf", None, "bold"),
("LLeMbasIdeAction", "ink", None, ""),
("LLeMbasIdeMuted", "ink_faint", None, ""),
("LLeMbasIdeNote", "ink_muted", None, "italic"),
("LLeMbasIdeGood", "success", None, ""),
("LLeMbasIdeWarn", "warning", None, ""),
("LLeMbasIdeStatus", "leaf", "surface_raised", ""),
("LLeMbasIdeStatusOff", "ink_faint", "surface_raised", ""),
]
# The terminal's sixteen colours, by palette name.
TERMINAL = [
"bg_sunken", "danger", "leaf", "warning", "accent", "accent_hover", "success", "ink_muted",
"border_strong", "danger", "leaf_hover", "warning", "accent_hover", "accent_hover", "success", "ink",
]
def render(themes: dict) -> str:
palettes = {}
for background, name in THEMES.items():
if name not in themes:
raise ValueError(f'the tokens file has no data-theme="{name}" block')
palettes[background] = palette(themes[name])
keys = sorted(palettes["dark"])
for _, fg, bg, attrs in GROUPS:
for used in [fg, bg] + re.findall(r"sp=(\w+)", attrs):
if used is not None and used not in keys:
raise ValueError(f"a group names the colour {used}, which the palette lacks")
out = [
"-- 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 = {",
]
for background in ("dark", "light"):
out.append(f" {background} = {{ -- {THEMES[background]}")
for key in keys:
out.append(f' {key} = "{palettes[background][key]}",')
out.append(" },")
out += [
"}",
"",
"local groups = {",
]
for name, fg, bg, attrs in GROUPS:
parts = []
if fg:
parts.append(f'fg = "{fg}"')
if bg:
parts.append(f'bg = "{bg}"')
for attr in attrs.split():
if attr.startswith("sp="):
parts.append(f'sp = "{attr[3:]}"')
else:
parts.append(f"{attr} = true")
out.append(f' ["{name}"] = {{ {", ".join(parts)} }},')
out += [
"}",
"",
"local terminal = { " + ", ".join(f'"{name}"' for name in TERMINAL) + " }",
"",
'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",
"",
]
return "\n".join(out)
def main() -> int:
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
ap.add_argument("--tokens", type=Path, default=ROOT / "ide" / "tokens.css")
ap.add_argument("--out", type=Path, default=ROOT / "ide" / "config" / "colors" / "llembas.lua")
ap.add_argument("--check", action="store_true", help="write nothing; fail when the file is stale")
args = ap.parse_args()
try:
text = render(parse(args.tokens.read_text(encoding="utf-8")))
except (OSError, ValueError) as err:
print(f"gen-ide-theme: {err}", file=sys.stderr)
return 2
if args.check:
current = args.out.read_text(encoding="utf-8") if args.out.exists() else ""
if current != text:
print(f"gen-ide-theme: {args.out} is not what {args.tokens} gives; run scripts/gen-ide-theme.py", file=sys.stderr)
return 1
print(f"gen-ide-theme: {args.out.name} matches the tokens")
return 0
args.out.parent.mkdir(parents=True, exist_ok=True)
args.out.write_text(text, encoding="utf-8")
print(f"gen-ide-theme: wrote {args.out}")
return 0
if __name__ == "__main__":
sys.exit(main())
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# What a release of LLeMbas IDE carries, written into dist/:
# llembas-ide-<version>.tar.gz ide/ (the installer, the configuration, the lock files) and
# nvim/ (the LLeMbas plugin), with VERSION and LICENSE
# install.sh the installer, for: curl -fsSL <release>/install.sh | bash
# SHA256SUMS of every release file in dist/ (the .vsix too, when it is there)
# SHA256SUMS.sig with --sign <key file>: signed with ssh-keygen in the namespace
# lembas-release, which install.sh checks once it is given the key
#
# scripts/package-ide.sh [--sign <ssh private key>]
#
# The archive is made from the files git tracks, in a fixed order with fixed times and owners, so
# the same commit gives the same bytes. The version is the repository's VERSION file.
set -euo pipefail
cd "$(dirname "$0")/.."
sign=""
while [ $# -gt 0 ]; do
case "$1" in
--sign) sign="${2:?--sign needs a key file}" && shift ;;
*) echo "package-ide: unknown option $1" >&2 && exit 2 ;;
esac
shift
done
version="$(tr -d '[:space:]' <VERSION)"
name="llembas-ide-$version"
python3 scripts/gen-ide-theme.py --check
mkdir -p dist
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
mkdir "$work/$name"
git ls-files -z -- VERSION LICENSE ide nvim | grep -zv -E '^(ide|nvim)/tests/' |
while IFS= read -r -d '' f; do
mkdir -p "$work/$name/$(dirname "$f")"
cp -p "$f" "$work/$name/$f"
done
chmod 755 "$work/$name/ide/install.sh" "$work/$name/ide/bin/llembas-ide"
stamp="$(git log -1 --format=%ct)"
tar -C "$work" --sort=name --mtime="@$stamp" --owner=0 --group=0 --numeric-owner -cf - "$name" | gzip -n -9 >"dist/$name.tar.gz"
cp ide/install.sh dist/install.sh
(
cd dist
files=("$name.tar.gz" install.sh)
[ ! -f "llembas-$version.vsix" ] || files+=("llembas-$version.vsix")
sha256sum "${files[@]}" >SHA256SUMS
)
rm -f dist/SHA256SUMS.sig
if [ -n "$sign" ]; then
ssh-keygen -Y sign -q -f "$sign" -n lembas-release dist/SHA256SUMS
fi
echo "package-ide: dist/$name.tar.gz, dist/install.sh, dist/SHA256SUMS$([ -z "$sign" ] || echo ", dist/SHA256SUMS.sig")"