Movatterモバイル変換


[0]ホーム

URL:


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

feat: ability to pick a model when launching claude#18

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
TheLazyLemur wants to merge1 commit intocoder:main
base:main
Choose a base branch
Loading
fromTheLazyLemur:main
Open
Show file tree
Hide file tree
Changes fromall 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
36 changes: 35 additions & 1 deletionlua/claudecode/init.lua
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -299,7 +299,7 @@ function M._create_commands()
if current_mode == "v" or current_mode == "V" or current_mode == "\22" then -- \22 is CTRL-V (blockwise visual mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", false)
end
terminal.toggle({}) -- `opts.fargs` can be used for future enhancements.
terminal.toggle({}, nil) -- `opts.fargs` can be used for future enhancements.
end, {
nargs = "?",
desc = "Toggle the Claude Code terminal window",
Expand All@@ -323,6 +323,40 @@ function M._create_commands()
"Terminal module not found. Terminal commands (ClaudeCode, ClaudeCodeOpen, ClaudeCodeClose) not registered."
)
end

vim.api.nvim_create_user_command("ClaudeSelectModel", function()
M.open_with_model()
end, {
desc = "Select and open Claude terminal with chosen model",
})
end

M.open_with_model = function()
local models = {
{ name = "Claude Opus 4 (Latest)", value = "claude-opus-4-20250514" },
{ name = "Claude Sonnet 4 (Latest)", value = "claude-sonnet-4-20250514" },
{ name = "Claude 3.7 Sonnet (Latest)", value = "claude-3-7-sonnet-latest" },
{ name = "Claude 3.5 Haiku (Latest)", value = "claude-3-5-haiku-latest" },
}
Comment on lines +335 to +340
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do you think we can make this a user-configurable table?
This could be included in the defaults, and then when a new model version is released, one can update their configuration.


vim.ui.select(models, {
prompt = "Select Claude model:",
format_item = function(item)
return item.name
end,
}, function(choice)
if not choice then
return -- User cancelled
end

local terminal_ok, terminal = pcall(require, "claudecode.terminal")
if not terminal_ok then
vim.notify("Terminal module not available", vim.log.levels.ERROR)
return
end

terminal.toggle({}, "--model " .. choice.value)
end)
end

--- Get version information
Expand Down
17 changes: 10 additions & 7 deletionslua/claudecode/terminal.lua
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,9 +37,12 @@ local native_term_tip_shown = false
-- Uses the `terminal_cmd` from the module's configuration, or defaults to "claude".
-- @local
-- @return string The command to execute.
local function get_claude_command()
local function get_claude_command(model)
local cmd_from_config = term_module_config.terminal_cmd
if not cmd_from_config or cmd_from_config == "" then
if model ~= nil then
return "claude " .. model -- Default if not configured
end
return "claude" -- Default if not configured
end
return cmd_from_config
Expand DownExpand Up@@ -332,8 +335,8 @@ end
-- @local
-- @return string|nil cmd_string The command string, or nil on failure.
-- @return table|nil env_table The environment variables table, or nil on failure.
local function get_claude_command_and_env()
local cmd_string = get_claude_command()
local function get_claude_command_and_env(model)
local cmd_string = get_claude_command(model)
if not cmd_string or cmd_string == "" then
vim.notify("Claude terminal base command cannot be determined.", vim.log.levels.ERROR)
return nil, nil
Expand DownExpand Up@@ -387,10 +390,10 @@ end

--- Opens or focuses the Claude terminal.
-- @param opts_override table (optional) Overrides for terminal appearance (split_side, split_width_percentage).
function M.open(opts_override)
function M.open(opts_override, model)
local provider = get_effective_terminal_provider()
local effective_config = build_effective_term_config(opts_override)
local cmd_string, claude_env_table = get_claude_command_and_env()
local cmd_string, claude_env_table = get_claude_command_and_env(model)

if not cmd_string then
-- Error already notified by the helper function
Expand DownExpand Up@@ -460,10 +463,10 @@ end

--- Toggles the Claude terminal open or closed.
-- @param opts_override table (optional) Overrides for terminal appearance (split_side, split_width_percentage).
function M.toggle(opts_override)
function M.toggle(opts_override, model)
local provider = get_effective_terminal_provider()
local effective_config = build_effective_term_config(opts_override)
local cmd_string, claude_env_table = get_claude_command_and_env()
local cmd_string, claude_env_table = get_claude_command_and_env(model)

if not cmd_string then
return -- Error already notified
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp