@@ -246,6 +246,47 @@ function M._create_commands()
246
246
})
247
247
248
248
vim .api .nvim_create_user_command (" ClaudeCodeSend" , function (opts )
249
+ if not M .state .server then
250
+ logger .error (" command" , " ClaudeCodeSend: Claude Code integration is not running." )
251
+ return
252
+ end
253
+
254
+ local terminal = require (" claudecode.terminal" )
255
+ local bufnr = terminal .get_active_terminal_bufnr ()
256
+ if not bufnr then
257
+ logger .error (" command" , " ClaudeCodeSend: Could not find terminal buffer." )
258
+ return
259
+ end
260
+
261
+ if opts .fargs and # opts .fargs > 0 then
262
+ local file_path = table.concat (opts .fargs , " " )
263
+ local formatted_path = " @file " .. file_path
264
+ local last_line = vim .api .nvim_buf_line_count (bufnr )
265
+ vim .api .nvim_buf_set_lines (bufnr , last_line , - 1 , false , { formatted_path })
266
+ else
267
+ local lines = vim .api .nvim_buf_get_lines (bufnr , 0 , - 1 , false )
268
+ local content = table.concat (lines , " \n " )
269
+ M .state .server .send (content )
270
+ vim .api .nvim_buf_set_lines (bufnr , 0 , - 1 , false , { " " })
271
+ end
272
+ end , {
273
+ desc = " Send the content of the input buffer to Claude Code. Optionally add a file path." ,
274
+ nargs = " *" ,
275
+ })
276
+
277
+ vim .api .nvim_create_user_command (" ClaudeCodeTreeAddFile" , function ()
278
+ local integrations = require (" claudecode.integrations" )
279
+ local file_path = integrations .get_path_from_tree ()
280
+ if file_path then
281
+ vim .cmd (" ClaudeCodeSend " .. file_path )
282
+ else
283
+ logger .warn (" command" , " ClaudeCodeTreeAddFile: Could not determine file path from the tree." )
284
+ end
285
+ end , {
286
+ desc = " Add the selected file from a tree explorer to the Claude Code input buffer." ,
287
+ })
288
+
289
+ vim .api .nvim_create_user_command (" ClaudeCodeSendSelection" , function (opts )
249
290
if not M .state .server then
250
291
logger .error (" command" , " ClaudeCodeSend: Claude Code integration is not running." )
251
292
vim .notify (" Claude Code integration is not running" , vim .log .levels .ERROR )
0 commit comments