mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-05 02:36:07 +00:00
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:
@@ -212,6 +212,11 @@ The plugin also provides `:Jdiff`, `:Jvdiff`, and `:Jhdiff` commands for diffing
|
||||
close_on_edit = false, -- Close log buffer after editing a change
|
||||
},
|
||||
|
||||
-- Configure bookmark command
|
||||
bookmark = {
|
||||
prefix = ""
|
||||
},
|
||||
|
||||
-- Configure keymaps for command buffers
|
||||
keymaps = {
|
||||
-- Log buffer keymaps (set to nil to disable)
|
||||
@@ -373,7 +378,20 @@ The `bookmark_create` function creates a new bookmark:
|
||||
|
||||
```lua
|
||||
local cmd = require("jj.cmd")
|
||||
cmd.bookmark_create() -- Prompts for bookmark name, then prompts the revision
|
||||
cmd.bookmark_create() -- Prompts for bookmark name, then prompts the revision
|
||||
cmd.bookmark_create({ prefix = "feature/" }) -- Uses prefix for default bookmark name
|
||||
```
|
||||
|
||||
You can also set a default bookmark prefix in the config:
|
||||
|
||||
```lua
|
||||
require("jj").setup({
|
||||
cmd = {
|
||||
bookmark = {
|
||||
prefix = "feature/" -- Default prefix when creating bookmarks
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The `bookmark_move` function moves an existing bookmark to a new revision:
|
||||
@@ -442,6 +460,9 @@ diff.open_hsplit({ rev = "@-2" }) -- Horizontal split against @-2
|
||||
}
|
||||
}
|
||||
},
|
||||
bookmark = {
|
||||
prefix = "feat/"
|
||||
},
|
||||
keymaps = {
|
||||
log = {
|
||||
checkout = "<CR>",
|
||||
|
||||
+13
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user