Improve keymap json schema (#23044)
Also: * Adds `impl_internal_actions!` for deriving the `Action` trait without registering. * Removes some deserializers that immediately fail in favor of `#[serde(skip)]` on fields where they were used. This also omits them from the schema. Release Notes: - Keymap settings file now has more JSON schema information to inform `json-language-server` completions and info, particularly for actions that take input.
This commit is contained in:
parent
4c50201036
commit
6aba3950d2
37 changed files with 506 additions and 283 deletions
|
@ -25,6 +25,7 @@ use itertools::Itertools;
|
|||
use language::DiagnosticSeverity;
|
||||
use parking_lot::Mutex;
|
||||
use project::{Project, ProjectEntryId, ProjectPath, WorktreeId};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::{
|
||||
|
@ -71,7 +72,7 @@ impl DraggedSelection {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Copy, Deserialize, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Debug, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum SaveIntent {
|
||||
/// write all files (even if unchanged)
|
||||
|
@ -92,16 +93,16 @@ pub enum SaveIntent {
|
|||
Skip,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq, Debug)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
pub struct ActivateItem(pub usize);
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseActiveItem {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseInactiveItems {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
|
@ -109,7 +110,7 @@ pub struct CloseInactiveItems {
|
|||
pub close_pinned: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseAllItems {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
|
@ -117,34 +118,35 @@ pub struct CloseAllItems {
|
|||
pub close_pinned: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseCleanItems {
|
||||
#[serde(default)]
|
||||
pub close_pinned: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseItemsToTheRight {
|
||||
#[serde(default)]
|
||||
pub close_pinned: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseItemsToTheLeft {
|
||||
#[serde(default)]
|
||||
pub close_pinned: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RevealInProjectPanel {
|
||||
#[serde(skip)]
|
||||
pub entry_id: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Clone, Deserialize)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema, Default)]
|
||||
pub struct DeploySearch {
|
||||
#[serde(default)]
|
||||
pub replace_enabled: bool,
|
||||
|
|
|
@ -13,6 +13,7 @@ use gpui::{
|
|||
};
|
||||
use parking_lot::Mutex;
|
||||
use project::Project;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
|
@ -717,7 +718,7 @@ impl PaneAxis {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, JsonSchema)]
|
||||
pub enum SplitDirection {
|
||||
Up,
|
||||
Down,
|
||||
|
@ -800,7 +801,7 @@ impl SplitDirection {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, JsonSchema, PartialEq)]
|
||||
pub enum ResizeIntent {
|
||||
Lengthen,
|
||||
Shorten,
|
||||
|
|
|
@ -61,10 +61,9 @@ use persistence::{
|
|||
SerializedWindowBounds, DB,
|
||||
};
|
||||
use postage::stream::Stream;
|
||||
use project::{
|
||||
DirectoryLister, Project, ProjectEntryId, ProjectPath, ResolvedPath, Worktree, WorktreeId,
|
||||
};
|
||||
use project::{DirectoryLister, Project, ProjectEntryId, ProjectPath, ResolvedPath, Worktree};
|
||||
use remote::{ssh_session::ConnectionIdentifier, SshClientDelegate, SshConnectionOptions};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use session::AppSession;
|
||||
use settings::Settings;
|
||||
|
@ -119,9 +118,6 @@ static ZED_WINDOW_POSITION: LazyLock<Option<Point<Pixels>>> = LazyLock::new(|| {
|
|||
.and_then(parse_pixel_position_env_var)
|
||||
});
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
pub struct RemoveWorktreeFromProject(pub WorktreeId);
|
||||
|
||||
actions!(assistant, [ShowConfiguration]);
|
||||
|
||||
actions!(
|
||||
|
@ -165,64 +161,64 @@ pub struct OpenPaths {
|
|||
pub paths: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct ActivatePane(pub usize);
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct ActivatePaneInDirection(pub SplitDirection);
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct SwapPaneInDirection(pub SplitDirection);
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct MoveItemToPane {
|
||||
pub destination: usize,
|
||||
#[serde(default = "default_true")]
|
||||
pub focus: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct MoveItemToPaneInDirection {
|
||||
pub direction: SplitDirection,
|
||||
#[serde(default = "default_true")]
|
||||
pub focus: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SaveAll {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Save {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseAllItemsAndPanes {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)]
|
||||
#[derive(Clone, PartialEq, Debug, Deserialize, Default, JsonSchema)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct CloseInactiveTabsAndPanes {
|
||||
pub save_intent: Option<SaveIntent>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct SendKeystrokes(pub String);
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq, Default)]
|
||||
#[derive(Clone, Deserialize, PartialEq, Default, JsonSchema)]
|
||||
pub struct Reload {
|
||||
pub binary_path: Option<PathBuf>,
|
||||
}
|
||||
|
||||
action_as!(project_symbols, ToggleProjectSymbols as Toggle);
|
||||
|
||||
#[derive(Default, PartialEq, Eq, Clone, serde::Deserialize)]
|
||||
#[derive(Default, PartialEq, Eq, Clone, Deserialize, JsonSchema)]
|
||||
pub struct ToggleFileFinder {
|
||||
#[serde(default)]
|
||||
pub separate_history: bool,
|
||||
|
@ -299,7 +295,7 @@ impl PartialEq for Toast {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Deserialize, PartialEq)]
|
||||
#[derive(Debug, Default, Clone, Deserialize, PartialEq, JsonSchema)]
|
||||
pub struct OpenTerminal {
|
||||
pub working_directory: PathBuf,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue