From 86cc9352dc6a5e9ce798b5ef17b432c548ba2247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Wed, 2 Dec 2026 20:48:03 +0000 Subject: [PATCH] The bars: tab pages named in the top bar, a quit that did not happen brings the side bars back, names shown as text Under 120 columns the search count and the pending operator stay where stock Neovim shows them, so the bottom bar keeps its room for the keys. Co-Authored-By: Claude Fable 5.2 --- ide/README.md | 5 +++-- nvim/doc/llembas.txt | 6 +++++- nvim/lua/llembas/layout.lua | 22 ++++++++++++++++++---- nvim/lua/llembas/tree.lua | 4 +++- nvim/tests/layout.lua | 23 +++++++++++++++++++++++ 5 files changed, 52 insertions(+), 8 deletions(-) diff --git a/ide/README.md b/ide/README.md index 88df971..a05d0ef 100644 --- a/ide/README.md +++ b/ide/README.md @@ -122,8 +122,9 @@ does: a new version of the IDE carries new pins. code, the tree, the prompt, the settings lines, the transcript, and a proposed change. It is made from the same table that maps the keys, so it cannot show a key that is not bound, and it is cut from the end to fit, never wrapped. At its right end is Neovim's own state: the mode, - `+` for unsaved changes, the macro being recorded, the search count, the line and column, and - the pending operator. + `+` for unsaved changes, the macro being recorded, the line and column, and from 120 columns + the search count and the pending operator (narrower, those two are where stock Neovim shows + them, in the command line's row under the bar). - **The tree** (left). Open by default, 26 columns. The file you are in is followed and marked. `Enter` opens a file and opens or closes a directory (`→`/`←` too), `a` makes a file — or a directory when the name ends in `/` — `r` renames or moves, `d` deletes after asking (into the diff --git a/nvim/doc/llembas.txt b/nvim/doc/llembas.txt index 4f97619..27143f2 100644 --- a/nvim/doc/llembas.txt +++ b/nvim/doc/llembas.txt @@ -188,7 +188,11 @@ which can be switched off (`bars = { top = false }`, |:LLeMbasBars|): bottom the keys for the bar that has the focus (|llembas-keys|), and Neovim's own state: mode, modified, macro, search count, line and column, pending operator. It is the 'statusline' (with - 'laststatus' 3 and 'showcmdloc' statusline). + 'laststatus' 3). From 120 columns the search count and the + pending operator have cells in it ('showcmdloc' statusline); + narrower, the keys need the room and both are where stock Neovim + shows them, in the command line's row. + With several tab pages the top bar says which one this is. tree the file tree on the left (|llembas-tree|). chat the right bar: the settings lines (model, mode, effort, autocomplete — on a line opens its choices under it, diff --git a/nvim/lua/llembas/layout.lua b/nvim/lua/llembas/layout.lua index 6fd5179..37fd780 100644 --- a/nvim/lua/llembas/layout.lua +++ b/nvim/lua/llembas/layout.lua @@ -158,9 +158,16 @@ function M.top_cells(width) { id = "autocomplete", text = "AC " .. (s.autocomplete and "on" or "off"), width = 6, prio = 4, hl = s.autocomplete and "LLeMbasBar" or "LLeMbasBarOff" }, } + -- Tab pages have no line of their own under this bar: which one this is, when there are several. + local tabs = #vim.api.nvim_list_tabpages() + if tabs > 1 then + cells[#cells + 1] = { id = "tabs", text = ("tab %d/%d"):format(vim.api.nvim_tabpage_get_number(0), tabs), width = 9, prio = 4, hl = "LLeMbasBarFact" } + cells[5].prio = 5 + cells[4].prio = 6 + end local b, d = branch(), diagnostics() - if b ~= "" then cells[#cells + 1] = { id = "branch", text = b, width = 14, prio = 7, hl = "LLeMbasBarFact" } end - if d ~= "" then cells[#cells + 1] = { id = "problems", text = d, width = 7, prio = 6, hl = "LLeMbasBarFact" } end + if b ~= "" then cells[#cells + 1] = { id = "branch", text = b, width = 14, prio = 9, hl = "LLeMbasBarFact" } end + if d ~= "" then cells[#cells + 1] = { id = "problems", text = d, width = 7, prio = 8, hl = "LLeMbasBarFact" } end return cells end @@ -196,7 +203,7 @@ end local function search_count() if vim.v.hlsearch ~= 1 then return "" end - local ok, c = pcall(vim.fn.searchcount, { maxcount = 999, timeout = 30 }) + local ok, c = pcall(vim.fn.searchcount, { maxcount = 999, timeout = 10 }) if not ok or type(c) ~= "table" or (c.total or 0) == 0 then return "" end if c.incomplete == 1 then return "?/?" end return ("%d/%s"):format(c.current or 0, c.incomplete == 2 and "999+" or tostring(c.total)) @@ -221,6 +228,8 @@ end --- `%l`, `%v` and `%S` are the statusline's own items, so they are as live as Neovim's. `%S` is --- the one item whose width Neovim decides (an empty one takes no cell at all), so it stands at --- the very end, in the five cells kept for it, where it moves nothing else. +--- Under 120 columns the keys need the room: the search count and the pending operator are then +--- where stock Neovim shows them, in the command line's row ('showcmdloc' is "last"). local function vim_segment(width) local rec = vim.fn.reg_recording() local mode = mode_word() @@ -488,7 +497,9 @@ function M.bars() if not Y.saved.statusline then Y.saved.statusline = { vim.o.statusline, vim.o.laststatus, vim.o.showcmdloc } end vim.o.statusline = "%!v:lua.require'llembas.layout'.bottom()" vim.o.laststatus = 3 - vim.o.showcmdloc = "statusline" -- the pending operator is the bar's %S + -- The pending operator: the bar's %S where the bar is wide enough to have a cell for it, + -- otherwise in the command line's row, as Neovim itself shows it. + vim.o.showcmdloc = vim.o.columns >= 120 and "statusline" or "last" elseif Y.saved.statusline then vim.o.statusline, vim.o.laststatus, vim.o.showcmdloc = Y.saved.statusline[1], Y.saved.statusline[2], Y.saved.statusline[3] Y.saved.statusline = nil @@ -580,6 +591,7 @@ function M.setup(opts) vim.api.nvim_create_autocmd("VimResized", { group = group, callback = function() -- A new size is judged anew: what was opened by hand at the old one no longer holds. Y.forced = {} + if Y.saved.statusline then vim.o.showcmdloc = vim.o.columns >= 120 and "statusline" or "last" end vim.schedule(M.apply) end }) vim.api.nvim_create_autocmd({ "WinResized", "VimLeavePre" }, { group = group, callback = function() @@ -596,6 +608,8 @@ function M.setup(opts) Y.applying = true M.hide() Y.applying = false + -- A quit that did not happen (unsaved changes, a no to the question): the bars come back. + vim.defer_fn(function() if Y.on then M.apply() end end, 60) end }) Y.ai = L().settings().ai if vim.v.vim_did_enter == 1 then diff --git a/nvim/lua/llembas/tree.lua b/nvim/lua/llembas/tree.lua index 1a9865f..9cbc0eb 100644 --- a/nvim/lua/llembas/tree.lua +++ b/nvim/lua/llembas/tree.lua @@ -100,7 +100,9 @@ end --- A row as its line: the git mark, the indent, the fold mark of a directory, the name. local function line_of(row) local fold = row.dir and (T.open[row.path] and "▾ " or "▸ ") or " " - return mark_of(row) .. " " .. (" "):rep(row.depth) .. fold .. row.name .. (row.dir and "/" or "") + -- A name is shown as text on one line, whatever bytes it has. + local name = row.name:gsub("[%c]", "?") + return mark_of(row) .. " " .. (" "):rep(row.depth) .. fold .. name .. (row.dir and "/" or "") end function M.render() diff --git a/nvim/tests/layout.lua b/nvim/tests/layout.lua index c5e4559..4b3480c 100644 --- a/nvim/tests/layout.lua +++ b/nvim/tests/layout.lua @@ -616,6 +616,29 @@ local function run() layout.focus("code") vim.cmd("edit " .. vim.fn.fnameescape(tmp .. "/sample.py")) + -- ── What a model or a file's name says is text. ───────────────────────────────────────────────── + local title = L._state.title + L._state.title = "50% done\nnext %#Error#line %{1+1}" + check("a title is shown as text on one line: no line break, no highlight or expression of its own, the bar as wide as ever", + top():find("│ 50% done next %#Error#line %{1+1} ", 1, true) ~= nil and width(top()) == 160, top()) + L._state.title = title + local odd = tmp .. "/odd\nname.py" + if pcall(vim.fn.writefile, { "" }, odd) and vim.uv.fs_stat(odd) then + tree.refresh() + check("a file's name with a line break in it is one row of the tree", vim.tbl_contains(tree.lines(), " odd?name.py") + or vim.tbl_contains(tree.lines(), "? odd?name.py"), tree.lines()) + vim.fn.delete(odd) + tree.refresh() + end + vim.cmd("tabnew") + check("a second tab page: the top bar says which one this is", top():find("│ tab 2/2 ", 1, true) ~= nil and width(top()) == 160, top()) + vim.cmd("tabclose") + vim.cmd("2,3LLeMbasPrompt rewrite") + check(":2,3LLeMbasPrompt rewrite: the lines come along and the prompt says rewrite", + L.intent() == "rewrite" and L.settings().attachment == "sample.py:2-3" and vim.api.nvim_get_current_buf() == chat.ibuf, L.settings()) + L.intent("ask") + feed("") + -- ── AI off: a plain editor. ───────────────────────────────────────────────────────────────────── local agent = L._state.conn and L._state.conn.proc.pid feed("")