context_servers: Make settings field show up in settings completions (#20905)
This PR fixes an issue where the `settings` field for a context server would not show up in the completions when editing the Zed settings. It seems that `schemars` doesn't like the `serde_json::Value` as a setting type when generating the JSON Schema. To address this, we are using a custom schema of an empty object (as we don't yet have any other information as to the structure of a given context server's settings). Release Notes: - context_servers: Fixed `settings` field not being suggested in completions when editing `settings.json`.
This commit is contained in:
@@ -24,6 +24,8 @@ use gpui::{AsyncAppContext, EventEmitter, Model, ModelContext, Subscription, Tas
|
|||||||
use log;
|
use log;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
|
use schemars::gen::SchemaGenerator;
|
||||||
|
use schemars::schema::{InstanceType, Schema, SchemaObject};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::{Settings, SettingsSources, SettingsStore};
|
use settings::{Settings, SettingsSources, SettingsStore};
|
||||||
@@ -43,9 +45,17 @@ pub struct ContextServerSettings {
|
|||||||
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)]
|
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)]
|
||||||
pub struct ServerConfig {
|
pub struct ServerConfig {
|
||||||
pub command: Option<ServerCommand>,
|
pub command: Option<ServerCommand>,
|
||||||
|
#[schemars(schema_with = "server_config_settings_json_schema")]
|
||||||
pub settings: Option<serde_json::Value>,
|
pub settings: Option<serde_json::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn server_config_settings_json_schema(_generator: &mut SchemaGenerator) -> Schema {
|
||||||
|
Schema::Object(SchemaObject {
|
||||||
|
instance_type: Some(InstanceType::Object.into()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
#[derive(Deserialize, Serialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
||||||
pub struct ServerCommand {
|
pub struct ServerCommand {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user