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

Commit90346e3

Browse files
author
Dan Rousseau
committed
feat: ability to pick a model when launching claude
1 parentc1cdcd5 commit90346e3

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

‎lua/claudecode/init.lua

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function M._create_commands()
299299
ifcurrent_mode=="v"orcurrent_mode=="V"orcurrent_mode=="\22"then-- \22 is CTRL-V (blockwise visual mode)
300300
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>",true,false,true),"n",false)
301301
end
302-
terminal.toggle({})-- `opts.fargs` can be used for future enhancements.
302+
terminal.toggle({},nil)-- `opts.fargs` can be used for future enhancements.
303303
end, {
304304
nargs="?",
305305
desc="Toggle the Claude Code terminal window",
@@ -323,6 +323,40 @@ function M._create_commands()
323323
"Terminal module not found. Terminal commands (ClaudeCode, ClaudeCodeOpen, ClaudeCodeClose) not registered."
324324
)
325325
end
326+
327+
vim.api.nvim_create_user_command("ClaudeSelectModel",function()
328+
M.open_with_model()
329+
end, {
330+
desc="Select and open Claude terminal with chosen model",
331+
})
332+
end
333+
334+
M.open_with_model=function()
335+
localmodels= {
336+
{name="Claude Opus 4 (Latest)",value="claude-opus-4-20250514"},
337+
{name="Claude Sonnet 4 (Latest)",value="claude-sonnet-4-20250514"},
338+
{name="Claude 3.7 Sonnet (Latest)",value="claude-3-7-sonnet-latest"},
339+
{name="Claude 3.5 Haiku (Latest)",value="claude-3-5-haiku-latest"},
340+
}
341+
342+
vim.ui.select(models, {
343+
prompt="Select Claude model:",
344+
format_item=function(item)
345+
returnitem.name
346+
end,
347+
},function(choice)
348+
ifnotchoicethen
349+
return-- User cancelled
350+
end
351+
352+
localterminal_ok,terminal=pcall(require,"claudecode.terminal")
353+
ifnotterminal_okthen
354+
vim.notify("Terminal module not available",vim.log.levels.ERROR)
355+
return
356+
end
357+
358+
terminal.toggle({},"--model"..choice.value)
359+
end)
326360
end
327361

328362
--- Get version information

‎lua/claudecode/terminal.lua

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ local native_term_tip_shown = false
3737
-- Uses the `terminal_cmd` from the module's configuration, or defaults to "claude".
3838
-- @local
3939
-- @return string The command to execute.
40-
localfunctionget_claude_command()
40+
localfunctionget_claude_command(model)
4141
localcmd_from_config=term_module_config.terminal_cmd
4242
ifnotcmd_from_configorcmd_from_config==""then
43+
ifmodel~=nilthen
44+
return"claude"..model-- Default if not configured
45+
end
4346
return"claude"-- Default if not configured
4447
end
4548
returncmd_from_config
@@ -332,8 +335,8 @@ end
332335
-- @local
333336
-- @return string|nil cmd_string The command string, or nil on failure.
334337
-- @return table|nil env_table The environment variables table, or nil on failure.
335-
localfunctionget_claude_command_and_env()
336-
localcmd_string=get_claude_command()
338+
localfunctionget_claude_command_and_env(model)
339+
localcmd_string=get_claude_command(model)
337340
ifnotcmd_stringorcmd_string==""then
338341
vim.notify("Claude terminal base command cannot be determined.",vim.log.levels.ERROR)
339342
returnnil,nil
@@ -387,10 +390,10 @@ end
387390

388391
--- Opens or focuses the Claude terminal.
389392
-- @param opts_override table (optional) Overrides for terminal appearance (split_side, split_width_percentage).
390-
functionM.open(opts_override)
393+
functionM.open(opts_override,model)
391394
localprovider=get_effective_terminal_provider()
392395
localeffective_config=build_effective_term_config(opts_override)
393-
localcmd_string,claude_env_table=get_claude_command_and_env()
396+
localcmd_string,claude_env_table=get_claude_command_and_env(model)
394397

395398
ifnotcmd_stringthen
396399
-- Error already notified by the helper function
@@ -460,10 +463,10 @@ end
460463

461464
--- Toggles the Claude terminal open or closed.
462465
-- @param opts_override table (optional) Overrides for terminal appearance (split_side, split_width_percentage).
463-
functionM.toggle(opts_override)
466+
functionM.toggle(opts_override,model)
464467
localprovider=get_effective_terminal_provider()
465468
localeffective_config=build_effective_term_config(opts_override)
466-
localcmd_string,claude_env_table=get_claude_command_and_env()
469+
localcmd_string,claude_env_table=get_claude_command_and_env(model)
467470

468471
ifnotcmd_stringthen
469472
return-- Error already notified

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp