pub trait Extension: Send + Sync {
Show 19 methods
// Required method
fn new() -> Self
where Self: Sized;
// Provided methods
fn language_server_command(
&mut self,
_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Command> { ... }
fn language_server_initialization_options(
&mut self,
_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>> { ... }
fn language_server_workspace_configuration(
&mut self,
_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>> { ... }
fn language_server_additional_initialization_options(
&mut self,
_language_server_id: &LanguageServerId,
_target_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>> { ... }
fn language_server_additional_workspace_configuration(
&mut self,
_language_server_id: &LanguageServerId,
_target_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>> { ... }
fn label_for_completion(
&self,
_language_server_id: &LanguageServerId,
_completion: Completion,
) -> Option<CodeLabel> { ... }
fn label_for_symbol(
&self,
_language_server_id: &LanguageServerId,
_symbol: Symbol,
) -> Option<CodeLabel> { ... }
fn complete_slash_command_argument(
&self,
_command: SlashCommand,
_args: Vec<String>,
) -> Result<Vec<SlashCommandArgumentCompletion>, String> { ... }
fn run_slash_command(
&self,
_command: SlashCommand,
_args: Vec<String>,
_worktree: Option<&Worktree>,
) -> Result<SlashCommandOutput, String> { ... }
fn context_server_command(
&mut self,
_context_server_id: &ContextServerId,
_project: &Project,
) -> Result<Command> { ... }
fn context_server_configuration(
&mut self,
_context_server_id: &ContextServerId,
_project: &Project,
) -> Result<Option<ContextServerConfiguration>> { ... }
fn suggest_docs_packages(
&self,
_provider: String,
) -> Result<Vec<String>, String> { ... }
fn index_docs(
&self,
_provider: String,
_package: String,
_database: &KeyValueStore,
) -> Result<(), String> { ... }
fn get_dap_binary(
&mut self,
_adapter_name: String,
_config: DebugTaskDefinition,
_user_provided_debug_adapter_path: Option<String>,
_worktree: &Worktree,
) -> Result<DebugAdapterBinary, String> { ... }
fn dap_request_kind(
&mut self,
_adapter_name: String,
_config: Value,
) -> Result<StartDebuggingRequestArgumentsRequest, String> { ... }
fn dap_config_to_scenario(
&mut self,
_config: DebugConfig,
) -> Result<DebugScenario, String> { ... }
fn dap_locator_create_scenario(
&mut self,
_locator_name: String,
_build_task: TaskTemplate,
_resolved_label: String,
_debug_adapter_name: String,
) -> Option<DebugScenario> { ... }
fn run_dap_locator(
&mut self,
_locator_name: String,
_build_task: TaskTemplate,
) -> Result<DebugRequest, String> { ... }
}Expand description
A Zed extension.
Required Methods§
Provided Methods§
Sourcefn language_server_command(
&mut self,
_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Command>
fn language_server_command( &mut self, _language_server_id: &LanguageServerId, _worktree: &Worktree, ) -> Result<Command>
Returns the command used to start the language server for the specified language.
Sourcefn language_server_initialization_options(
&mut self,
_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>>
fn language_server_initialization_options( &mut self, _language_server_id: &LanguageServerId, _worktree: &Worktree, ) -> Result<Option<Value>>
Returns the initialization options to pass to the specified language server.
Sourcefn language_server_workspace_configuration(
&mut self,
_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>>
fn language_server_workspace_configuration( &mut self, _language_server_id: &LanguageServerId, _worktree: &Worktree, ) -> Result<Option<Value>>
Returns the workspace configuration options to pass to the language server.
Sourcefn language_server_additional_initialization_options(
&mut self,
_language_server_id: &LanguageServerId,
_target_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>>
fn language_server_additional_initialization_options( &mut self, _language_server_id: &LanguageServerId, _target_language_server_id: &LanguageServerId, _worktree: &Worktree, ) -> Result<Option<Value>>
Returns the initialization options to pass to the other language server.
Sourcefn language_server_additional_workspace_configuration(
&mut self,
_language_server_id: &LanguageServerId,
_target_language_server_id: &LanguageServerId,
_worktree: &Worktree,
) -> Result<Option<Value>>
fn language_server_additional_workspace_configuration( &mut self, _language_server_id: &LanguageServerId, _target_language_server_id: &LanguageServerId, _worktree: &Worktree, ) -> Result<Option<Value>>
Returns the workspace configuration options to pass to the other language server.
Sourcefn label_for_completion(
&self,
_language_server_id: &LanguageServerId,
_completion: Completion,
) -> Option<CodeLabel>
fn label_for_completion( &self, _language_server_id: &LanguageServerId, _completion: Completion, ) -> Option<CodeLabel>
Returns the label for the given completion.
Sourcefn label_for_symbol(
&self,
_language_server_id: &LanguageServerId,
_symbol: Symbol,
) -> Option<CodeLabel>
fn label_for_symbol( &self, _language_server_id: &LanguageServerId, _symbol: Symbol, ) -> Option<CodeLabel>
Returns the label for the given symbol.
Sourcefn complete_slash_command_argument(
&self,
_command: SlashCommand,
_args: Vec<String>,
) -> Result<Vec<SlashCommandArgumentCompletion>, String>
fn complete_slash_command_argument( &self, _command: SlashCommand, _args: Vec<String>, ) -> Result<Vec<SlashCommandArgumentCompletion>, String>
Returns the completions that should be shown when completing the provided slash command with the given query.
Sourcefn run_slash_command(
&self,
_command: SlashCommand,
_args: Vec<String>,
_worktree: Option<&Worktree>,
) -> Result<SlashCommandOutput, String>
fn run_slash_command( &self, _command: SlashCommand, _args: Vec<String>, _worktree: Option<&Worktree>, ) -> Result<SlashCommandOutput, String>
Returns the output from running the provided slash command.
Sourcefn context_server_command(
&mut self,
_context_server_id: &ContextServerId,
_project: &Project,
) -> Result<Command>
fn context_server_command( &mut self, _context_server_id: &ContextServerId, _project: &Project, ) -> Result<Command>
Returns the command used to start a context server.
Sourcefn context_server_configuration(
&mut self,
_context_server_id: &ContextServerId,
_project: &Project,
) -> Result<Option<ContextServerConfiguration>>
fn context_server_configuration( &mut self, _context_server_id: &ContextServerId, _project: &Project, ) -> Result<Option<ContextServerConfiguration>>
Returns the configuration options for the specified context server.
Sourcefn suggest_docs_packages(
&self,
_provider: String,
) -> Result<Vec<String>, String>
fn suggest_docs_packages( &self, _provider: String, ) -> Result<Vec<String>, String>
Returns a list of package names as suggestions to be included in the
search results of the /docs slash command.
This can be used to provide completions for known packages (e.g., from the local project or a registry) before a package has been indexed.
Sourcefn index_docs(
&self,
_provider: String,
_package: String,
_database: &KeyValueStore,
) -> Result<(), String>
fn index_docs( &self, _provider: String, _package: String, _database: &KeyValueStore, ) -> Result<(), String>
Indexes the docs for the specified package.
Sourcefn get_dap_binary(
&mut self,
_adapter_name: String,
_config: DebugTaskDefinition,
_user_provided_debug_adapter_path: Option<String>,
_worktree: &Worktree,
) -> Result<DebugAdapterBinary, String>
fn get_dap_binary( &mut self, _adapter_name: String, _config: DebugTaskDefinition, _user_provided_debug_adapter_path: Option<String>, _worktree: &Worktree, ) -> Result<DebugAdapterBinary, String>
Returns the debug adapter binary for the specified adapter name and configuration.
Sourcefn dap_request_kind(
&mut self,
_adapter_name: String,
_config: Value,
) -> Result<StartDebuggingRequestArgumentsRequest, String>
fn dap_request_kind( &mut self, _adapter_name: String, _config: Value, ) -> Result<StartDebuggingRequestArgumentsRequest, String>
Determines whether the specified adapter configuration should launch a new debuggee process or attach to an existing one. This function should not perform any further validation (outside of determining the kind of a request). This function should return an error when the kind cannot be determined (rather than fall back to a known default).
Sourcefn dap_config_to_scenario(
&mut self,
_config: DebugConfig,
) -> Result<DebugScenario, String>
fn dap_config_to_scenario( &mut self, _config: DebugConfig, ) -> Result<DebugScenario, String>
Converts a high-level definition of a debug scenario (originating in a new session UI) to a “low-level” configuration suitable for a particular adapter.
In layman’s terms: given a program, list of arguments, current working directory and environment variables, create a configuration that can be used to start a debug session.
Sourcefn dap_locator_create_scenario(
&mut self,
_locator_name: String,
_build_task: TaskTemplate,
_resolved_label: String,
_debug_adapter_name: String,
) -> Option<DebugScenario>
fn dap_locator_create_scenario( &mut self, _locator_name: String, _build_task: TaskTemplate, _resolved_label: String, _debug_adapter_name: String, ) -> Option<DebugScenario>
Locators are entities that convert a Zed task into a debug scenario.
They can be provided even by extensions that don’t provide a debug adapter.
For all tasks applicable to a given buffer, Zed will query all locators to find one that can turn the task into a debug scenario.
A converted debug scenario can include a build task (it shouldn’t contain any configuration in such case); a build task result will later
be resolved with Extension::run_dap_locator.
To work through a real-world example, take a cargo run task and a hypothetical cargo locator:
- We may need to modify the task; in this case, it is problematic that
cargo runspawns a binary. We should turncargo runinto a debug scenario withcargo buildtask. This is the decision we make atdap_locator_create_scenarioscope. - Then, after the build task finishes, we will run
run_dap_locatorof the locator that produced the build task to find the program to be debugged. This function should give us a debugger-agnostic configuration for launching a debug target (that we end up resolving withExtension::dap_config_to_scenario). It’s almost as if the user found the artifact path by themselves.
Note that you’re not obliged to use build tasks with locators. Specifically, it is sufficient to provide a debug configuration directly in the return value of
dap_locator_create_scenario if you’re able to do that. Make sure to not fill out build field in that case, as that will prevent Zed from running second phase of resolution in such case.
This might be of particular relevance to interpreted languages.
Sourcefn run_dap_locator(
&mut self,
_locator_name: String,
_build_task: TaskTemplate,
) -> Result<DebugRequest, String>
fn run_dap_locator( &mut self, _locator_name: String, _build_task: TaskTemplate, ) -> Result<DebugRequest, String>
Runs the second phase of locator resolution.
See Extension::dap_locator_create_scenario for a hefty comment on locators.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".