-- The installed IDE's four bars, checked on its own screen at three sizes, through its launcher: -- llembas-ide --headless -c "luafile ide/tests/layout.lua" -- Environment: IDE_TEST_REPO (the repository). The stand-in agent is nvim/tests/agent_levels.py. -- With IDE_LAYOUT_STEP set this is one start of the IDE for the checks that need a new process -- (what is remembered, what is written to the terminal); the answer is one line, RESULT {json}. local repo = assert(vim.env.IDE_TEST_REPO, "IDE_TEST_REPO") local agent = repo .. "/nvim/tests/agent_levels.py" local step = vim.env.IDE_LAYOUT_STEP local passed, failed = 0, {} local function check(name, cond, extra) if cond then passed = passed + 1 else table.insert(failed, name .. (extra ~= nil and (": " .. (type(extra) == "string" and extra or vim.inspect(extra))) or "")) end end local function wait(cond, ms) return vim.wait(ms or 8000, cond, 20) end local function t(keys) return vim.api.nvim_replace_termcodes(keys, true, false, true) end local function feed(keys) vim.api.nvim_feedkeys(t(keys), "mx", false) end local function row(r) vim.cmd("redraw") local out = {} for c = 1, vim.o.columns do out[#out + 1] = vim.fn.screenstring(r, c) end return table.concat(out) end local function top() return row(1) end local function bottom() return row(vim.o.lines - vim.o.cmdheight) end local function rtrim(s) return (s:gsub("%s+$", "")) end local function cell(text, w) return text .. (" "):rep(w - vim.fn.strdisplaywidth(text)) end local function width(s) return vim.fn.strdisplaywidth(s) end local function seg() return vim.o.columns < 60 and 15 or vim.o.columns < 120 and 20 or 35 end local function keys_part() return rtrim(vim.fn.strcharpart(bottom(), 0, vim.o.columns - seg())) end -- (At full width the segment's last six cells are the pending operator's, Neovim's own: not compared.) local function vim_part() return vim.fn.strcharpart(bottom(), vim.o.columns - seg(), seg() == 35 and 29 or seg()) end local function wins() local out = {} for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do if vim.api.nvim_win_get_config(w).relative == "" then local b = vim.api.nvim_win_get_buf(w) local ft, name = vim.bo[b].filetype, vim.api.nvim_buf_get_name(b) local kind = ft == "llembas-tree" and "tree" or ft == "llembas-settings" and "settings" or name:match("llembas://chat$") and "chat" or name:match("llembas://prompt$") and "prompt" or "code" out[kind] = { win = w, width = vim.api.nvim_win_get_width(w), height = vim.api.nvim_win_get_height(w) } end end return out end local function kinds(w) local names = vim.tbl_keys(w) table.sort(names) return table.concat(names, " ") end local function resize(cols, rows) vim.o.columns, vim.o.lines = cols, rows vim.api.nvim_exec_autocmds("VimResized", {}) vim.wait(80) vim.cmd("redraw") end local function calls(method) local out = {} for _, line in ipairs(vim.fn.filereadable(vim.env.FAKE_AGENT_LOG) == 1 and vim.fn.readfile(vim.env.FAKE_AGENT_LOG) or {}) do local m = vim.json.decode(line) if m.method == method then out[#out + 1] = m.params end end return out end local function last_call(method) local c = calls(method); return c[#c] end local function finish() vim.g.llembas_ide_no_session = true pcall(function() require("llembas").restart(true) end) io.stdout:write("\n") for _, f in ipairs(failed) do io.stdout:write("FAIL " .. f .. "\n") end io.stdout:write(("ide-layout: %d passed, %d failed (Neovim %s)\n"):format(passed, #failed, tostring(vim.version()))) vim.cmd(#failed > 0 and "cquit 1" or "qa!") end -- ── One start, for the parent's questions. ────────────────────────────────────────────────────── local function one_start() vim.g.llembas_ide_no_session = true vim.notify = function() end local L = require("llembas") local out = {} if step ~= "start" then L.setup({ cmd = { "python3", agent }, complete = { auto = true } }) vim.o.columns, vim.o.lines = 160, 45 vim.api.nvim_exec_autocmds("VimResized", {}) vim.wait(80) end local layout, store = require("llembas.layout"), require("llembas.store") if step == "change" then L.mode("edit") wait(function() return store.get().mode == "edit" end) L.effort("high") L.autocomplete(false) layout.toggle("tree", false) vim.api.nvim_win_set_width(vim.fn.bufwinid(require("llembas.chat").tbuf), 46) elseif step == "change_b" then L.mode("plan") wait(function() return store.get().mode == "plan" end) elseif step == "session" then local done = false L.choices("mode", function() done = true end) wait(function() return done end) local p = last_call("session/new") out.new_mode, out.new_effort = p and (p._meta or {}).mode, p and (p._meta or {}).effort end layout.remember_widths() local s, o = L.settings(), layout.options() out.mode, out.effort, out.autocomplete = s.mode, s.effort, s.autocomplete out.tree, out.chat_width, out.top, out.bottom = o.tree, o.chat_width, o.top, o.bottom out.tree_open = require("llembas.tree").is_open() out.kinds = kinds(wins()) out.state_file = store.path() out.tabline, out.statusline = vim.o.tabline, vim.o.statusline out.ask_chord = require("llembas.keys").by_id.ask.chord out.f2 = vim.fn.maparg("", "n") ~= "" or vim.fn.maparg("", "n", false, true).callback ~= nil io.stdout:write("RESULT " .. vim.json.encode(out) .. "\n") pcall(function() L.restart(true) end) vim.cmd("qa!") end --- Start the IDE again through its launcher in `dir`; returns the decoded RESULT and what it wrote on stderr. local function start(dir, name, env) local e = vim.tbl_extend("force", { IDE_LAYOUT_STEP = name, PYTHONDONTWRITEBYTECODE = "1" }, env or {}) local done = vim.system({ vim.env.LLEMBAS_IDE_LAUNCHER, "--headless", "-c", "luafile " .. repo .. "/ide/tests/layout.lua" }, { cwd = dir, env = e, text = false }):wait(60000) local ok, data = pcall(vim.json.decode, (done.stdout or ""):match("RESULT (%b{})") or "", { luanil = { object = true, array = true } }) return ok and data or { failed = true, out = done.stdout, code = done.code }, done.stderr or "" end local function run() local ide = require("llembas_ide") local L = require("llembas") local layout = require("llembas.layout") local keys = require("llembas.keys") local tree = require("llembas.tree") local lines = require("llembas.lines") local chat = require("llembas.chat") local said = {} vim.notify = function(m) said[#said + 1] = tostring(m) end local work = vim.fn.tempname() local project = work .. "/project" vim.fn.mkdir(project .. "/src", "p") vim.fn.writefile({ "def a():", " return 1", "", "def b():", " return 2" }, project .. "/sample.py") vim.fn.writefile({ "x = 1" }, project .. "/src/util.py") work = vim.uv.fs_realpath(work) project = work .. "/project" vim.env.FAKE_AGENT_LOG = work .. "/agent.log" vim.env.PYTHONDONTWRITEBYTECODE = "1" check("every part of the IDE started", #ide.problems == 0, ide.problems) -- ── As installed, with no CLI: the bars are there, and the keys say what is missing. ───────────── vim.o.columns, vim.o.lines = 160, 45 vim.api.nvim_exec_autocmds("VimResized", {}) vim.wait(80) check("the layout is on by default, all four bars", layout.options().on and layout.options().top and layout.options().bottom and layout.options().tree and layout.options().chat, layout.options()) check("the start screen stands between the tree and the right bar", vim.bo.filetype == "llembas-ide-dashboard" and kinds(wins()) == "chat code prompt settings tree", { vim.bo.filetype, kinds(wins()) }) if not require("llembas_ide.llembas").has_cli() then check("without the CLI the top bar says so, and nothing is asked of anybody", vim.startswith(top(), " ● no CLI │ ") and top():find("│ AC off ", 1, true) ~= nil and L._state.conn == nil, top()) local ide_llembas = require("llembas_ide.llembas") local sign_in, asked_to = ide_llembas.sign_in, 0 ide_llembas.sign_in = function() asked_to = asked_to + 1 end feed(" la") check("without the CLI la leads to signing in instead of failing, and opens nothing", asked_to == 1 and vim.bo.filetype == "llembas-ide-dashboard" and L._state.conn == nil, { asked_to, vim.bo.filetype }) ide_llembas.sign_in = sign_in feed(" e") check("e hides the tree without the CLI as with it", not tree.is_open()) feed(" e") check("…and shows it again", tree.is_open()) end -- ── With an agent (the stand-in). 160×45. ─────────────────────────────────────────────────────── L.setup({ cmd = { "python3", agent }, complete = { auto = true } }) vim.cmd("cd " .. vim.fn.fnameescape(project)) vim.cmd("edit " .. vim.fn.fnameescape(project .. "/sample.py")) local fbuf = vim.api.nvim_get_current_buf() vim.wait(100) local w = wins() check("160×45: tree, code, settings lines, chat and prompt", kinds(w) == "chat code prompt settings tree", kinds(w)) check("160×45: the tree is 26 columns, the right bar 42, the code the rest", w.tree.width == 26 and w.chat.width == 42 and w.settings.width == 42 and w.prompt.width == 42 and w.code.width == 160 - 26 - 42 - 2, w) check("160×45: the top bar, cell for cell", top() == " ● idle │ " .. cell("no conversation yet", 160 - 2 - 17 - 3 - 3 - 32 - 3 - 8 - 3 - 6) .. " │ " .. cell("— · — · —", 32) .. " │ ctx — │ AC on ", top()) check("160×45: both bars are exactly as wide as the screen", width(top()) == 160 and width(bottom()) == 160) check("160×45, in the code: the keys that always arrive (no chord was seen in this terminal)", keys_part() == " Spc la ask · Tab accept suggestion · Alt+→ one word · Spc lp menu · Alt+←→ bars · Spc lb tree · Spc ll chat", keys_part()) check("160×45: Neovim's own state in its cells", vim_part() == " NOR" .. (" "):rep(19) .. "1:1 ", "[" .. vim_part() .. "]") check("the tree shows the directory and marks the file you are in", vim.deep_equal(tree.lines(), { " ▸ src/", " sample.py" }), tree.lines()) -- The keys: the plugin's one table, mapped here in both forms, and nothing beside it. local missing = {} for _, k in ipairs(keys.table) do if not k.virtual and k.run then for _, lhs in ipairs(type(k.chord) == "table" and k.chord or { k.chord }) do for _, mode in ipairs({ "n", "x", "i" }) do if next(vim.fn.maparg(lhs, mode, false, true)) == nil then missing[#missing + 1] = mode .. " " .. lhs end end end if not k.scope then for _, lhs in ipairs(keys.alts(k)) do for _, mode in ipairs(k.modes or { "n" }) do if next(vim.fn.maparg(keys.lhs(lhs), mode, false, true)) == nil then missing[#missing + 1] = mode .. " " .. keys.lhs(lhs) end end end end end end check("keys: every key of the table is mapped", #missing == 0, missing) local in_table = {} for _, k in ipairs(keys.table) do for _, lhs in ipairs(type(k.chord) == "table" and k.chord or { k.chord }) do in_table[t(lhs)] = true end for _, lhs in ipairs(keys.alts(k)) do in_table[t(keys.lhs(lhs))] = true end end local strays = {} for _, mode in ipairs({ "n", "x", "i" }) do for _, m in ipairs(vim.api.nvim_get_keymap(mode)) do local lhs = t(m.lhs) local ours = (m.desc or ""):match("^LLeMbas: ") or (vim.startswith(lhs, " l") and #lhs > 2) if ours and not in_table[lhs] and lhs ~= t(L.config.complete.trigger) then strays[#strays + 1] = mode .. " " .. m.lhs end end end check("keys: every mapping of the LLeMbas group (l…, and LLeMbas's own) is in the table", #strays == 0, strays) local shown = {} for _, where in ipairs({ "code", "tree", "prompt", "settings", "chat", "change" }) do for _, form in ipairs({ true, false }) do for _, k in ipairs(keys.for_bar(where, form)) do local e = keys.by_id[k.id] local lhs = (form and e.chord) or keys.alts(e)[1] or e.chord if type(lhs) == "table" then lhs = lhs[1] end local buf = ({ tree = tree.buf(), settings = lines.buf(), prompt = chat.ibuf, chat = chat.tbuf })[e.scope or ""] local bound if e.virtual or e.scope == "change" or e.scope == "suggestion" then -- Neovim's own arrows, or mapped only while a change or a suggestion is shown (checked -- below and in the plugin's own suite). bound = true elseif buf and not (form and e.chord) then bound = vim.api.nvim_buf_call(buf, function() return vim.fn.maparg(lhs, "n", false, true).buffer == 1 or vim.fn.maparg(lhs, "i", false, true).buffer == 1 end) else bound = next(vim.fn.maparg(keys.lhs(lhs), "n", false, true)) ~= nil end if not bound then shown[#shown + 1] = where .. " " .. k.id .. " " .. tostring(lhs) end end end end check("keys: every key the bottom bar can show is bound where it shows it", #shown == 0, shown) check("keys: the IDE's own map takes none of LLeMbas's keys", #require("llembas_ide.keys").duplicates() == 0, require("llembas_ide.keys").duplicates()) -- The bottom bar for each bar that has the focus. layout.focus("tree") check("focus tree", keys_part() == " Enter open · a new · r rename · d delete · / filter · Alt+→ code · . hidden files · Spc la ask · Spc lp menu · Spc lb tree", keys_part()) layout.focus("chat") check("focus prompt", keys_part() == " Enter send · Tab ask/rewrite/add · Spc lm mode · Spc lM model · Esc back to code · Spc l. stop", keys_part()) vim.cmd("stopinsert") vim.api.nvim_set_current_win(wins().settings.win) check("focus settings lines", keys_part() == " Enter change · ↑↓ move · Esc back · Alt+← code", keys_part()) vim.api.nvim_set_current_win(wins().chat.win) check("focus transcript", keys_part() == " Enter open file · K tool output · i prompt · Alt+← code · Spc l. stop · Spc la ask · Spc lp menu · Spc ll chat", keys_part()) layout.focus("code") -- A chord that arrives: the bar shows the chords from then on. feed("") check("Ctrl+Shift+E hides the tree", wait(function() return not tree.is_open() end)) feed("") wait(function() return tree.is_open() end) check("code, chords", keys_part() == " ^⇧A ask · Tab accept suggestion · Alt+→ one word · ^⇧P menu · Alt+←→ bars · ^⇧E tree · ^⇧D chat", keys_part()) layout.focus("tree") check("tree, chords", vim.startswith(keys_part(), " Enter open · a new · r rename · d delete · / filter · Alt+→ code"), keys_part()) layout.focus("chat") check("prompt, chords", vim.startswith(keys_part(), " Enter send · Tab ask/rewrite/add · ^Tab mode · ^⇧M model · Esc back to code"), keys_part()) -- Tab in the prompt. local function prompt_rows() local pw = wins().prompt.win local pos = vim.fn.win_screenpos(pw) local out = {} for r = pos[1], pos[1] + vim.api.nvim_win_get_height(pw) - 1 do out[#out + 1] = vim.fn.strcharpart(row(r), pos[2] - 1, vim.api.nvim_win_get_width(pw)) end return out end check("the prompt begins with what Enter does", prompt_rows()[2] == cell("ask ›", 42), prompt_rows()) feed("") check("Tab in an empty prompt: rewrite", L.intent() == "rewrite" and vim.startswith(prompt_rows()[2], "rewrite › "), prompt_rows()) feed("") check("Tab: add", L.intent() == "add" and vim.startswith(prompt_rows()[2], "add › "), prompt_rows()) feed("") check("Tab: ask again", L.intent() == "ask" and vim.startswith(prompt_rows()[2], "ask › "), prompt_rows()) local menu = require("blink.cmp.config").keymap check("the completion menu has no , and is not offered over the prompt", menu[""] == nil and vim.b[chat.ibuf].completion == false) feed("") check("Esc is back in the code", vim.api.nvim_get_current_buf() == fbuf) -- What comes along. vim.api.nvim_win_set_cursor(0, { 1, 0 }) feed("Vj") check("Ctrl+Shift+A with a selection: the chip names the lines", vim.api.nvim_get_current_buf() == chat.ibuf and rtrim(prompt_rows()[1]) == " sample.py:1-2", prompt_rows()) vim.api.nvim_buf_set_lines(chat.ibuf, 0, -1, false, { "what is this?" }) feed("") check("Enter sends the question with the selection", wait(function() return last_call("session/prompt") ~= nil end) and wait(function() return not L._state.busy end) and ((((last_call("session/prompt") or {})._meta or {}).lembas or {}).editor or {}).selection ~= nil, last_call("session/prompt")) check("the top bar and the settings lines follow the session", wait(function() return L.settings().context == 4 end) and top():find("│ " .. cell("model-a · manual · default", 32) .. " │ ctx 4% │ AC on ", 1, true) ~= nil and vim.deep_equal(lines.lines(), { "model model-a", "mode manual", "effort default", "autocomplete on" }), { top(), lines.lines() }) layout.focus("code") vim.api.nvim_win_set_cursor(0, { 4, 0 }) feed(" la") check("la without a selection: the cursor's line, as a point", rtrim(prompt_rows()[1]) == " sample.py:4", prompt_rows()) feed("") vim.api.nvim_win_set_cursor(0, { 1, 0 }) feed("Vj le") vim.api.nvim_buf_set_lines(chat.ibuf, 0, -1, false, { "REPLACE def a():\\n return 100" }) feed("") check("rewrite: shown in the file as a change; the bar shows the change's keys", wait(function() return require("llembas.diff").pending(fbuf) == 1 end) and vim.api.nvim_get_current_buf() == fbuf and wait(function() return keys_part() == " ^⇧Y accept · ^⇧J reject · ]h next · Alt+^⇧Y accept all · [h previous · ^⇧P menu" end), keys_part()) feed("") check("Ctrl+Shift+Y accepts it", vim.api.nvim_buf_get_lines(fbuf, 1, 2, false)[1] == " return 100") vim.cmd("silent write") -- The settings lines, through the agent. vim.api.nvim_set_current_win(wins().settings.win) vim.api.nvim_win_set_cursor(0, { 2, 0 }) feed("") check("Enter on mode opens its choices in the bar", wait(function() return #lines.lines() == 8 end) and lines.lines()[3] == " ● manual" and wins().settings.height == 8, lines.lines()) feed("j") check("a choice is set through the agent and shown", wait(function() return (last_call("session/set_mode") or {}).modeId == "edit" end) and wait(function() return lines.lines()[2] == "mode edit" and #lines.lines() == 4 end) and top():find("model-a · edit · default", 1, true) ~= nil, { lines.lines(), top() }) L.set("effort", "high") check("the effort too", wait(function() return (last_call("_lembas/configure") or {}).effort == "high" end) and wait(function() return lines.lines()[3] == "effort high" end), lines.lines()) feed("") local asked local select = vim.ui.select vim.ui.select = function(items, opts) asked = { items = items, opts = opts } end feed("") local menu_text = {} for _, i in ipairs(asked and asked.items or {}) do menu_text[#menu_text + 1] = asked.opts.format_item(i) end menu_text = table.concat(menu_text, "\n") check("Ctrl+Shift+P: the menu has the effort and the bars", menu_text:find("Effort: high", 1, true) and menu_text:find("Tree: shown", 1, true) and menu_text:find("Top bar: shown", 1, true), menu_text) vim.ui.select = select -- ── 100×30 and 80×24. ─────────────────────────────────────────────────────────────────────────── vim.api.nvim_set_current_win(wins().code.win) vim.api.nvim_win_set_cursor(0, { 1, 0 }) resize(100, 30) w = wins() check("100×30: the chat folds away, the tree stays", kinds(w) == "code tree" and w.tree.width == 26 and w.code.width == 73, w) check("100×30: the top bar", top() == " ● idle │ " .. cell("conversation", 100 - 2 - 17 - 3 - 3 - 32 - 3 - 8 - 3 - 6) .. " │ " .. cell("model-a · edit · high", 32) .. " │ ctx 4% │ AC on ", top()) check("100×30: the bottom bar", keys_part() == " ^⇧A ask · Tab accept suggestion · Alt+→ one word · ^⇧P menu · Alt+←→ bars" and vim_part() == " NOR" .. (" "):rep(10) .. "1:1 ", { keys_part(), "[" .. vim_part() .. "]" }) check("100×30: both rows are 100 wide", width(top()) == 100 and width(bottom()) == 100) layout.focus("tree") check("100×30, in the tree", keys_part() == " Enter open · a new · r rename · d delete · / filter · Alt+→ code", keys_part()) layout.focus("code") resize(80, 24) w = wins() check("80×24: the code alone, all 80 columns", kinds(w) == "code" and w.code.width == 80, w) check("80×24: the top bar", top() == " ● idle │ " .. cell("conversation", 80 - 2 - 9 - 3 - 3 - 26 - 3 - 8 - 3 - 6) .. " │ " .. cell("model-a · edit · high", 26) .. " │ ctx 4% │ AC on ", top()) check("80×24: the bottom bar", keys_part() == " ^⇧A ask · Tab accept suggestion · Alt+→ one word · ^⇧P menu" and vim_part() == " NOR" .. (" "):rep(10) .. "1:1 ", { keys_part(), "[" .. vim_part() .. "]" }) check("80×24: both rows are 80 wide", width(top()) == 80 and width(bottom()) == 80) feed("") check("80×24: Alt+→ still reaches the chat", chat.is_open() and vim.api.nvim_get_current_buf() == chat.ibuf) check("80×24, in the prompt", keys_part() == " Enter send · Tab ask/rewrite/add · ^Tab mode · ^⇧M model", keys_part()) feed("") resize(160, 45) check("160×45 again: everything is back", kinds(wins()) == "chat code prompt settings tree", kinds(wins())) -- ── A bar switched off: the IDE's stand-ins. ──────────────────────────────────────────────────── layout.toggle("top", false) check("the top bar off: the line of open buffers stands in", vim.o.tabline:find("MiniTabline", 1, true) ~= nil and vim.o.showtabline == 2, vim.o.tabline) layout.toggle("bottom", false) check("the bottom bar off: the IDE's statusline stands in", #vim.api.nvim_eval_statusline(require("mini.statusline").active(), {}).str > 0 and not vim.o.statusline:find("llembas.layout", 1, true), vim.o.statusline) layout.toggle("top", true) layout.toggle("bottom", true) check("…and on again", vim.startswith(top(), " ● idle") and vim.startswith(keys_part(), " ^⇧A ask"), { top(), keys_part() }) -- ── A session holds the code's windows, not the bars. ─────────────────────────────────────────── local sessions = require("llembas_ide.sessions") check("a session is saved with the bars put away, and they are back after", sessions.save(true) and kinds(wins()) == "chat code prompt settings tree", kinds(wins())) local session_text = table.concat(vim.fn.readfile(vim.fn.stdpath("state") .. "/sessions/" .. sessions.name()), "\n") check("the session file names no bar", not session_text:find("llembas://", 1, true), session_text:match("[^\n]*llembas://[^\n]*")) sessions.restore() vim.wait(200) check("restored: the file, with the bars around it", kinds(wins()) == "chat code prompt settings tree" and vim.fn.fnamemodify(vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(wins().code.win)), ":t") == "sample.py", kinds(wins())) sessions.delete() pcall(function() L.restart(true) end) -- ── Remembered across restarts, per directory; and a person's own file. ───────────────────────── local dir_a, dir_b = work .. "/dir-a", work .. "/dir-b" vim.fn.mkdir(dir_a, "p") vim.fn.mkdir(dir_b, "p") local env = { FAKE_AGENT_LOG = work .. "/remember.log" } local r = start(dir_a, "change", env) check("remember: changed in one directory", r.mode == "edit" and r.effort == "high" and r.autocomplete == false and r.tree == false and r.chat_width == 46, r) check("remember: kept in the IDE's own state directory", type(r.state_file) == "string" and r.state_file:find("/llembas%-ide/llembas/settings%.json$") ~= nil and vim.fn.filereadable(r.state_file) == 1, r.state_file) r = start(dir_b, "look", env) check("remember: another directory starts as the IDE does", r.mode == nil and r.effort == nil and r.autocomplete == true and r.tree == true and r.chat_width == 42 and r.kinds == "chat code prompt settings tree", r) r = start(dir_b, "change_b", env) r = start(dir_a, "look", env) check("remember: the first directory, started again", r.mode == "edit" and r.effort == "high" and r.autocomplete == false and r.tree == false and r.tree_open == false and r.chat_width == 46 and r.kinds == "chat code prompt settings", r) r = start(dir_a, "session", env) check("remember: a session there starts on that mode and effort", r.new_mode == "edit" and r.new_effort == "high", r) r = start(dir_b, "look", env) check("remember: the second directory has its own", r.mode == "plan" and r.effort == nil and r.tree == true, r) local user = vim.fn.stdpath("config") .. "/lua/user/init.lua" local before = vim.fn.readfile(user) vim.fn.writefile(vim.list_extend(vim.list_slice(before), { 'require("llembas.keys").by_id.ask.chord = ""', 'require("llembas").setup({ bars = { top = false, chat_width = 48 }, keys = { prefix = "l" } })', }), user) r = start(dir_b, "look", env) check("your own file: a bar switched off, a width, a key changed in the table and mapped", r.top == false and r.bottom == true and r.chat_width == 48 and r.tabline:find("MiniTabline", 1, true) ~= nil and r.statusline:find("llembas.layout", 1, true) ~= nil and r.ask_chord == "" and r.f2 == true, r) vim.fn.writefile(vim.list_extend(vim.list_slice(before), { 'require("llembas").setup({ bars = false })' }), user) r = start(dir_b, "look", env) check("your own file: no bars at all — one window, the IDE's statusline and buffer line", r.kinds == "code" and r.tabline:find("MiniTabline", 1, true) ~= nil and not r.statusline:find("llembas.layout", 1, true), r) vim.fn.writefile(before, user) -- ── The terminal. ─────────────────────────────────────────────────────────────────────────────── local set, clear = "\27]1337;SetUserVar=llembas_ide=MQ==\7", "\27]1337;SetUserVar=llembas_ide=\7" local _, err = start(dir_b, "start", { LLEMBAS_TERM = "1" }) check("user var: in the LLeMbas terminal llembas_ide=1 is set on start and cleared on exit, and nothing else is written", err == set .. clear, vim.inspect(err)) _, err = start(dir_b, "start", { LLEMBAS_TTY = "pane-1" }) check("user var: $LLEMBAS_TTY counts as well", err == set .. clear, vim.inspect(err)) _, err = start(dir_b, "start", {}) check("user var: in any other terminal nothing is written", err == "", vim.inspect(err)) vim.cmd("cd /") vim.fn.delete(work, "rf") end vim.schedule(function() local ok, err = xpcall(step and one_start or run, debug.traceback) if not ok then table.insert(failed, "the checks themselves stopped: " .. tostring(err)) end if step and ok then return end finish() end)