@@ -3,6 +3,7 @@ local util = require('opencode.util')
33local session = require (' opencode.session' )
44local config_file = require (' opencode.config_file' )
55local state = require (' opencode.state' )
6+ local quick_chat = require (' opencode.quick_chat' )
67
78local input_window = require (' opencode.ui.input_window' )
89local ui = require (' opencode.ui.ui' )
@@ -107,6 +108,15 @@ function M.select_history()
107108 require (' opencode.ui.history_picker' ).pick ()
108109end
109110
111+ function M .quick_chat (message , range )
112+ local options = {}
113+ if type (message ) == ' table' then
114+ message = table.concat (message , ' ' )
115+ end
116+
117+ return quick_chat .quick_chat (message , options , range )
118+ end
119+
110120function M .toggle_pane ()
111121 return core .open ({ new_session = false , focus = ' output' }):and_then (function ()
112122 ui .toggle_pane ()
@@ -957,6 +967,14 @@ M.commands = {
957967 fn = M .toggle_zoom ,
958968 },
959969
970+ quick_chat = {
971+ desc = ' Quick chat with current context' ,
972+ fn = M .quick_chat ,
973+ range = true , -- Enable range support for visual selections
974+ nargs = ' +' , -- Allow multiple arguments
975+ complete = false , -- No completion for custom messages
976+ },
977+
960978 swap = {
961979 desc = ' Swap pane position left/right' ,
962980 fn = M .swap_position ,
@@ -1284,6 +1302,14 @@ M.legacy_command_map = {
12841302
12851303function M .route_command (opts )
12861304 local args = vim .split (opts .args or ' ' , ' %s+' , { trimempty = true })
1305+ local range = nil
1306+
1307+ if opts .range and opts .range > 0 then
1308+ range = {
1309+ start = opts .line1 ,
1310+ stop = opts .line2 ,
1311+ }
1312+ end
12871313
12881314 if # args == 0 then
12891315 M .toggle ()
@@ -1294,7 +1320,7 @@ function M.route_command(opts)
12941320 local subcmd_def = M .commands [subcommand ]
12951321
12961322 if subcmd_def and subcmd_def .fn then
1297- subcmd_def .fn (vim .list_slice (args , 2 ))
1323+ subcmd_def .fn (vim .list_slice (args , 2 ), range )
12981324 else
12991325 vim .notify (' Unknown subcommand: ' .. subcommand , vim .log .levels .ERROR )
13001326 end
@@ -1388,6 +1414,7 @@ function M.setup()
13881414 vim .api .nvim_create_user_command (' Opencode' , M .route_command , {
13891415 desc = ' Opencode.nvim main command with nested subcommands' ,
13901416 nargs = ' *' ,
1417+ range = true , -- Enable range support
13911418 complete = M .complete_command ,
13921419 })
13931420
0 commit comments