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
|
@ -1,20 +1,20 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use editor::{scroll::Autoscroll, Editor, MultiBufferSnapshot, ToOffset, ToPoint};
|
||||
use gpui::{impl_actions, ViewContext};
|
||||
use language::{Bias, Point};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use std::ops::Range;
|
||||
|
||||
use crate::{state::Mode, Vim};
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Increment {
|
||||
#[serde(default)]
|
||||
step: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Decrement {
|
||||
#[serde(default)]
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
use std::cmp;
|
||||
|
||||
use editor::{display_map::ToDisplayPoint, movement, scroll::Autoscroll, DisplayPoint, RowExt};
|
||||
use gpui::{impl_actions, ViewContext};
|
||||
use language::{Bias, SelectionGoal};
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use std::cmp;
|
||||
|
||||
use crate::{
|
||||
state::{Mode, Register},
|
||||
Vim,
|
||||
};
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Deserialize, JsonSchema, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Paste {
|
||||
#[serde(default)]
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::{iter::Peekable, str::Chars, time::Duration};
|
||||
|
||||
use editor::Editor;
|
||||
use gpui::{actions, impl_actions, ViewContext};
|
||||
use gpui::{actions, impl_actions, impl_internal_actions, ViewContext};
|
||||
use language::Point;
|
||||
use schemars::JsonSchema;
|
||||
use search::{buffer_search, BufferSearchBar, SearchOptions};
|
||||
use serde_derive::Deserialize;
|
||||
use std::{iter::Peekable, str::Chars, time::Duration};
|
||||
use util::serde::default_true;
|
||||
use workspace::{notifications::NotifyResultExt, searchable::Direction};
|
||||
|
||||
|
@ -15,7 +15,7 @@ use crate::{
|
|||
Vim,
|
||||
};
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct MoveToNext {
|
||||
#[serde(default = "default_true")]
|
||||
|
@ -26,7 +26,7 @@ pub(crate) struct MoveToNext {
|
|||
regex: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub(crate) struct MoveToPrev {
|
||||
#[serde(default = "default_true")]
|
||||
|
@ -37,7 +37,7 @@ pub(crate) struct MoveToPrev {
|
|||
regex: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, PartialEq)]
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq)]
|
||||
pub(crate) struct Search {
|
||||
#[serde(default)]
|
||||
backwards: bool,
|
||||
|
@ -45,19 +45,19 @@ pub(crate) struct Search {
|
|||
regex: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq)]
|
||||
pub struct FindCommand {
|
||||
pub query: String,
|
||||
pub backwards: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ReplaceCommand {
|
||||
pub(crate) range: CommandRange,
|
||||
pub(crate) replacement: Replacement,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Deserialize, Clone)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct Replacement {
|
||||
search: String,
|
||||
replacement: String,
|
||||
|
@ -66,10 +66,8 @@ pub(crate) struct Replacement {
|
|||
}
|
||||
|
||||
actions!(vim, [SearchSubmit, MoveToNextMatch, MoveToPrevMatch]);
|
||||
impl_actions!(
|
||||
vim,
|
||||
[FindCommand, ReplaceCommand, Search, MoveToPrev, MoveToNext]
|
||||
);
|
||||
impl_actions!(vim, [FindCommand, Search, MoveToPrev, MoveToNext]);
|
||||
impl_internal_actions!(vim, [ReplaceCommand]);
|
||||
|
||||
pub(crate) fn register(editor: &mut Editor, cx: &mut ViewContext<Vim>) {
|
||||
Vim::action(editor, cx, Vim::move_to_next);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue