on master help sign in
Support attach request
commit299da5a35b1917812a0f37e046d946031474d606 authorDmitry Sharshakov <d3dx12.xx@gmail.com> dateTue 24 Aug 2021, 20:27 (5 years ago) parentb001008
2 files changed+27−2
helix-term/src/commands.rs+7−2 languages.toml+20
helix-term/src/commands.rs+7−2
@@ -24,6 +24,7 @@ use helix_lsp::{
2424};
2525use insert::*;
2626use movement::Movement;
27+use serde_json::Value;
2728
2829use crate::{
2930 compositor::{self, Component, Compositor},
@@ -4454,7 +4455,7 @@ fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option<Vec<&s
44544455 };
44554456
44564457 let template = start_config.args.clone();
4457− let mut args = HashMap::new();
4458+ let mut args: HashMap<String, Value> = HashMap::new();
44584459
44594460 if let Some(params) = params {
44604461 for (k, t) in template {
@@ -4464,7 +4465,11 @@ fn dap_start_impl(editor: &mut Editor, name: Option<&str>, params: Option<Vec<&s
44644465 value = value.replace(format!("{{{}}}", i).as_str(), x);
44654466 }
44664467
4467− args.insert(k, value);
4468+ if let Ok(integer) = value.parse::<usize>() {
4469+ args.insert(k, Value::Number(serde_json::Number::from(integer)));
4470+ } else {
4471+ args.insert(k, Value::String(value));
4472+ }
44684473 }
44694474 }
44704475
languages.toml+20
@@ -32,6 +32,11 @@ name = "binary"
3232request = "launch"
3333args = { console = "internalConsole", program = "{0}" }
3434
35+[[language.debugger.templates]]
36+name = "attach"
37+request = "attach"
38+args = { console = "internalConsole", pid = "{0}" }
39+
3540[[language]]
3641name = "toml"
3742scope = "source.toml"
@@ -94,6 +99,11 @@ name = "binary"
9499request = "launch"
95100args = { console = "internalConsole", program = "main" }
96101
102+[[language.debugger.templates]]
103+name = "attach"
104+request = "attach"
105+args = { console = "internalConsole", pid = "{0}" }
106+
97107[[language]]
98108name = "cpp"
99109scope = "source.cpp"
@@ -117,6 +127,11 @@ name = "binary"
117127request = "launch"
118128args = { console = "internalConsole", program = "main" }
119129
130+[[language.debugger.templates]]
131+name = "attach"
132+request = "attach"
133+args = { console = "internalConsole", pid = "{0}" }
134+
120135[[language]]
121136name = "go"
122137scope = "source.go"
@@ -152,6 +167,11 @@ name = "test"
152167request = "launch"
153168args = { mode = "test", program = "{0}" }
154169
170+[[language.debugger.templates]]
171+name = "attach"
172+request = "attach"
173+args = { mode = "local", processId = "{0}" }
174+
155175[[language]]
156176name = "javascript"
157177scope = "source.js"