debugger_settings.rs

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