@@ -260,7 +260,7 @@ function M.send_at_mention(file_path, start_line, end_line, context)
260
260
if M .is_claude_connected () then
261
261
-- Claude is connected, send immediately and ensure terminal is visible
262
262
local success , error_msg = M ._broadcast_at_mention (file_path , start_line , end_line )
263
- if success then
263
+ if success and M . state . config . enable_terminal then
264
264
local terminal = require (" claudecode.terminal" )
265
265
terminal .ensure_visible ()
266
266
end
@@ -276,9 +276,11 @@ function M.send_at_mention(file_path, start_line, end_line, context)
276
276
277
277
queue_at_mention (mention_data )
278
278
279
- -- Launch terminal with Claude Code
280
- local terminal = require (" claudecode.terminal" )
281
- terminal .open ()
279
+ -- Launch terminal with Claude Code if enabled
280
+ if M .state .config .enable_terminal then
281
+ local terminal = require (" claudecode.terminal" )
282
+ terminal .open ()
283
+ end
282
284
283
285
logger .debug (context , " Queued @ mention and launched Claude Code: " .. file_path )
284
286
@@ -307,15 +309,17 @@ function M.setup(opts)
307
309
308
310
-- Setup terminal module: always try to call setup to pass terminal_cmd,
309
311
-- even if terminal_opts (for split_side etc.) are not provided.
310
- local terminal_setup_ok , terminal_module = pcall (require , " claudecode.terminal" )
311
- if terminal_setup_ok then
312
- -- Guard in case tests or user replace the module with a minimal stub without `setup`.
313
- if type (terminal_module .setup ) == " function" then
314
- -- terminal_opts might be nil, which the setup function should handle gracefully.
315
- terminal_module .setup (terminal_opts , M .state .config .terminal_cmd )
312
+ if M .state .config .enable_terminal then
313
+ local terminal_setup_ok , terminal_module = pcall (require , " claudecode.terminal" )
314
+ if terminal_setup_ok then
315
+ -- Guard in case tests or user replace the module with a minimal stub without `setup`.
316
+ if type (terminal_module .setup ) == " function" then
317
+ -- terminal_opts might be nil, which the setup function should handle gracefully.
318
+ terminal_module .setup (terminal_opts , M .state .config .terminal_cmd )
319
+ end
320
+ else
321
+ logger .error (" init" , " Failed to load claudecode.terminal module for setup." )
316
322
end
317
- else
318
- logger .error (" init" , " Failed to load claudecode.terminal module for setup." )
319
323
end
320
324
321
325
local diff = require (" claudecode.diff" )
@@ -882,50 +886,52 @@ function M._create_commands()
882
886
desc = " Add specified file or directory to Claude Code context with optional line range" ,
883
887
})
884
888
885
- local terminal_ok , terminal = pcall (require , " claudecode.terminal" )
886
- if terminal_ok then
887
- vim .api .nvim_create_user_command (" ClaudeCode" , function (opts )
888
- local current_mode = vim .fn .mode ()
889
- if current_mode == " v" or current_mode == " V" or current_mode == " \22 " then
890
- vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (" <Esc>" , true , false , true ), " n" , false )
891
- end
892
- local cmd_args = opts .args and opts .args ~= " " and opts .args or nil
893
- terminal .simple_toggle ({}, cmd_args )
894
- end , {
895
- nargs = " *" ,
896
- desc = " Toggle the Claude Code terminal window (simple show/hide) with optional arguments" ,
897
- })
898
-
899
- vim .api .nvim_create_user_command (" ClaudeCodeFocus" , function (opts )
900
- local current_mode = vim .fn .mode ()
901
- if current_mode == " v" or current_mode == " V" or current_mode == " \22 " then
902
- vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (" <Esc>" , true , false , true ), " n" , false )
903
- end
904
- local cmd_args = opts .args and opts .args ~= " " and opts .args or nil
905
- terminal .focus_toggle ({}, cmd_args )
906
- end , {
907
- nargs = " *" ,
908
- desc = " Smart focus/toggle Claude Code terminal (switches to terminal if not focused, hides if focused)" ,
909
- })
910
-
911
- vim .api .nvim_create_user_command (" ClaudeCodeOpen" , function (opts )
912
- local cmd_args = opts .args and opts .args ~= " " and opts .args or nil
913
- terminal .open ({}, cmd_args )
914
- end , {
915
- nargs = " *" ,
916
- desc = " Open the Claude Code terminal window with optional arguments" ,
917
- })
918
-
919
- vim .api .nvim_create_user_command (" ClaudeCodeClose" , function ()
920
- terminal .close ()
921
- end , {
922
- desc = " Close the Claude Code terminal window" ,
923
- })
924
- else
925
- logger .error (
926
- " init" ,
927
- " Terminal module not found. Terminal commands (ClaudeCode, ClaudeCodeOpen, ClaudeCodeClose) not registered."
928
- )
889
+ if M .state .config .enable_terminal then
890
+ local terminal_ok , terminal = pcall (require , " claudecode.terminal" )
891
+ if terminal_ok then
892
+ vim .api .nvim_create_user_command (" ClaudeCode" , function (opts )
893
+ local current_mode = vim .fn .mode ()
894
+ if current_mode == " v" or current_mode == " V" or current_mode == " \22 " then
895
+ vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (" <Esc>" , true , false , true ), " n" , false )
896
+ end
897
+ local cmd_args = opts .args and opts .args ~= " " and opts .args or nil
898
+ terminal .simple_toggle ({}, cmd_args )
899
+ end , {
900
+ nargs = " *" ,
901
+ desc = " Toggle the Claude Code terminal window (simple show/hide) with optional arguments" ,
902
+ })
903
+
904
+ vim .api .nvim_create_user_command (" ClaudeCodeFocus" , function (opts )
905
+ local current_mode = vim .fn .mode ()
906
+ if current_mode == " v" or current_mode == " V" or current_mode == " \22 " then
907
+ vim .api .nvim_feedkeys (vim .api .nvim_replace_termcodes (" <Esc>" , true , false , true ), " n" , false )
908
+ end
909
+ local cmd_args = opts .args and opts .args ~= " " and opts .args or nil
910
+ terminal .focus_toggle ({}, cmd_args )
911
+ end , {
912
+ nargs = " *" ,
913
+ desc = " Smart focus/toggle Claude Code terminal (switches to terminal if not focused, hides if focused)" ,
914
+ })
915
+
916
+ vim .api .nvim_create_user_command (" ClaudeCodeOpen" , function (opts )
917
+ local cmd_args = opts .args and opts .args ~= " " and opts .args or nil
918
+ terminal .open ({}, cmd_args )
919
+ end , {
920
+ nargs = " *" ,
921
+ desc = " Open the Claude Code terminal window with optional arguments" ,
922
+ })
923
+
924
+ vim .api .nvim_create_user_command (" ClaudeCodeClose" , function ()
925
+ terminal .close ()
926
+ end , {
927
+ desc = " Close the Claude Code terminal window" ,
928
+ })
929
+ else
930
+ logger .error (
931
+ " init" ,
932
+ " Terminal module not found. Terminal commands (ClaudeCode, ClaudeCodeOpen, ClaudeCodeClose) not registered."
933
+ )
934
+ end
929
935
end
930
936
931
937
-- Diff management commands
0 commit comments