@@ -8,9 +8,9 @@ use std::{collections::HashMap, path::Path};
88use language_servers:: { LanguageServer , Rubocop , RubyLsp , Solargraph , Sorbet , Steep } ;
99use serde:: { Deserialize , Serialize } ;
1010use zed_extension_api:: {
11- self as zed, resolve_tcp_template, Command , DebugAdapterBinary , DebugTaskDefinition ,
12- StartDebuggingRequestArguments , StartDebuggingRequestArgumentsRequest , TcpArgumentsTemplate ,
13- Worktree ,
11+ self as zed, resolve_tcp_template, Command , DebugAdapterBinary , DebugConfig , DebugRequest ,
12+ DebugScenario , DebugTaskDefinition , StartDebuggingRequestArguments ,
13+ StartDebuggingRequestArgumentsRequest , TcpArgumentsTemplate , Worktree ,
1414} ;
1515
1616#[ derive( Default ) ]
@@ -191,6 +191,43 @@ impl zed::Extension for RubyExtension {
191191 } ,
192192 } )
193193 }
194+ fn dap_request_kind (
195+ & mut self ,
196+ _: String ,
197+ _: serde_json:: Value ,
198+ ) -> zed_extension_api:: Result < StartDebuggingRequestArgumentsRequest , String > {
199+ Ok ( StartDebuggingRequestArgumentsRequest :: Launch )
200+ }
201+ fn dap_config_to_scenario (
202+ & mut self ,
203+ zed_scenario : DebugConfig ,
204+ ) -> Result < DebugScenario , String > {
205+ match zed_scenario. request {
206+ DebugRequest :: Launch ( launch) => {
207+ let config = RubyDebugConfig {
208+ script_or_command : Some ( launch. program ) ,
209+ script : None ,
210+ command : None ,
211+ args : launch. args ,
212+ env : launch. envs . into_iter ( ) . collect ( ) ,
213+ cwd : launch. cwd . clone ( ) ,
214+ } ;
215+
216+ let config = serde_json:: to_value ( config)
217+ . map_err ( |e| e. to_string ( ) ) ?
218+ . to_string ( ) ;
219+
220+ Ok ( DebugScenario {
221+ adapter : zed_scenario. adapter ,
222+ label : zed_scenario. label ,
223+ config,
224+ tcp_connection : None ,
225+ build : None ,
226+ } )
227+ }
228+ DebugRequest :: Attach ( _) => Err ( "Attach requests are unsupported" . into ( ) ) ,
229+ }
230+ }
194231}
195232
196233zed_extension_api:: register_extension!( RubyExtension ) ;
0 commit comments