Expand description
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
EXTENSION — NO vendor/ COUNTERPART. Interactive REPL for vimlrs — a
utop-style line editor backed by reedline. Adapted from strykelang’s
repl.rs (same reedline 0.47 API), trimmed for vimlrs’s thread-local
interpreter model.
Layout per turn:
─( HH:MM:SS )──< command N >─────────────────────────────{ vimlrs 0.1.2 }─
vimlrs❯ <buffer>
abs add and append …- The top “modeline” is rendered as part of
Prompt::render_prompt_left, so it repaints with the buffer (no scroll-off, no flicker). - Tab pops a
ColumnarMenuof suggestions sourced fromcrate::lsp::completion_words— the same wordlist the LSP serves. - History is
~/.vimlrs/historyviaFileBackedHistory. - Edit mode (emacs/vi) comes from
~/.vimlrs/config.toml[repl] mode, with aVIMLRS_REPL_MODEenv override and aVIMLRS_NO_CONFIGguard.
§Single-line evaluation (no multi-line block validator)
Each Enter submits one line to crate::eval_source, exactly like the
plain non-TTY cli::repl fallback. A reedline Validator that continued the
buffer on an open function/if/while/for/try block was considered
and deliberately not shipped: doing it correctly requires replicating the
parser’s |-separator + string/comment awareness (an inline
if x | echo 1 | endif is a complete line; echo "endif" must not decrement
block depth). A naive counter hangs the REPL on those valid single-line
inputs, which is worse than not having continuation. Interactive block
definitions are therefore entered one line at a time, matching the existing
stdin REPL. Reedline does not include a file-path completer either; bare-path
completion is intentionally dropped — the LSP word list is the high-value
surface (commands, not paths), the same choice utop makes.
Functions§
- ensure_
default_ config_ seeded - First-run seed: write
~/.vimlrs/config.tomlif it does not exist. Safe to call on every REPL launch — no-op when the file is already there (and silent if the home directory is read-only). HonorsVIMLRS_NO_CONFIG=1for CI / sandbox environments that should not touch the user’s home dir. - run
- Run the interactive reedline REPL. Must be called on the CLI worker thread
(interpreter globals —
g:/v:vars, the last-result slot — are thread-local, so evaluating inline here preserves state across turns).