Extract VimModeSetting to its own crate (#21019)

This PR extracts the `VimModeSetting` out of the `vim` crate and into
its own `vim_mode_setting` crate.

A number of crates were depending on the entirety of the `vim` crate
just to reference `VimModeSetting`, which was not ideal.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-11-21 16:24:38 -05:00 committed by GitHub
parent 790fdcf737
commit b102a40e04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 85 additions and 39 deletions

View file

@ -39,6 +39,7 @@ settings.workspace = true
tokio = { version = "1.15", features = ["full"], optional = true }
ui.workspace = true
util.workspace = true
vim_mode_setting.workspace = true
workspace.workspace = true
zed_actions.workspace = true

View file

@ -41,15 +41,11 @@ use state::{Mode, Operator, RecordedSelection, SearchState, VimGlobals};
use std::{mem, ops::Range, sync::Arc};
use surrounds::SurroundsType;
use ui::{IntoElement, VisualContext};
use vim_mode_setting::VimModeSetting;
use workspace::{self, Pane, Workspace};
use crate::state::ReplayableAction;
/// Whether or not to enable Vim mode.
///
/// Default: false
pub struct VimModeSetting(pub bool);
/// An Action to Switch between modes
#[derive(Clone, Deserialize, PartialEq)]
pub struct SwitchMode(pub Mode);
@ -89,7 +85,7 @@ impl_actions!(vim, [SwitchMode, PushOperator, Number, SelectRegister]);
/// Initializes the `vim` crate.
pub fn init(cx: &mut AppContext) {
VimModeSetting::register(cx);
vim_mode_setting::init(cx);
VimSettings::register(cx);
VimGlobals::register(cx);
@ -1122,23 +1118,6 @@ impl Vim {
}
}
impl Settings for VimModeSetting {
const KEY: Option<&'static str> = Some("vim_mode");
type FileContent = Option<bool>;
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
Ok(Self(
sources
.user
.or(sources.server)
.copied()
.flatten()
.unwrap_or(sources.default.ok_or_else(Self::missing_default)?),
))
}
}
/// Controls when to use system clipboard.
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]