1use dap_types::SteppingGranularity;
2use gpui::{App, Global};
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5use settings::{Settings, SettingsKey, 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, SettingsUi, SettingsKey)]
16#[serde(default)]
17// todo(settings_ui) @ben: I'm pretty sure not having the fields be optional here is a bug,
18// it means the defaults will override previously set values if a single key is missing
19#[settings_ui(group = "Debugger")]
20#[settings_key(key = "debugger")]
21pub struct DebuggerSettings {
22 /// Determines the stepping granularity.
23 ///
24 /// Default: line
25 #[settings_ui(skip)]
26 pub stepping_granularity: SteppingGranularity,
27 /// Whether the breakpoints should be reused across Zed sessions.
28 ///
29 /// Default: true
30 pub save_breakpoints: bool,
31 /// Whether to show the debug button in the status bar.
32 ///
33 /// Default: true
34 pub button: bool,
35 /// Time in milliseconds until timeout error when connecting to a TCP debug adapter
36 ///
37 /// Default: 2000ms
38 pub timeout: u64,
39 /// Whether to log messages between active debug adapters and Zed
40 ///
41 /// Default: true
42 pub log_dap_communications: bool,
43 /// Whether to format dap messages in when adding them to debug adapter logger
44 ///
45 /// Default: true
46 pub format_dap_log_messages: bool,
47 /// The dock position of the debug panel
48 ///
49 /// Default: Bottom
50 pub dock: DebugPanelDockPosition,
51}
52
53impl Default for DebuggerSettings {
54 fn default() -> Self {
55 Self {
56 button: true,
57 save_breakpoints: true,
58 stepping_granularity: SteppingGranularity::Line,
59 timeout: 2000,
60 log_dap_communications: true,
61 format_dap_log_messages: true,
62 dock: DebugPanelDockPosition::Bottom,
63 }
64 }
65}
66
67impl Settings for DebuggerSettings {
68 type FileContent = Self;
69
70 fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> anyhow::Result<Self> {
71 sources.json_merge()
72 }
73
74 fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {}
75}
76
77impl Global for DebuggerSettings {}