feat(bookmark): add prefix configuration for bookmark creation

- Add `prefix` option to `bookmark_create()` function for setting default bookmark names
- Add `bookmark.prefix` configuration option for global bookmark prefix defaults
- Update README with bookmark prefix usage examples
This commit is contained in:
NicolasGB
2025-12-18 19:43:36 +10:00
parent 43b5a81771
commit 1fd8faed4b
2 changed files with 35 additions and 2 deletions
+13 -1
View File
@@ -43,6 +43,9 @@ local status_module = require("jj.cmd.status")
--- @field open_pr_list? string|string[]
--- @field bookmark? string|string[]
--- @class jj.cmd.bookmark
--- @field prefix? string Prefix to append when creating a bookmark
--- @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[]
@@ -60,6 +63,7 @@ local status_module = require("jj.cmd.status")
--- @class jj.cmd.opts
--- @field describe? jj.cmd.describe
--- @field log? jj.cmd.log
--- @field bookmark? jj.cmd.bookmark
--- @field keymaps? jj.cmd.keymaps Keymaps for the buffers containing the of the commands
---
--- @class jj.cmd.keymap_spec
@@ -88,6 +92,9 @@ M.config = {
log = {
close_on_edit = false,
},
bookmark = {
prefix = "",
},
keymaps = {
log = {
edit = "<CR>",
@@ -348,14 +355,19 @@ function M.rebase()
end
-- Jujutsu create bookmark
function M.bookmark_create()
--- @param opts? jj.cmd.bookmark The options for the bookmark command
function M.bookmark_create(opts)
if not utils.ensure_jj() then
return
end
-- Try and get the bookmark from the params
local bookmark_prefix = (opts and opts.prefix) or (M.config.bookmark and M.config.bookmark.prefix) or ""
M.log({})
vim.ui.input({
prompt = "Bookmark name: ",
default = bookmark_prefix,
}, function(input)
if input then
-- Get the revset