Define language settings in the language crate
This commit is contained in:
parent
9ae10a5dd9
commit
39618ae32d
54 changed files with 1348 additions and 1161 deletions
|
@ -12,6 +12,7 @@ doctest = false
|
|||
neovim = ["nvim-rs", "async-compat", "async-trait", "tokio"]
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
serde.workspace = true
|
||||
serde_derive.workspace = true
|
||||
itertools = "0.10"
|
||||
|
|
|
@ -17,14 +17,16 @@ pub struct VimTestContext<'a> {
|
|||
impl<'a> VimTestContext<'a> {
|
||||
pub async fn new(cx: &'a mut gpui::TestAppContext, enabled: bool) -> VimTestContext<'a> {
|
||||
let mut cx = EditorLspTestContext::new_rust(Default::default(), cx).await;
|
||||
|
||||
cx.update(|cx| {
|
||||
search::init(cx);
|
||||
crate::init(cx);
|
||||
});
|
||||
|
||||
cx.update(|cx| {
|
||||
cx.update_global(|store: &mut SettingsStore, cx| {
|
||||
store.update_user_settings::<VimModeSetting>(cx, |s| *s = Some(enabled));
|
||||
});
|
||||
|
||||
settings::KeymapFileContent::load("keymaps/vim.json", cx).unwrap();
|
||||
});
|
||||
|
||||
|
|
|
@ -10,8 +10,7 @@ mod state;
|
|||
mod utils;
|
||||
mod visual;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use collections::CommandPaletteFilter;
|
||||
use editor::{Bias, Cancel, Editor, EditorMode, Event};
|
||||
use gpui::{
|
||||
|
@ -24,6 +23,7 @@ use normal::normal_replace;
|
|||
use serde::Deserialize;
|
||||
use settings::{Setting, SettingsStore};
|
||||
use state::{Mode, Operator, VimState};
|
||||
use std::sync::Arc;
|
||||
use visual::visual_replace;
|
||||
use workspace::{self, Workspace};
|
||||
|
||||
|
@ -343,14 +343,10 @@ impl Setting for VimModeSetting {
|
|||
default_value: &Self::FileContent,
|
||||
user_values: &[&Self::FileContent],
|
||||
_: &AppContext,
|
||||
) -> Self {
|
||||
Self(
|
||||
user_values
|
||||
.first()
|
||||
.map(|e| **e)
|
||||
.flatten()
|
||||
.unwrap_or(default_value.unwrap()),
|
||||
)
|
||||
) -> Result<Self> {
|
||||
Ok(Self(user_values.iter().rev().find_map(|v| **v).unwrap_or(
|
||||
default_value.ok_or_else(Self::missing_default)?,
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue