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 -7
View File
@@ -7,6 +7,8 @@ local utils = require("jj.utils")
--- Jujutsu plugin configuration
--- @class jj.Config
--- @field cmd? jj.cmd.opts Options for command module
--- @field picker? jj.picker.config Options for picker module
M.config = {
-- Default configuration
--- @type jj.picker.config
@@ -20,8 +22,6 @@ M.config = {
deleted = { fg = "#f85149", ctermfg = "Red" },
renamed = { fg = "#d29922", ctermfg = "Yellow" },
},
--- @type "buffer"|"input" Editor mode for describe command: "buffer" (Git-style editor) or "input" (simple input prompt)
describe_editor = "buffer",
}
--- Setup the plugin
@@ -32,13 +32,9 @@ function M.setup(opts)
-- Setup for sub-modules
picker.setup(opts and opts.picker or {})
editor.setup({ highlights = M.config.highlights })
cmd.setup(opts.cmd)
utils.setup(opts) -- Keep for future-proofing, even if it's a no-op now
-- Pass describe_editor config to cmd module
if opts and opts.describe_editor then
cmd.config.describe_editor = opts.describe_editor
end
cmd.register_command()
-- Expose public API functions on the top-level module