-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
790fdcf
commit b102a40
Showing
13 changed files
with
85 additions
and
39 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../LICENSE-GPL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)?), | ||
)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters