Successfully feature gate DAP

gui
Blaž Hrastnik 3 years ago
parent d7b1c40452
commit dcd1e9eaa3
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -16,6 +16,8 @@ build = true
app = true app = true
[features] [features]
# default = ["dap"]
dap = ["helix-dap", "helix-view/dap"]
unicode-lines = ["helix-core/unicode-lines"] unicode-lines = ["helix-core/unicode-lines"]
[[bin]] [[bin]]
@ -26,7 +28,7 @@ path = "src/main.rs"
helix-core = { version = "0.6", path = "../helix-core" } helix-core = { version = "0.6", path = "../helix-core" }
helix-view = { version = "0.6", path = "../helix-view" } helix-view = { version = "0.6", path = "../helix-view" }
helix-lsp = { version = "0.6", path = "../helix-lsp" } helix-lsp = { version = "0.6", path = "../helix-lsp" }
helix-dap = { version = "0.6", path = "../helix-dap" } helix-dap = { version = "0.6", path = "../helix-dap", optional = true }
helix-loader = { version = "0.6", path = "../helix-loader" } helix-loader = { version = "0.6", path = "../helix-loader" }
anyhow = "1" anyhow = "1"

@ -247,7 +247,9 @@ impl Application {
} }
} }
Some(payload) = self.editor.debugger_events.next() => { Some(payload) = self.editor.debugger_events.next() => {
#[cfg(feature = "dap")]
let needs_render = self.editor.handle_debugger_message(payload).await; let needs_render = self.editor.handle_debugger_message(payload).await;
#[cfg(feature = "dap")]
if needs_render { if needs_render {
self.render(); self.render();
} }

@ -1,7 +1,9 @@
#[cfg(feature = "dap")]
pub(crate) mod dap; pub(crate) mod dap;
pub(crate) mod lsp; pub(crate) mod lsp;
pub(crate) mod typed; pub(crate) mod typed;
#[cfg(feature = "dap")]
pub use dap::*; pub use dap::*;
pub use lsp::*; pub use lsp::*;
pub use typed::*; pub use typed::*;
@ -139,8 +141,10 @@ pub enum MappableCommand {
} }
macro_rules! static_commands { macro_rules! static_commands {
( $($name:ident, $doc:literal,)* ) => { ( $($(#[cfg($attr:meta)])? $name:ident, $doc:literal,)* ) => {
$( $(
$(#[cfg($attr)])?
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
pub const $name: Self = Self::Static { pub const $name: Self = Self::Static {
name: stringify!($name), name: stringify!($name),
@ -150,7 +154,7 @@ macro_rules! static_commands {
)* )*
pub const STATIC_COMMAND_LIST: &'static [Self] = &[ pub const STATIC_COMMAND_LIST: &'static [Self] = &[
$( Self::$name, )* $( $(#[cfg($attr)])? Self::$name, )*
]; ];
} }
} }
@ -389,20 +393,35 @@ impl MappableCommand {
goto_prev_comment, "Goto previous comment", goto_prev_comment, "Goto previous comment",
goto_next_paragraph, "Goto next paragraph", goto_next_paragraph, "Goto next paragraph",
goto_prev_paragraph, "Goto previous paragraph", goto_prev_paragraph, "Goto previous paragraph",
#[cfg(feature = "dap")]
dap_launch, "Launch debug target", dap_launch, "Launch debug target",
#[cfg(feature = "dap")]
dap_toggle_breakpoint, "Toggle breakpoint", dap_toggle_breakpoint, "Toggle breakpoint",
#[cfg(feature = "dap")]
dap_continue, "Continue program execution", dap_continue, "Continue program execution",
#[cfg(feature = "dap")]
dap_pause, "Pause program execution", dap_pause, "Pause program execution",
#[cfg(feature = "dap")]
dap_step_in, "Step in", dap_step_in, "Step in",
#[cfg(feature = "dap")]
dap_step_out, "Step out", dap_step_out, "Step out",
#[cfg(feature = "dap")]
dap_next, "Step to next", dap_next, "Step to next",
#[cfg(feature = "dap")]
dap_variables, "List variables", dap_variables, "List variables",
#[cfg(feature = "dap")]
dap_terminate, "End debug session", dap_terminate, "End debug session",
#[cfg(feature = "dap")]
dap_edit_condition, "Edit condition of the breakpoint on the current line", dap_edit_condition, "Edit condition of the breakpoint on the current line",
#[cfg(feature = "dap")]
dap_edit_log, "Edit log message of the breakpoint on the current line", dap_edit_log, "Edit log message of the breakpoint on the current line",
#[cfg(feature = "dap")]
dap_switch_thread, "Switch current thread", dap_switch_thread, "Switch current thread",
#[cfg(feature = "dap")]
dap_switch_stack_frame, "Switch stack frame", dap_switch_stack_frame, "Switch stack frame",
#[cfg(feature = "dap")]
dap_enable_exceptions, "Enable exception breakpoints", dap_enable_exceptions, "Enable exception breakpoints",
#[cfg(feature = "dap")]
dap_disable_exceptions, "Disable exception breakpoints", dap_disable_exceptions, "Disable exception breakpoints",
shell_pipe, "Pipe selections through shell command", shell_pipe, "Pipe selections through shell command",
shell_pipe_to, "Pipe selections into shell command, ignoring command output", shell_pipe_to, "Pipe selections into shell command, ignoring command output",

@ -847,6 +847,7 @@ fn hsplit_new(
Ok(()) Ok(())
} }
#[cfg(feature = "dap")]
fn debug_eval( fn debug_eval(
cx: &mut compositor::Context, cx: &mut compositor::Context,
args: &[Cow<str>], args: &[Cow<str>],
@ -869,6 +870,7 @@ fn debug_eval(
Ok(()) Ok(())
} }
#[cfg(feature = "dap")]
fn debug_start( fn debug_start(
cx: &mut compositor::Context, cx: &mut compositor::Context,
args: &[Cow<str>], args: &[Cow<str>],
@ -882,6 +884,7 @@ fn debug_start(
dap_start_impl(cx, name.as_deref(), None, Some(args)) dap_start_impl(cx, name.as_deref(), None, Some(args))
} }
#[cfg(feature = "dap")]
fn debug_remote( fn debug_remote(
cx: &mut compositor::Context, cx: &mut compositor::Context,
args: &[Cow<str>], args: &[Cow<str>],
@ -1435,6 +1438,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: tree_sitter_scopes, fun: tree_sitter_scopes,
completer: None, completer: None,
}, },
#[cfg(feature = "dap")]
TypableCommand { TypableCommand {
name: "debug-start", name: "debug-start",
aliases: &["dbg"], aliases: &["dbg"],
@ -1442,6 +1446,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: debug_start, fun: debug_start,
completer: None, completer: None,
}, },
#[cfg(feature = "dap")]
TypableCommand { TypableCommand {
name: "debug-remote", name: "debug-remote",
aliases: &["dbg-tcp"], aliases: &["dbg-tcp"],
@ -1449,6 +1454,7 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: debug_remote, fun: debug_remote,
completer: None, completer: None,
}, },
#[cfg(feature = "dap")]
TypableCommand { TypableCommand {
name: "debug-eval", name: "debug-eval",
aliases: &[], aliases: &[],

@ -5,7 +5,7 @@ use super::{Keymap, Mode};
use helix_core::hashmap; use helix_core::hashmap;
pub fn default() -> HashMap<Mode, Keymap> { pub fn default() -> HashMap<Mode, Keymap> {
let normal = keymap!({ "Normal mode" let mut normal = keymap!({ "Normal mode"
"h" | "left" => move_char_left, "h" | "left" => move_char_left,
"j" | "down" => move_line_down, "j" | "down" => move_line_down,
"k" | "up" => move_line_up, "k" | "up" => move_line_up,
@ -202,26 +202,6 @@ pub fn default() -> HashMap<Mode, Keymap> {
"S" => workspace_symbol_picker, "S" => workspace_symbol_picker,
"a" => code_action, "a" => code_action,
"'" => last_picker, "'" => last_picker,
"d" => { "Debug (experimental)" sticky=true
"l" => dap_launch,
"b" => dap_toggle_breakpoint,
"c" => dap_continue,
"h" => dap_pause,
"i" => dap_step_in,
"o" => dap_step_out,
"n" => dap_next,
"v" => dap_variables,
"t" => dap_terminate,
"C-c" => dap_edit_condition,
"C-l" => dap_edit_log,
"s" => { "Switch"
"t" => dap_switch_thread,
"f" => dap_switch_stack_frame,
// sl, sb
},
"e" => dap_enable_exceptions,
"E" => dap_disable_exceptions,
},
"w" => { "Window" "w" => { "Window"
"C-w" | "w" => rotate_view, "C-w" | "w" => rotate_view,
"C-s" | "s" => hsplit, "C-s" | "s" => hsplit,
@ -285,6 +265,34 @@ pub fn default() -> HashMap<Mode, Keymap> {
"C-a" => increment, "C-a" => increment,
"C-x" => decrement, "C-x" => decrement,
}); });
// DAP
#[cfg(feature = "dap")]
normal.merge_nodes(keymap!({ "Normal mode"
"space" => { "Space"
"d" => { "Debug (experimental)" sticky=true
"l" => dap_launch,
"b" => dap_toggle_breakpoint,
"c" => dap_continue,
"h" => dap_pause,
"i" => dap_step_in,
"o" => dap_step_out,
"n" => dap_next,
"v" => dap_variables,
"t" => dap_terminate,
"C-c" => dap_edit_condition,
"C-l" => dap_edit_log,
"s" => { "Switch"
"t" => dap_switch_thread,
"f" => dap_switch_stack_frame,
// sl, sb
},
"e" => dap_enable_exceptions,
"E" => dap_disable_exceptions,
},
},
}));
let mut select = normal.clone(); let mut select = normal.clone();
select.merge_nodes(keymap!({ "Select mode" select.merge_nodes(keymap!({ "Select mode"
"h" | "left" => extend_char_left, "h" | "left" => extend_char_left,

@ -80,6 +80,7 @@ impl EditorView {
let theme = &editor.theme; let theme = &editor.theme;
// DAP: Highlight current stack frame position // DAP: Highlight current stack frame position
#[cfg(feature = "dap")]
let stack_frame = editor.debugger.as_ref().and_then(|debugger| { let stack_frame = editor.debugger.as_ref().and_then(|debugger| {
if let (Some(frame), Some(thread_id)) = (debugger.active_frame, debugger.thread_id) { if let (Some(frame), Some(thread_id)) = (debugger.active_frame, debugger.thread_id) {
debugger debugger
@ -90,6 +91,7 @@ impl EditorView {
None None
} }
}); });
#[cfg(feature = "dap")]
if let Some(frame) = stack_frame { if let Some(frame) = stack_frame {
if doc.path().is_some() if doc.path().is_some()
&& frame && frame
@ -957,6 +959,7 @@ impl EditorView {
) -> EventResult { ) -> EventResult {
let config = cxt.editor.config(); let config = cxt.editor.config();
match event { match event {
#[cfg(feature = "dap")]
MouseEvent { MouseEvent {
kind: MouseEventKind::Down(MouseButton::Left), kind: MouseEventKind::Down(MouseButton::Left),
row, row,
@ -1084,6 +1087,7 @@ impl EditorView {
EventResult::Consumed(None) EventResult::Consumed(None)
} }
#[cfg(feature = "dap")]
MouseEvent { MouseEvent {
kind: MouseEventKind::Up(MouseButton::Right), kind: MouseEventKind::Up(MouseButton::Right),
row, row,

@ -10,7 +10,8 @@ repository = "https://github.com/helix-editor/helix"
homepage = "https://helix-editor.com" homepage = "https://helix-editor.com"
[features] [features]
default = [] # default = ["dap"]
dap = ["helix-dap", "tokio-stream"]
term = ["crossterm"] term = ["crossterm"]
[dependencies] [dependencies]
@ -18,7 +19,9 @@ bitflags = "1.3"
anyhow = "1" anyhow = "1"
helix-core = { version = "0.6", path = "../helix-core" } helix-core = { version = "0.6", path = "../helix-core" }
helix-lsp = { version = "0.6", path = "../helix-lsp" } helix-lsp = { version = "0.6", path = "../helix-lsp" }
helix-dap = { version = "0.6", path = "../helix-dap" } helix-dap = { version = "0.6", path = "../helix-dap", optional = true }
tokio-stream = { version = "0.1", optional = true }
crossterm = { version = "0.23", optional = true } crossterm = { version = "0.23", optional = true }
# Conversion traits # Conversion traits
@ -28,7 +31,6 @@ url = "2"
arc-swap = { version = "1.5.0" } arc-swap = { version = "1.5.0" }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] } tokio = { version = "1", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot"] }
tokio-stream = "0.1"
futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false } futures-util = { version = "0.3", features = ["std", "async-await"], default-features = false }
slotmap = "1" slotmap = "1"

@ -10,8 +10,6 @@ use crate::{
}; };
use futures_util::future; use futures_util::future;
use futures_util::stream::select_all::SelectAll;
use tokio_stream::wrappers::UnboundedReceiverStream;
use std::{ use std::{
borrow::Cow, borrow::Cow,
@ -38,6 +36,13 @@ use helix_core::{
Change, Change,
}; };
use helix_core::{Position, Selection}; use helix_core::{Position, Selection};
#[cfg(feature = "dap")]
use futures_util::stream::select_all::SelectAll;
#[cfg(feature = "dap")]
use tokio_stream::wrappers::UnboundedReceiverStream;
#[cfg(feature = "dap")]
use helix_dap as dap; use helix_dap as dap;
use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer}; use serde::{ser::SerializeMap, Deserialize, Deserializer, Serialize, Serializer};
@ -433,8 +438,12 @@ pub struct Editor {
pub theme: Theme, pub theme: Theme,
pub language_servers: helix_lsp::Registry, pub language_servers: helix_lsp::Registry,
#[cfg(feature = "dap")]
pub debugger: Option<dap::Client>, pub debugger: Option<dap::Client>,
#[cfg(feature = "dap")]
pub debugger_events: SelectAll<UnboundedReceiverStream<dap::Payload>>, pub debugger_events: SelectAll<UnboundedReceiverStream<dap::Payload>>,
#[cfg(not(feature = "dap"))]
pub debugger_events: futures_util::stream::Empty<()>,
pub breakpoints: HashMap<PathBuf, Vec<Breakpoint>>, pub breakpoints: HashMap<PathBuf, Vec<Breakpoint>>,
pub clipboard_provider: Box<dyn ClipboardProvider>, pub clipboard_provider: Box<dyn ClipboardProvider>,
@ -502,8 +511,12 @@ impl Editor {
macro_recording: None, macro_recording: None,
theme: theme_loader.default(), theme: theme_loader.default(),
language_servers, language_servers,
#[cfg(feature = "dap")]
debugger: None, debugger: None,
#[cfg(feature = "dap")]
debugger_events: SelectAll::new(), debugger_events: SelectAll::new(),
#[cfg(not(feature = "dap"))]
debugger_events: futures_util::stream::empty(),
breakpoints: HashMap::new(), breakpoints: HashMap::new(),
syn_loader, syn_loader,
theme_loader, theme_loader,

@ -7,6 +7,7 @@ pub mod editor;
pub mod graphics; pub mod graphics;
pub mod gutter; pub mod gutter;
pub mod handlers { pub mod handlers {
#[cfg(feature = "dap")]
pub mod dap; pub mod dap;
pub mod lsp; pub mod lsp;
} }

Loading…
Cancel
Save