Skip to content

Commit 763ee39

Browse files
committed
feat: redesign diff view with horizontal layout and new tab options
Change-Id: Ia8df210bad3a05b7eddd92fafbbb4f8aa90e2704 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 985b4b1 commit 763ee39

File tree

13 files changed

+1141
-271
lines changed

13 files changed

+1141
-271
lines changed

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,17 @@ require("claudecode").setup({
289289
The `diff_opts` configuration allows you to customize diff behavior:
290290

291291
- `keep_terminal_focus` (boolean, default: `false`) - When enabled, keeps focus in the Claude Code terminal when a diff opens instead of moving focus to the diff buffer. This allows you to continue using terminal keybindings like `<CR>` for accepting/rejecting diffs without accidentally triggering other mappings.
292+
- `open_in_new_tab` (boolean, default: `false`) - Open diffs in a new tab instead of the current tab.
293+
- `hide_terminal_in_new_tab` (boolean, default: `false`) - When opening diffs in a new tab, do not show the Claude terminal split in that new tab. The terminal remains in the original tab, giving maximum screen estate for reviewing the diff.
292294

293295
**Example use case**: If you frequently use `<CR>` or arrow keys in the Claude Code terminal to accept/reject diffs, enable this option to prevent focus from moving to the diff buffer where `<CR>` might trigger unintended actions.
294296

295297
```lua
296298
require("claudecode").setup({
297299
diff_opts = {
298300
keep_terminal_focus = true, -- If true, moves focus back to terminal after diff opens
301+
open_in_new_tab = true, -- Open diff in a separate tab
302+
hide_terminal_in_new_tab = true, -- In the new tab, do not show Claude terminal
299303
auto_close_on_accept = true,
300304
show_diff_stats = true,
301305
vertical_split = true,

dev-config.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,29 @@ return {
4040
},
4141

4242
-- Development configuration - all options shown with defaults commented out
43+
---@type ClaudeCodeConfig
4344
opts = {
4445
-- Server Configuration
45-
-- port_range = { min = 10000, max = 65535 }, -- WebSocket server port range
46-
-- auto_start = true, -- Auto-start server on Neovim startup
47-
-- log_level = "info", -- "trace", "debug", "info", "warn", "error"
48-
-- terminal_cmd = nil, -- Custom terminal command (default: "claude")
46+
-- port_range = { min = 10000, max = 65535 }, -- WebSocket server port range
47+
-- auto_start = true, -- Auto-start server on Neovim startup
48+
-- log_level = "info", -- "trace", "debug", "info", "warn", "error"
49+
-- terminal_cmd = nil, -- Custom terminal command (default: "claude")
4950

5051
-- Selection Tracking
51-
-- track_selection = true, -- Enable real-time selection tracking
52-
-- visual_demotion_delay_ms = 50, -- Delay before demoting visual selection (ms)
52+
-- track_selection = true, -- Enable real-time selection tracking
53+
-- visual_demotion_delay_ms = 50, -- Delay before demoting visual selection (ms)
5354

5455
-- Connection Management
55-
-- connection_wait_delay = 200, -- Wait time after connection before sending queued @ mentions (ms)
56-
-- connection_timeout = 10000, -- Max time to wait for Claude Code connection (ms)
57-
-- queue_timeout = 5000, -- Max time to keep @ mentions in queue (ms)
56+
-- connection_wait_delay = 200, -- Wait time after connection before sending queued @ mentions (ms)
57+
-- connection_timeout = 10000, -- Max time to wait for Claude Code connection (ms)
58+
-- queue_timeout = 5000, -- Max time to keep @ mentions in queue (ms)
5859

5960
-- Diff Integration
6061
-- diff_opts = {
61-
-- auto_close_on_accept = true, -- Close diff view after accepting changes
62-
-- show_diff_stats = true, -- Show diff statistics
63-
-- vertical_split = true, -- Use vertical split for diffs
64-
-- open_in_current_tab = true, -- Open diffs in current tab vs new tab
65-
-- keep_terminal_focus = false, -- If true, moves focus back to terminal after diff opens
62+
-- layout = "horizontal", -- "vertical" or "horizontal" diff layout
63+
-- open_in_new_tab = true, -- Open diff in a new tab (false = use current tab)
64+
-- keep_terminal_focus = true, -- Keep focus in terminal after opening diff
65+
-- hide_terminal_in_new_tab = true, -- Hide Claude terminal in the new diff tab for more review space
6666
-- },
6767

6868
-- Terminal Configuration

fixtures/nvim-tree/lazy-lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
3-
"nvim-tree.lua": { "branch": "master", "commit": "0a7fcdf3f8ba208f4260988a198c77ec11748339" },
3+
"nvim-tree.lua": { "branch": "master", "commit": "0a52012d611f3c1492b8d2aba363fabf734de91d" },
44
"nvim-web-devicons": { "branch": "master", "commit": "3362099de3368aa620a8105b19ed04c2053e38c0" },
55
"tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }
66
}

lua/claudecode/config.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ M.defaults = {
1919
connection_timeout = 10000, -- Maximum time to wait for Claude Code to connect (milliseconds)
2020
queue_timeout = 5000, -- Maximum time to keep @ mentions in queue (milliseconds)
2121
diff_opts = {
22-
auto_close_on_accept = true,
23-
show_diff_stats = true,
24-
vertical_split = true,
25-
open_in_current_tab = true, -- Use current tab instead of creating new tab
22+
layout = "vertical",
23+
open_in_new_tab = false, -- Open diff in a new tab (false = use current tab)
2624
keep_terminal_focus = false, -- If true, moves focus back to terminal after diff opens
25+
hide_terminal_in_new_tab = false, -- If true and opening in a new tab, do not show Claude terminal there
2726
},
2827
models = {
2928
{ name = "Claude Opus 4.1 (Latest)", value = "opus" },
@@ -104,11 +103,16 @@ function M.validate(config)
104103
assert(type(config.queue_timeout) == "number" and config.queue_timeout > 0, "queue_timeout must be a positive number")
105104

106105
assert(type(config.diff_opts) == "table", "diff_opts must be a table")
107-
assert(type(config.diff_opts.auto_close_on_accept) == "boolean", "diff_opts.auto_close_on_accept must be a boolean")
108-
assert(type(config.diff_opts.show_diff_stats) == "boolean", "diff_opts.show_diff_stats must be a boolean")
109-
assert(type(config.diff_opts.vertical_split) == "boolean", "diff_opts.vertical_split must be a boolean")
110-
assert(type(config.diff_opts.open_in_current_tab) == "boolean", "diff_opts.open_in_current_tab must be a boolean")
106+
assert(
107+
config.diff_opts.layout == "vertical" or config.diff_opts.layout == "horizontal",
108+
"diff_opts.layout must be 'vertical' or 'horizontal'"
109+
)
110+
assert(type(config.diff_opts.open_in_new_tab) == "boolean", "diff_opts.open_in_new_tab must be a boolean")
111111
assert(type(config.diff_opts.keep_terminal_focus) == "boolean", "diff_opts.keep_terminal_focus must be a boolean")
112+
assert(
113+
type(config.diff_opts.hide_terminal_in_new_tab) == "boolean",
114+
"diff_opts.hide_terminal_in_new_tab must be a boolean"
115+
)
112116

113117
-- Validate env
114118
assert(type(config.env) == "table", "env must be a table")

0 commit comments

Comments
 (0)