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:
parent
790fdcf737
commit
b102a40e04
13 changed files with 85 additions and 39 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -4236,7 +4236,7 @@ dependencies = [
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
"ui",
|
"ui",
|
||||||
"util",
|
"util",
|
||||||
"vim",
|
"vim_mode_setting",
|
||||||
"wasmtime-wasi",
|
"wasmtime-wasi",
|
||||||
"workspace",
|
"workspace",
|
||||||
"zed_actions",
|
"zed_actions",
|
||||||
|
@ -13697,10 +13697,20 @@ dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"ui",
|
"ui",
|
||||||
"util",
|
"util",
|
||||||
|
"vim_mode_setting",
|
||||||
"workspace",
|
"workspace",
|
||||||
"zed_actions",
|
"zed_actions",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vim_mode_setting"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"gpui",
|
||||||
|
"settings",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vscode_theme"
|
name = "vscode_theme"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
|
@ -14415,7 +14425,7 @@ dependencies = [
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
"ui",
|
"ui",
|
||||||
"util",
|
"util",
|
||||||
"vim",
|
"vim_mode_setting",
|
||||||
"workspace",
|
"workspace",
|
||||||
"zed_actions",
|
"zed_actions",
|
||||||
]
|
]
|
||||||
|
@ -15575,6 +15585,7 @@ dependencies = [
|
||||||
"uuid",
|
"uuid",
|
||||||
"vcs_menu",
|
"vcs_menu",
|
||||||
"vim",
|
"vim",
|
||||||
|
"vim_mode_setting",
|
||||||
"welcome",
|
"welcome",
|
||||||
"windows 0.58.0",
|
"windows 0.58.0",
|
||||||
"winresource",
|
"winresource",
|
||||||
|
|
|
@ -129,6 +129,7 @@ members = [
|
||||||
"crates/util",
|
"crates/util",
|
||||||
"crates/vcs_menu",
|
"crates/vcs_menu",
|
||||||
"crates/vim",
|
"crates/vim",
|
||||||
|
"crates/vim_mode_setting",
|
||||||
"crates/welcome",
|
"crates/welcome",
|
||||||
"crates/workspace",
|
"crates/workspace",
|
||||||
"crates/worktree",
|
"crates/worktree",
|
||||||
|
@ -304,6 +305,7 @@ ui_macros = { path = "crates/ui_macros" }
|
||||||
util = { path = "crates/util" }
|
util = { path = "crates/util" }
|
||||||
vcs_menu = { path = "crates/vcs_menu" }
|
vcs_menu = { path = "crates/vcs_menu" }
|
||||||
vim = { path = "crates/vim" }
|
vim = { path = "crates/vim" }
|
||||||
|
vim_mode_setting = { path = "crates/vim_mode_setting" }
|
||||||
welcome = { path = "crates/welcome" }
|
welcome = { path = "crates/welcome" }
|
||||||
workspace = { path = "crates/workspace" }
|
workspace = { path = "crates/workspace" }
|
||||||
worktree = { path = "crates/worktree" }
|
worktree = { path = "crates/worktree" }
|
||||||
|
|
|
@ -41,7 +41,7 @@ theme.workspace = true
|
||||||
theme_selector.workspace = true
|
theme_selector.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
vim.workspace = true
|
vim_mode_setting.workspace = true
|
||||||
wasmtime-wasi.workspace = true
|
wasmtime-wasi.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
|
|
|
@ -27,7 +27,7 @@ use release_channel::ReleaseChannel;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use theme::ThemeSettings;
|
use theme::ThemeSettings;
|
||||||
use ui::{prelude::*, CheckboxWithLabel, ContextMenu, PopoverMenu, ToggleButton, Tooltip};
|
use ui::{prelude::*, CheckboxWithLabel, ContextMenu, PopoverMenu, ToggleButton, Tooltip};
|
||||||
use vim::VimModeSetting;
|
use vim_mode_setting::VimModeSetting;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
item::{Item, ItemEvent},
|
item::{Item, ItemEvent},
|
||||||
Workspace, WorkspaceId,
|
Workspace, WorkspaceId,
|
||||||
|
|
|
@ -39,6 +39,7 @@ settings.workspace = true
|
||||||
tokio = { version = "1.15", features = ["full"], optional = true }
|
tokio = { version = "1.15", features = ["full"], optional = true }
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
|
vim_mode_setting.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,11 @@ use state::{Mode, Operator, RecordedSelection, SearchState, VimGlobals};
|
||||||
use std::{mem, ops::Range, sync::Arc};
|
use std::{mem, ops::Range, sync::Arc};
|
||||||
use surrounds::SurroundsType;
|
use surrounds::SurroundsType;
|
||||||
use ui::{IntoElement, VisualContext};
|
use ui::{IntoElement, VisualContext};
|
||||||
|
use vim_mode_setting::VimModeSetting;
|
||||||
use workspace::{self, Pane, Workspace};
|
use workspace::{self, Pane, Workspace};
|
||||||
|
|
||||||
use crate::state::ReplayableAction;
|
use crate::state::ReplayableAction;
|
||||||
|
|
||||||
/// Whether or not to enable Vim mode.
|
|
||||||
///
|
|
||||||
/// Default: false
|
|
||||||
pub struct VimModeSetting(pub bool);
|
|
||||||
|
|
||||||
/// An Action to Switch between modes
|
/// An Action to Switch between modes
|
||||||
#[derive(Clone, Deserialize, PartialEq)]
|
#[derive(Clone, Deserialize, PartialEq)]
|
||||||
pub struct SwitchMode(pub Mode);
|
pub struct SwitchMode(pub Mode);
|
||||||
|
@ -89,7 +85,7 @@ impl_actions!(vim, [SwitchMode, PushOperator, Number, SelectRegister]);
|
||||||
|
|
||||||
/// Initializes the `vim` crate.
|
/// Initializes the `vim` crate.
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
VimModeSetting::register(cx);
|
vim_mode_setting::init(cx);
|
||||||
VimSettings::register(cx);
|
VimSettings::register(cx);
|
||||||
VimGlobals::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.
|
/// Controls when to use system clipboard.
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
|
|
17
crates/vim_mode_setting/Cargo.toml
Normal file
17
crates/vim_mode_setting/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "vim_mode_setting"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/vim_mode_setting.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow.workspace = true
|
||||||
|
gpui.workspace = true
|
||||||
|
settings.workspace = true
|
1
crates/vim_mode_setting/LICENSE-GPL
Symbolic link
1
crates/vim_mode_setting/LICENSE-GPL
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../../LICENSE-GPL
|
36
crates/vim_mode_setting/src/vim_mode_setting.rs
Normal file
36
crates/vim_mode_setting/src/vim_mode_setting.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
//! Contains the [`VimModeSetting`] used to enable/disable Vim mode.
|
||||||
|
//!
|
||||||
|
//! This is in its own crate as we want other crates to be able to enable or
|
||||||
|
//! disable Vim mode without having to depend on the `vim` crate in its
|
||||||
|
//! entirety.
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use gpui::AppContext;
|
||||||
|
use settings::{Settings, SettingsSources};
|
||||||
|
|
||||||
|
/// Initializes the `vim_mode_setting` crate.
|
||||||
|
pub fn init(cx: &mut AppContext) {
|
||||||
|
VimModeSetting::register(cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Whether or not to enable Vim mode.
|
||||||
|
///
|
||||||
|
/// Default: false
|
||||||
|
pub struct VimModeSetting(pub bool);
|
||||||
|
|
||||||
|
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)?),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,7 +30,7 @@ settings.workspace = true
|
||||||
theme_selector.workspace = true
|
theme_selector.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
util.workspace = true
|
util.workspace = true
|
||||||
vim.workspace = true
|
vim_mode_setting.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use gpui::{
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use ui::{prelude::*, CheckboxWithLabel};
|
use ui::{prelude::*, CheckboxWithLabel};
|
||||||
use vim::VimModeSetting;
|
use vim_mode_setting::VimModeSetting;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
dock::DockPosition,
|
dock::DockPosition,
|
||||||
item::{Item, ItemEvent},
|
item::{Item, ItemEvent},
|
||||||
|
|
|
@ -119,6 +119,7 @@ util.workspace = true
|
||||||
uuid.workspace = true
|
uuid.workspace = true
|
||||||
vcs_menu.workspace = true
|
vcs_menu.workspace = true
|
||||||
vim.workspace = true
|
vim.workspace = true
|
||||||
|
vim_mode_setting.workspace = true
|
||||||
welcome.workspace = true
|
welcome.workspace = true
|
||||||
workspace.workspace = true
|
workspace.workspace = true
|
||||||
zed_actions.workspace = true
|
zed_actions.workspace = true
|
||||||
|
|
|
@ -9,7 +9,9 @@ mod open_listener;
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub(crate) mod windows_only_instance;
|
pub(crate) mod windows_only_instance;
|
||||||
|
|
||||||
|
use anyhow::Context as _;
|
||||||
pub use app_menus::*;
|
pub use app_menus::*;
|
||||||
|
use assets::Assets;
|
||||||
use assistant::PromptBuilder;
|
use assistant::PromptBuilder;
|
||||||
use breadcrumbs::Breadcrumbs;
|
use breadcrumbs::Breadcrumbs;
|
||||||
use client::{zed_urls, ZED_URL_SCHEME};
|
use client::{zed_urls, ZED_URL_SCHEME};
|
||||||
|
@ -18,17 +20,15 @@ use command_palette_hooks::CommandPaletteFilter;
|
||||||
use editor::ProposedChangesEditorToolbar;
|
use editor::ProposedChangesEditorToolbar;
|
||||||
use editor::{scroll::Autoscroll, Editor, MultiBuffer};
|
use editor::{scroll::Autoscroll, Editor, MultiBuffer};
|
||||||
use feature_flags::FeatureFlagAppExt;
|
use feature_flags::FeatureFlagAppExt;
|
||||||
|
use futures::{channel::mpsc, select_biased, StreamExt};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, point, px, AppContext, AsyncAppContext, Context, FocusableView, MenuItem,
|
actions, point, px, AppContext, AsyncAppContext, Context, FocusableView, MenuItem,
|
||||||
PathPromptOptions, PromptLevel, ReadGlobal, Task, TitlebarOptions, View, ViewContext,
|
PathPromptOptions, PromptLevel, ReadGlobal, Task, TitlebarOptions, View, ViewContext,
|
||||||
VisualContext, WindowKind, WindowOptions,
|
VisualContext, WindowKind, WindowOptions,
|
||||||
};
|
};
|
||||||
pub use open_listener::*;
|
pub use open_listener::*;
|
||||||
|
|
||||||
use anyhow::Context as _;
|
|
||||||
use assets::Assets;
|
|
||||||
use futures::{channel::mpsc, select_biased, StreamExt};
|
|
||||||
use outline_panel::OutlinePanel;
|
use outline_panel::OutlinePanel;
|
||||||
|
use paths::{local_settings_file_relative_path, local_tasks_file_relative_path};
|
||||||
use project::{DirectoryLister, Item};
|
use project::{DirectoryLister, Item};
|
||||||
use project_panel::ProjectPanel;
|
use project_panel::ProjectPanel;
|
||||||
use quick_action_bar::QuickActionBar;
|
use quick_action_bar::QuickActionBar;
|
||||||
|
@ -43,16 +43,14 @@ use settings::{
|
||||||
use std::any::TypeId;
|
use std::any::TypeId;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{borrow::Cow, ops::Deref, path::Path, sync::Arc};
|
use std::{borrow::Cow, ops::Deref, path::Path, sync::Arc};
|
||||||
use theme::ActiveTheme;
|
|
||||||
use workspace::notifications::NotificationId;
|
|
||||||
use workspace::CloseIntent;
|
|
||||||
|
|
||||||
use paths::{local_settings_file_relative_path, local_tasks_file_relative_path};
|
|
||||||
use terminal_view::terminal_panel::{self, TerminalPanel};
|
use terminal_view::terminal_panel::{self, TerminalPanel};
|
||||||
|
use theme::ActiveTheme;
|
||||||
use util::{asset_str, ResultExt};
|
use util::{asset_str, ResultExt};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use vim::VimModeSetting;
|
use vim_mode_setting::VimModeSetting;
|
||||||
use welcome::{BaseKeymap, MultibufferHint};
|
use welcome::{BaseKeymap, MultibufferHint};
|
||||||
|
use workspace::notifications::NotificationId;
|
||||||
|
use workspace::CloseIntent;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
create_and_open_local_file, notifications::simple_message_notification::MessageNotification,
|
create_and_open_local_file, notifications::simple_message_notification::MessageNotification,
|
||||||
open_new, AppState, NewFile, NewWindow, OpenLog, Toast, Workspace, WorkspaceSettings,
|
open_new, AppState, NewFile, NewWindow, OpenLog, Toast, Workspace, WorkspaceSettings,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue