Skip to content

feat: add Shift+Enter keybinding for new line in terminal #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: thomask33/feat_add_PartialClaudeCodeConfig_type_for_better_configuration_handling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions lua/claudecode/terminal/snacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
---@param config ClaudeCodeTerminalConfig Terminal configuration
---@param env_table table Environment variables to set for the terminal process
---@param focus boolean|nil Whether to focus the terminal when opened (defaults to true)
---@return table options Snacks terminal options with start_insert/auto_insert controlled by focus parameter
---@return snacks.terminal.Opts opts Snacks terminal options with start_insert/auto_insert controlled by focus parameter
local function build_opts(config, env_table, focus)
focus = utils.normalize_focus(focus)
return {
Expand All @@ -58,8 +58,21 @@ local function build_opts(config, env_table, focus)
width = config.split_width_percentage,
height = 0,
relative = "editor",
}, config.snacks_win_opts or {}),
}
keys = {
claude_new_line = {
"<S-CR>",
function()
vim.api.nvim_feedkeys("\\", "t", true)
vim.defer_fn(function()
vim.api.nvim_feedkeys("\r", "t", true)
end, 10)
end,
mode = "t",
desc = "New line",
},
},
} --[[@as snacks.win.Config]], config.snacks_win_opts or {}),
} --[[@as snacks.terminal.Opts]]
end

function M.setup()
Expand Down
2 changes: 1 addition & 1 deletion lua/claudecode/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
---@field provider_opts ClaudeCodeTerminalProviderOptions?
---@field auto_close boolean
---@field env table<string, string>
---@field snacks_win_opts table
---@field snacks_win_opts snacks.win.Config

-- Port range configuration
---@class ClaudeCodePortRange
Expand Down