Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8879ae0

Browse files
feat: redesign diff view with horizontal layout and new tab options
Change-Id: Ia8df210bad3a05b7eddd92fafbbb4f8aa90e2704 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent e21a837 commit 8879ae0

File tree

13 files changed

+1175
-271
lines changed

13 files changed

+1175
-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: 46 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" },
@@ -106,13 +105,39 @@ function M.validate(config)
106105
assert(type(config.queue_timeout) == "number" and config.queue_timeout > 0, "queue_timeout must be a positive number")
107106

108107
assert(type(config.diff_opts) == "table", "diff_opts must be a table")
109-
assert(type(config.diff_opts.auto_close_on_accept) == "boolean", "diff_opts.auto_close_on_accept must be a boolean")
110-
assert(type(config.diff_opts.show_diff_stats) == "boolean", "diff_opts.show_diff_stats must be a boolean")
111-
assert(type(config.diff_opts.vertical_split) == "boolean", "diff_opts.vertical_split must be a boolean")
112-
assert(type(config.diff_opts.open_in_current_tab) == "boolean", "diff_opts.open_in_current_tab must be a boolean")
108+
-- New diff options (optional validation to allow backward compatibility)
109+
if config.diff_opts.layout ~= nil then
110+
assert(
111+
config.diff_opts.layout == "vertical" or config.diff_opts.layout == "horizontal",
112+
"diff_opts.layout must be 'vertical' or 'horizontal'"
113+
)
114+
end
115+
if config.diff_opts.open_in_new_tab ~= nil then
116+
assert(type(config.diff_opts.open_in_new_tab) == "boolean", "diff_opts.open_in_new_tab must be a boolean")
117+
end
113118
if config.diff_opts.keep_terminal_focus ~= nil then
114119
assert(type(config.diff_opts.keep_terminal_focus) == "boolean", "diff_opts.keep_terminal_focus must be a boolean")
115120
end
121+
if config.diff_opts.hide_terminal_in_new_tab ~= nil then
122+
assert(
123+
type(config.diff_opts.hide_terminal_in_new_tab) == "boolean",
124+
"diff_opts.hide_terminal_in_new_tab must be a boolean"
125+
)
126+
end
127+
128+
-- Legacy diff options (accept if present to avoid breaking old configs)
129+
if config.diff_opts.auto_close_on_accept ~= nil then
130+
assert(type(config.diff_opts.auto_close_on_accept) == "boolean", "diff_opts.auto_close_on_accept must be a boolean")
131+
end
132+
if config.diff_opts.show_diff_stats ~= nil then
133+
assert(type(config.diff_opts.show_diff_stats) == "boolean", "diff_opts.show_diff_stats must be a boolean")
134+
end
135+
if config.diff_opts.vertical_split ~= nil then
136+
assert(type(config.diff_opts.vertical_split) == "boolean", "diff_opts.vertical_split must be a boolean")
137+
end
138+
if config.diff_opts.open_in_current_tab ~= nil then
139+
assert(type(config.diff_opts.open_in_current_tab) == "boolean", "diff_opts.open_in_current_tab must be a boolean")
140+
end
116141

117142
-- Validate env
118143
assert(type(config.env) == "table", "env must be a table")
@@ -160,6 +185,19 @@ function M.apply(user_config)
160185
end
161186
end
162187

188+
-- Backward compatibility: map legacy diff options to new fields if provided
189+
if config.diff_opts then
190+
local d = config.diff_opts
191+
-- Map vertical_split -> layout (only if layout not explicitly set)
192+
if d.layout == nil and type(d.vertical_split) == "boolean" then
193+
d.layout = d.vertical_split and "vertical" or "horizontal"
194+
end
195+
-- Map open_in_current_tab -> open_in_new_tab (invert; only if not explicitly set)
196+
if d.open_in_new_tab == nil and type(d.open_in_current_tab) == "boolean" then
197+
d.open_in_new_tab = not d.open_in_current_tab
198+
end
199+
end
200+
163201
M.validate(config)
164202

165203
return config

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /