mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-15 23:53:18 +00:00
Change the :J describe behaviour to open an editable buffer instead of an input box (#6)
Co-authored-by: fautore <fautore@protonmail.com>
This commit is contained in:
@@ -16,7 +16,7 @@ This plugin aims to be something like vim-fugitive but for driving the jj-vcs CL
|
||||
- Terminal-based output display for jj commands
|
||||
- Support jj subcommands including your aliases through the cmdline.
|
||||
- First class citizens with ui integration
|
||||
- `describe` - Set change descriptions
|
||||
- `describe` - Set change descriptions with a Git-style commit message editor
|
||||
- `status` / `st` - Show repository status
|
||||
- `log` - Display log history with configurable options
|
||||
- `diff` - Show changes
|
||||
@@ -91,11 +91,66 @@ The plugin provides a `:J` command that accepts jj subcommands:
|
||||
snacks = {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
-- Choose the editor mode for describe command
|
||||
-- "buffer" - Opens a Git-style commit message buffer with syntax highlighting (default)
|
||||
-- "input" - Uses a simple vim.ui.input prompt
|
||||
describe_editor = "buffer",
|
||||
|
||||
-- Customize syntax highlighting colors for the describe buffer
|
||||
highlights = {
|
||||
added = { fg = "#3fb950", ctermfg = "Green" }, -- Added files
|
||||
modified = { fg = "#56d4dd", ctermfg = "Cyan" }, -- Modified files
|
||||
deleted = { fg = "#f85149", ctermfg = "Red" }, -- Deleted files
|
||||
renamed = { fg = "#d29922", ctermfg = "Yellow" }, -- Renamed files
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Describe Editor Modes
|
||||
|
||||
The `describe_editor` option lets you choose how you want to write commit descriptions:
|
||||
|
||||
- **`"buffer"`** (default) - Opens a full buffer editor similar to Git's commit message editor
|
||||
- Shows file changes with syntax highlighting
|
||||
- Multi-line editing with proper formatting
|
||||
- Close with `q` or `<Esc>`, save with `:w` or `:wq`
|
||||
|
||||
- **`"input"`** - Simple single-line input prompt
|
||||
- Quick and minimal
|
||||
- Good for short, single-line descriptions
|
||||
- Uses `vim.ui.input()` which can be customized by UI plugins like dressing.nvim
|
||||
|
||||
Example:
|
||||
```lua
|
||||
require("jj").setup({
|
||||
describe_editor = "input", -- Use simple input mode
|
||||
})
|
||||
```
|
||||
|
||||
### Highlight Customization
|
||||
|
||||
The `highlights` option allows you to customize the colors used in the describe buffer's file status display. Each highlight accepts standard Neovim highlight attributes:
|
||||
|
||||
- `fg` - Foreground color (hex or color name)
|
||||
- `bg` - Background color
|
||||
- `ctermfg` - Terminal foreground color
|
||||
- `ctermbg` - Terminal background color
|
||||
- `bold`, `italic`, `underline` - Text styles
|
||||
|
||||
Example with custom colors:
|
||||
|
||||
```lua
|
||||
require("jj").setup({
|
||||
highlights = {
|
||||
modified = { fg = "#89ddff", bold = true },
|
||||
added = { fg = "#c3e88d", ctermfg = "LightGreen" },
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Example config
|
||||
|
||||
```lua
|
||||
@@ -105,35 +160,38 @@ The plugin provides a `:J` command that accepts jj subcommands:
|
||||
"folke/snacks.nvim", -- Optional only if you use picker's
|
||||
},
|
||||
config = function()
|
||||
require("jj").setup({})
|
||||
local cmd = require "jj.cmd"
|
||||
vim.keymap.set("n", "<leader>jd", cmd.describe, { desc = "JJ describe" })
|
||||
vim.keymap.set("n", "<leader>jl", cmd.log, { desc = "JJ log" })
|
||||
vim.keymap.set("n", "<leader>je", cmd.edit, { desc = "JJ edit" })
|
||||
vim.keymap.set("n", "<leader>jn", cmd.new, { desc = "JJ new" })
|
||||
vim.keymap.set("n", "<leader>js", cmd.status, { desc = "JJ status" })
|
||||
vim.keymap.set("n", "<leader>dj", cmd.diff, { desc = "JJ diff" })
|
||||
vim.keymap.set("n", "<leader>sj", cmd.squash, { desc = "JJ squash" })
|
||||
require("jj").setup({
|
||||
highlights = {
|
||||
-- Customize colors if desired
|
||||
modified = { fg = "#89ddff" },
|
||||
}
|
||||
})
|
||||
|
||||
-- Use the exposed functions directly from the main module
|
||||
local jj = require("jj")
|
||||
vim.keymap.set("n", "<leader>jd", jj.describe, { desc = "JJ describe" })
|
||||
vim.keymap.set("n", "<leader>jl", jj.log, { desc = "JJ log" })
|
||||
vim.keymap.set("n", "<leader>je", jj.edit, { desc = "JJ edit" })
|
||||
vim.keymap.set("n", "<leader>jn", jj.new, { desc = "JJ new" })
|
||||
vim.keymap.set("n", "<leader>js", jj.status, { desc = "JJ status" })
|
||||
vim.keymap.set("n", "<leader>dj", jj.diff, { desc = "JJ diff" })
|
||||
vim.keymap.set("n", "<leader>sj", jj.squash, { desc = "JJ squash" })
|
||||
|
||||
-- Pickers
|
||||
vim.keymap.set("n", "<leader>gj", function()
|
||||
require("jj.picker").status()
|
||||
end, { desc = "JJ Picker status" })
|
||||
vim.keymap.set("n", "<leader>gl", function()
|
||||
require("jj.picker").file_history()
|
||||
end, { desc = "JJ Picker file history" })
|
||||
|
||||
|
||||
local picker = require("jj.picker")
|
||||
vim.keymap.set("n", "<leader>gj", picker.status, { desc = "JJ Picker status" })
|
||||
vim.keymap.set("n", "<leader>gl", picker.file_history, { desc = "JJ Picker file history" })
|
||||
|
||||
-- Some functions like `describe` or `log` can take parameters
|
||||
vim.keymap.set("n", "<leader>jl", function()
|
||||
cmd.log {
|
||||
vim.keymap.set("n", "<leader>jL", function()
|
||||
jj.log {
|
||||
revisions = "all()",
|
||||
}
|
||||
end, { desc = "JJ log" })
|
||||
end, { desc = "JJ log all" })
|
||||
|
||||
-- This is an alias i use for moving bookmarks its so good
|
||||
vim.keymap.set("n", "<leader>jt", function()
|
||||
local cmd = require("jj.cmd")
|
||||
cmd.j "tug"
|
||||
cmd.log {}
|
||||
end, { desc = "JJ tug" })
|
||||
|
||||
Reference in New Issue
Block a user