Skip to content

Commit 5acc233

Browse files
ThomasK33alex35mil
andcommitted
feat: add Shift+Enter keybinding for new line in terminal
Change-Id: I9a5eee55b87db158dbf93266ef809ca10216b070 Signed-off-by: Thomas Kosiewski <[email protected]> Co-authored-by: alex35mil <[email protected]>
1 parent cc09df9 commit 5acc233

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lua/claudecode/terminal/snacks.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ end
4545
---@param config ClaudeCodeTerminalConfig Terminal configuration
4646
---@param env_table table Environment variables to set for the terminal process
4747
---@param focus boolean|nil Whether to focus the terminal when opened (defaults to true)
48-
---@return table options Snacks terminal options with start_insert/auto_insert controlled by focus parameter
48+
---@return snacks.terminal.Opts opts Snacks terminal options with start_insert/auto_insert controlled by focus parameter
4949
local function build_opts(config, env_table, focus)
5050
focus = utils.normalize_focus(focus)
5151
return {
@@ -58,8 +58,21 @@ local function build_opts(config, env_table, focus)
5858
width = config.split_width_percentage,
5959
height = 0,
6060
relative = "editor",
61-
}, config.snacks_win_opts or {}),
62-
}
61+
keys = {
62+
claude_new_line = {
63+
"<S-CR>",
64+
function()
65+
vim.api.nvim_feedkeys("\\", "t", true)
66+
vim.defer_fn(function()
67+
vim.api.nvim_feedkeys("\r", "t", true)
68+
end, 10)
69+
end,
70+
mode = "t",
71+
desc = "New line",
72+
},
73+
},
74+
} --[[@as snacks.win.Config]], config.snacks_win_opts or {}),
75+
} --[[@as snacks.terminal.Opts]]
6376
end
6477

6578
function M.setup()

lua/claudecode/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
---@field provider_opts ClaudeCodeTerminalProviderOptions?
7575
---@field auto_close boolean
7676
---@field env table<string, string>
77-
---@field snacks_win_opts table
77+
---@field snacks_win_opts snacks.win.Config
7878

7979
-- Port range configuration
8080
---@class ClaudeCodePortRange

0 commit comments

Comments
 (0)