Neovim: the four bars — top, bottom, tree, and the right bar with settings lines, chat and prompt
One table of keys binds every action in two forms (the terminal's chords, and keys that always arrive), and the bottom bar shows the form that works for the bar that has the focus. The prompt says what Enter will do (ask, rewrite, add; Tab switches in an empty prompt) and carries the selection or the cursor's line as its attachment. Mode, effort, suggestions, AI on or off and the bars are remembered per directory with a machine-wide default. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
15 files changed
+3261
-46
No files matched your search
@@ -29,6 +29,7 @@ local function drop(buf, hunk)
|
||||
if #list == 0 then
|
||||
proposals[buf] = nil
|
||||
unmap(buf)
|
||||
pcall(vim.api.nvim_exec_autocmds, "User", { pattern = "LLeMbasChanged", modeline = false })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -169,9 +170,12 @@ function M.propose(buf, first, last, new)
|
||||
virt_lines = virt(lines), virt_lines_above = hunk.above, right_gravity = false })
|
||||
end
|
||||
if i == 1 and hint_row then
|
||||
-- The keys as the key table has them, in the form that arrives in this terminal.
|
||||
local K = require("llembas.keys")
|
||||
local function key(id) return K.shown(K.by_id[id]) end
|
||||
local label = #hunks > 1
|
||||
and (" ◈ LLeMbas (%d changes): ga accept · gr reject · gA/gR all · ]h/[h jump"):format(#hunks)
|
||||
or " ◈ LLeMbas: ga accept · gr reject"
|
||||
and (" ◈ LLeMbas (%d changes): %s accept · %s reject · %s all · %s next"):format(#hunks, key("accept"), key("reject"), key("accept_all"), key("next_change"))
|
||||
or (" ◈ LLeMbas: %s accept · %s reject"):format(key("accept"), key("reject"))
|
||||
hunk.hint = vim.api.nvim_buf_set_extmark(buf, ns, hint_row, 0, {
|
||||
virt_text = { { label, "LLeMbasDiffHint" } },
|
||||
virt_text_pos = "eol",
|
||||
@@ -186,13 +190,16 @@ function M.propose(buf, first, last, new)
|
||||
if next(before) and before.buffer == 1 then table.insert(saved[buf], before) end
|
||||
end
|
||||
end
|
||||
local function map(k, fn, desc) vim.keymap.set("n", k, fn, { buffer = buf, desc = desc, nowait = true }) end
|
||||
map("ga", function() M.accept(false) end, "LLeMbas: accept this change")
|
||||
map("gr", function() M.reject(false) end, "LLeMbas: reject this change")
|
||||
map("gA", function() M.accept(true) end, "LLeMbas: accept all changes")
|
||||
map("gR", function() M.reject(true) end, "LLeMbas: reject all changes")
|
||||
map("]h", function() M.next_hunk() end, "LLeMbas: next proposed change")
|
||||
map("[h", function() M.prev_hunk() end, "LLeMbas: previous proposed change")
|
||||
-- The buffer's own keys while changes are shown: the key table's (scope "change").
|
||||
require("llembas.keys").bind("change", buf, {
|
||||
accept = function() M.accept(false) end,
|
||||
reject = function() M.reject(false) end,
|
||||
accept_all = function() M.accept(true) end,
|
||||
reject_all = function() M.reject(true) end,
|
||||
next_change = function() M.next_hunk() end,
|
||||
prev_change = function() M.prev_hunk() end,
|
||||
})
|
||||
pcall(vim.api.nvim_exec_autocmds, "User", { pattern = "LLeMbasChanged", modeline = false })
|
||||
return #hunks
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user