Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ path = "src/dart.rs"
crate-type = ["cdylib"]

[dependencies]
zed_extension_api = "0.7.0"
zed_extension_api = "0.8.0"
33 changes: 32 additions & 1 deletion src/dart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use zed::settings::LspSettings;
use zed::{CodeLabel, CodeLabelSpan};
use zed_extension_api::serde_json::json;
use zed_extension_api::{
self as zed, current_platform, serde_json, DebugAdapterBinary, DebugTaskDefinition, Os, Result,
self as zed, current_platform, serde_json, DapCustomAction, DapCustomActionIcon,
DapCustomActionTrigger, DebugAdapterBinary, DebugTaskDefinition, Os, Result,
StartDebuggingRequestArguments, StartDebuggingRequestArgumentsRequest, Worktree,
};

Expand Down Expand Up @@ -138,13 +139,20 @@ impl zed::Extension for DartExtension {

let vm_service_uri = user_config.get("vmServiceUri").and_then(|v| v.as_str());

let tool_args = if debug_mode == "flutter" {
vec!["-d".to_string(), device_id.to_string()]
} else {
vec![]
};

let config_json = json!({
"type": tool,
"request": request,
"vmServiceUri": vm_service_uri,
"program": program,
"cwd": cwd.clone().unwrap_or_default(),
"args": args,
"toolArgs": tool_args,
"flutterMode": "debug",
"deviceId": device_id,
"platform": platform,
Expand Down Expand Up @@ -217,6 +225,29 @@ impl zed::Extension for DartExtension {
})))
}

fn get_dap_custom_actions(&self, adapter_name: String) -> Vec<DapCustomAction> {
if adapter_name != "Flutter" && adapter_name != "Dart" {
return Vec::new();
}

vec![
DapCustomAction {
label: "Hot Reload".to_string(),
command: "hotReload".to_string(),
arguments: "{}".to_string(),
trigger: DapCustomActionTrigger::Both,
icon: DapCustomActionIcon::Flame,
},
DapCustomAction {
label: "Hot Restart".to_string(),
command: "hotRestart".to_string(),
arguments: "{}".to_string(),
trigger: DapCustomActionTrigger::Toolbar,
icon: DapCustomActionIcon::RotateCw,
},
]
}

fn label_for_completion(
&self,
_language_server_id: &zed::LanguageServerId,
Expand Down