mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-05 10:46:08 +00:00
Update README with new config structure
- Document describe.editor configuration for type and keymaps - Document keymaps configuration for log, status, and close keybindings - Update examples to show the new nested config structure - Add section on customizing describe editor keymaps - Preserve multiline descriptions in describe editor buffer
This commit is contained in:
+44
-9
@@ -9,24 +9,52 @@ local editor = require("jj.ui.editor")
|
||||
local diff = require("jj.diff")
|
||||
|
||||
-- Config for cmd module
|
||||
--- @class jj.cmd.describe.editor.keymaps
|
||||
--- @field close? string|string[] Keymaps to close the editor buffer without saving
|
||||
|
||||
--- @class jj.cmd.describe.editor
|
||||
--- @field type? "buffer"|"input" Editor mode for describe command: "buffer" (Git-style editor) or "input" (simple input prompt)
|
||||
--- @field keymaps? jj.cmd.describe.editor.keymaps Keymaps for the describe editor only when on "buffer" mode.
|
||||
|
||||
--- @class jj.cmd.describe
|
||||
--- @field editor? jj.cmd.describe.editor Options for the describe message editor
|
||||
|
||||
--- @class jj.cmd.log.keymaps
|
||||
--- @field checkout? string|string[] Keymaps for the log command buffer, setting a keymap to nil will disable it
|
||||
--- @field checkout_immutable? string|string[]
|
||||
--- @field describe? string|string[]
|
||||
--- @field diff? string|string[]
|
||||
--- @field edit? string|string[]
|
||||
--- @field new? string|string[]
|
||||
--- @field new_after? string|string[]
|
||||
--- @field new_after_immutable? string|string[]
|
||||
--- @field undo? string|string[]
|
||||
--- @field redo? string|string[]
|
||||
|
||||
--- @class jj.cmd.status.keymaps
|
||||
--- @field open_file? string|string[] Keymaps for the status command buffer, setting a keymap to nil will disable it
|
||||
--- @field restore_file? string|string[]
|
||||
|
||||
--- @class jj.cmd.keymaps
|
||||
--- @field log? jj.cmd.log.keymaps Keymaps for the log command buffer
|
||||
--- @field status? jj.cmd.status.keymaps Keymaps for the status command buffer
|
||||
--- @field close? string|string[] Keymaps for the close keybind
|
||||
|
||||
--- @class jj.cmd.opts
|
||||
--- @field describe? jj.cmd.describe
|
||||
--- @field keymaps? jj.cmd.keymaps Keymaps for the buffers containing the output of the commands
|
||||
|
||||
--- @type jj.cmd.opts
|
||||
M.config = {
|
||||
--- @class jj.cmd.describe
|
||||
describe = {
|
||||
--- @class jj.cmd.describe.editor Options for the describe message editor
|
||||
editor = {
|
||||
--- @type "buffer"|"input" Editor mode for describe command: "buffer" (Git-style editor) or "input" (simple input prompt)
|
||||
type = "buffer",
|
||||
--- @class jj.cmd.describe.editor.keymaps Keymaps for the describe editor buffer
|
||||
keymaps = {
|
||||
--- @type string|string[] Keymaps to close the editor buffer without saving
|
||||
close = { "<Esc>", "<C-c>", "q" },
|
||||
},
|
||||
},
|
||||
},
|
||||
--- @class jj.cmd.keymaps Keymaps for the buffers containing the ouptut of the commands
|
||||
keymaps = {
|
||||
--- @class jj.cmd.log.keymaps: { [string]: string|string[] } Keymaps for the log command buffer, setting a keymap to nil will disable it
|
||||
log = {
|
||||
checkout = "<CR>",
|
||||
checkout_immutable = "<S-CR>",
|
||||
@@ -39,12 +67,10 @@ M.config = {
|
||||
undo = "<S-u>",
|
||||
redo = "<S-r>",
|
||||
},
|
||||
--- @class jj.cmd.status.keymaps: { [string]: string|string[] } Keymaps for the status command buffer, setting a keymap to nil will disable it
|
||||
status = {
|
||||
open_file = "<CR>",
|
||||
restore_file = "<S-x>",
|
||||
},
|
||||
--- @type string|string[] Keymaps for the close keybind
|
||||
close = { "q", "<Esc>" },
|
||||
},
|
||||
}
|
||||
@@ -835,6 +861,15 @@ function M.j(args)
|
||||
log = function()
|
||||
M.log({ raw_flags = remaining_args_str ~= "" and remaining_args_str or nil })
|
||||
end,
|
||||
diff = function()
|
||||
M.diff({ current = false })
|
||||
end,
|
||||
status = function()
|
||||
M.status()
|
||||
end,
|
||||
st = function()
|
||||
M.status()
|
||||
end,
|
||||
}
|
||||
|
||||
if handlers[subcommand] then
|
||||
|
||||
+3
-34
@@ -2,13 +2,12 @@ local M = {}
|
||||
local cmd = require("jj.cmd")
|
||||
local picker = require("jj.picker")
|
||||
local editor = require("jj.ui.editor")
|
||||
local diff = require("jj.diff")
|
||||
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
|
||||
--- @field highlights? jj.ui.editor.highlights Highlight configuration for describe buffer
|
||||
M.config = {
|
||||
-- Default configuration
|
||||
--- @type jj.picker.config
|
||||
@@ -16,12 +15,7 @@ M.config = {
|
||||
snacks = {},
|
||||
},
|
||||
--- @type jj.ui.editor.highlights Highlight configuration for describe buffer
|
||||
highlights = {
|
||||
added = { fg = "#3fb950", ctermfg = "Green" },
|
||||
modified = { fg = "#56d4dd", ctermfg = "Cyan" },
|
||||
deleted = { fg = "#f85149", ctermfg = "Red" },
|
||||
renamed = { fg = "#d29922", ctermfg = "Yellow" },
|
||||
},
|
||||
highlights = {},
|
||||
}
|
||||
|
||||
--- Setup the plugin
|
||||
@@ -32,34 +26,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
|
||||
cmd.setup(opts and opts.cmd or {})
|
||||
|
||||
cmd.register_command()
|
||||
|
||||
-- Expose public API functions on the top-level module
|
||||
M.status = cmd.status
|
||||
M.describe = cmd.describe
|
||||
M.log = cmd.log
|
||||
M.new = cmd.new
|
||||
M.edit = cmd.edit
|
||||
M.squash = cmd.squash
|
||||
M.rebase = cmd.rebase
|
||||
M.undo = cmd.undo
|
||||
M.redo = cmd.redo
|
||||
M.bookmark_create = cmd.bookmark_create
|
||||
M.bookmark_delete = cmd.bookmark_delete
|
||||
M.j = cmd.j
|
||||
|
||||
M.picker = {
|
||||
status = picker.status,
|
||||
file_history = picker.file_history,
|
||||
}
|
||||
|
||||
M.diff = {
|
||||
vsplit = diff.open_vdiff,
|
||||
hsplit = diff.open_hdiff,
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -4,10 +4,10 @@ local M = {}
|
||||
local buffer = require("jj.core.buffer")
|
||||
|
||||
--- @class jj.ui.editor.highlights
|
||||
---@field added table Highlight settings for added lines
|
||||
---@field modified table Highlight settings for modified lines
|
||||
---@field deleted table Highlight settings for deleted lines
|
||||
---@field renamed table Highlight settings for renamed lines
|
||||
---@field added? table Highlight settings for added lines
|
||||
---@field modified? table Highlight settings for modified lines
|
||||
---@field deleted? table Highlight settings for deleted lines
|
||||
---@field renamed? table Highlight settings for renamed lines
|
||||
|
||||
M.highlights = {
|
||||
added = { fg = "#3fb950", ctermfg = "Green" },
|
||||
|
||||
Reference in New Issue
Block a user