This PR adds support for context servers provided by extensions.
To provide a context server from an extension, you need to list the
context servers in your `extension.toml`:
```toml
[context_servers.my-context-server]
```
And then implement the `context_server_command` method to return the
command that will be used to start the context server:
```rs
use zed_extension_api::{self as zed, Command, ContextServerId, Result};
struct ExampleContextServerExtension;
impl zed::Extension for ExampleContextServerExtension {
fn new() -> Self {
ExampleContextServerExtension
}
fn context_server_command(&mut self, _context_server_id: &ContextServerId) -> Result<Command> {
Ok(Command {
command: "node".to_string(),
args: vec!["/path/to/example-context-server/index.js".to_string()],
env: Vec::new(),
})
}
}
zed::register_extension!(ExampleContextServerExtension);
```
Release Notes:
- N/A
28 lines
747 B
Rust
28 lines
747 B
Rust
pub mod client;
|
|
pub mod manager;
|
|
pub mod protocol;
|
|
mod registry;
|
|
pub mod types;
|
|
|
|
use command_palette_hooks::CommandPaletteFilter;
|
|
use gpui::{actions, AppContext};
|
|
use settings::Settings;
|
|
|
|
pub use crate::manager::ContextServer;
|
|
use crate::manager::ContextServerSettings;
|
|
pub use crate::registry::ContextServerFactoryRegistry;
|
|
|
|
actions!(context_servers, [Restart]);
|
|
|
|
/// The namespace for the context servers actions.
|
|
pub const CONTEXT_SERVERS_NAMESPACE: &'static str = "context_servers";
|
|
|
|
pub fn init(cx: &mut AppContext) {
|
|
ContextServerSettings::register(cx);
|
|
ContextServerFactoryRegistry::default_global(cx);
|
|
|
|
CommandPaletteFilter::update_global(cx, |filter, _cx| {
|
|
filter.hide_namespace(CONTEXT_SERVERS_NAMESPACE);
|
|
});
|
|
}
|