refactor: Restructure keymaps and event handlers into centralized config-driven system

- Add M.setup() to cmd module for configuration
    - Move describe editor config to M.config.describe.editor with nested structure
    - Add keymaps config with separate log, status, and close sections
    - Implement resolve_keymaps_from_specs() helper to build keymap lists from config
    - Extract editor.open_editor() keymaps parameter support
    - Move status/log event handlers from terminal.lua to cmd.lua
    - Convert log/status buffer keymaps to config-driven approach with handler specs
This commit is contained in:
NicolasGB
2025-11-23 16:34:42 +01:00
committed by Nicolas GB
parent f0cfb459bd
commit f06b23326e
4 changed files with 366 additions and 254 deletions
+3 -5
View File
@@ -51,7 +51,8 @@ end
---@param initial_text string[] Lines to initialize the buffer with
---@param on_done fun(buf: string[])? Optional callback called with user text on buffer write
function M.open_editor(initial_text, on_done)
---@param keymaps? jj.core.buffer.keymap[] Optional keymaps for the buffer
function M.open_editor(initial_text, on_done, keymaps)
-- Initialize highlight groups once
init_highlights()
@@ -124,10 +125,7 @@ function M.open_editor(initial_text, on_done)
size = math.floor(vim.o.lines / 2),
buftype = "acwrite",
modifiable = true,
keymaps = {
{ modes = "n", lhs = "q", rhs = "<cmd>close!<CR>", opts = { desc = "Close describe buffer" } },
{ modes = "n", lhs = "<Esc>", rhs = "<cmd>close!<CR>", opts = { desc = "Close describe buffer" } },
},
keymaps = keymaps,
})
-- Set buffer content