Skip to content
Merged
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
79 changes: 79 additions & 0 deletions debug_adapter_schemas/ElixirLS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "ElixirLS Debug Adapter Configuration",
"type": "object",
"properties": {
"request": {
"type": "string",
"enum": ["launch", "attach"],
Comment thread
andersfischernielsen marked this conversation as resolved.
"default": "launch",
"description": "Whether to launch a new process or attach to an existing one"
},
"task": {
"type": "string",
"examples": ["run", "test", "phx.server"],
"description": "Mix task to invoke (e.g. `run`, `test`, `phx.server`)"
},
"taskArgs": {
"type": "array",
"items": { "type": "string" },
Comment thread
andersfischernielsen marked this conversation as resolved.
"default": [],
"description": "Arguments passed to the Mix task"
},
"projectDir": {
"type": "string",
Comment thread
andersfischernielsen marked this conversation as resolved.
"default": "$ZED_WORKTREE_ROOT",
"description": "Absolute path to the directory containing `mix.exs`"
},
"startApps": {
"type": "boolean",
"description": "Run `mix app.start` before the debugger (default: false)"
},
"requireFiles": {
"type": "array",
"items": { "type": "string" },
"default": ["test/**/test_helper.exs", "test/**/*_test.exs"],
"description": "Extra `.exs` files to require and interpret before debugging"
},
"excludeModules": {
"type": "array",
"items": { "type": "string" },
Comment thread
andersfischernielsen marked this conversation as resolved.
"default": [],
"description": "Modules that should NOT be interpreted (e.g. NIFs)"
},
"debugAutoInterpretAllModules": {
"type": "boolean",
"description": "Automatically interpret all loaded modules (default: true)"
},
"debugInterpretModulesPatterns": {
"type": "array",
"items": { "type": "string" },
Comment thread
andersfischernielsen marked this conversation as resolved.
"default": [],
"description": "Glob patterns for modules to interpret"
},
"exitAfterTaskReturns": {
"type": "boolean",
"description": "End the debug session when the task returns (default: true)"
},
"env": {
"type": "object",
"additionalProperties": { "type": "string" },
Comment thread
andersfischernielsen marked this conversation as resolved.
"default": {},
"description": "Environment variables to set for the debugged process"
},
"stackTraceMode": {
"type": "string",
"enum": ["all", "no_tail", "false"],
"description": "Argument passed to `:int.stack_trace/1` (default: no_tail)"
},
"noDebug": {
"type": "boolean",
"description": "Run the Mix task without debugging (default: false)"
},
"breakOnDbg": {
"type": "boolean",
"description": "Automatically break on `Kernel.dbg/2` calls (default: true)"
}
},
"required": ["request", "task", "projectDir"]
}
2 changes: 2 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ languages = [
"EEx" = "eex"
"HEEx" = "heex"

[debug_adapters.ElixirLS]

[grammars.elixir]
repository = "https://github.com/elixir-lang/tree-sitter-elixir"
commit = "450a8194f5a66561135962cfc8d7545a27b61c4c"
Expand Down
43 changes: 42 additions & 1 deletion src/elixir.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mod language_servers;

Comment thread
andersfischernielsen marked this conversation as resolved.
use zed_extension_api::{
self as zed, CodeLabel, LanguageServerId, Result, Worktree,
self as zed, CodeLabel, DebugAdapterBinary, DebugConfig, DebugScenario, DebugTaskDefinition,
LanguageServerId, Result, StartDebuggingRequestArgumentsRequest, Worktree,
lsp::{Completion, Symbol},
serde_json::Value,
};
Expand Down Expand Up @@ -148,6 +149,46 @@ impl zed::Extension for ElixirExtension {
_ => None,
}
}

fn get_dap_binary(
&mut self,
adapter_name: String,
config: DebugTaskDefinition,
user_provided_debug_adapter_path: Option<String>,
worktree: &Worktree,
) -> Result<DebugAdapterBinary> {
match adapter_name.as_str() {
ElixirLs::DEBUG_ADAPTER_NAME => self
.elixir_ls
.get_or_insert_with(ElixirLs::new)
.get_dap_binary(config, user_provided_debug_adapter_path, worktree),
adapter_name => Err(format!("unknown debug adapter: {adapter_name}")),
}
}

fn dap_request_kind(
&mut self,
adapter_name: String,
config: Value,
) -> Result<StartDebuggingRequestArgumentsRequest> {
match adapter_name.as_str() {
ElixirLs::DEBUG_ADAPTER_NAME => self
.elixir_ls
.get_or_insert_with(ElixirLs::new)
.dap_request_kind(config),
adapter_name => Err(format!("unknown debug adapter: {adapter_name}")),
}
}

fn dap_config_to_scenario(&mut self, config: DebugConfig) -> Result<DebugScenario> {
match config.adapter.as_str() {
ElixirLs::DEBUG_ADAPTER_NAME => self
.elixir_ls
.get_or_insert_with(ElixirLs::new)
.dap_config_to_scenario(config),
adapter_name => Err(format!("unknown debug adapter: {adapter_name}")),
}
}
}

zed::register_extension!(ElixirExtension);
Loading
Loading