debugger_settings.rs

 1use dap_types::SteppingGranularity;
 2use gpui::{App, Global};
 3use schemars::JsonSchema;
 4use serde::{Deserialize, Serialize};
 5use settings::{Settings, SettingsSources};
 6
 7#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
 8#[serde(rename_all = "snake_case")]
 9pub enum DebugPanelDockPosition {
10    Left,
11    Bottom,
12    Right,
13}
14
15#[derive(Serialize, Deserialize, JsonSchema, Clone, Copy)]
16#[serde(default)]
17pub struct DebuggerSettings {
18    /// Determines the stepping granularity.
19    ///
20    /// Default: line
21    pub stepping_granularity: SteppingGranularity,
22    /// Whether the breakpoints should be reused across Zed sessions.
23    ///
24    /// Default: true
25    pub save_breakpoints: bool,
26    /// Whether to show the debug button in the status bar.
27    ///
28    /// Default: true
29    pub button: bool,
30    /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
31    ///
32    /// Default: 2000ms
33    pub timeout: u64,
34    /// Whether to log messages between active debug adapters and Zed
35    ///
36    /// Default: true
37    pub log_dap_communications: bool,
38    /// Whether to format dap messages in when adding them to debug adapter logger
39    ///
40    /// Default: true
41    pub format_dap_log_messages: bool,
42    /// The dock position of the debug panel
43    ///
44    /// Default: Bottom
45    pub dock: DebugPanelDockPosition,
46}
47
48impl Default for DebuggerSettings {
49    fn default() -> Self {
50        Self {
51            button: true,
52            save_breakpoints: true,
53            stepping_granularity: SteppingGranularity::Line,
54            timeout: 2000,
55            log_dap_communications: true,
56            format_dap_log_messages: true,
57            dock: DebugPanelDockPosition::Bottom,
58        }
59    }
60}
61
62impl Settings for DebuggerSettings {
63    const KEY: Option<&'static str> = Some("debugger");
64
65    type FileContent = Self;
66
67    fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> anyhow::Result<Self> {
68        sources.json_merge()
69    }
70
71    fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
72}
73
74impl Global for DebuggerSettings {}