mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 02:17:35 +03:00
Replace lazy_static
with std::sync::LazyLock
(#16066)
Closes #15860 Since rust std now supports LazyLock replacing lazy_static with it reduce the external dependency. Release Notes: - N/A --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
85731dfe8e
commit
ff7017c308
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -2329,7 +2329,6 @@ dependencies = [
|
|||||||
"futures 0.3.30",
|
"futures 0.3.30",
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
@ -2531,7 +2530,6 @@ dependencies = [
|
|||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"language",
|
"language",
|
||||||
"lazy_static",
|
|
||||||
"menu",
|
"menu",
|
||||||
"notifications",
|
"notifications",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
@ -3263,7 +3261,6 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"gpui",
|
"gpui",
|
||||||
"indoc",
|
"indoc",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"paths",
|
"paths",
|
||||||
"release_channel",
|
"release_channel",
|
||||||
@ -3543,7 +3540,6 @@ dependencies = [
|
|||||||
"indoc",
|
"indoc",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
"language",
|
"language",
|
||||||
"lazy_static",
|
|
||||||
"linkify",
|
"linkify",
|
||||||
"log",
|
"log",
|
||||||
"lsp",
|
"lsp",
|
||||||
@ -4306,7 +4302,6 @@ dependencies = [
|
|||||||
"git",
|
"git",
|
||||||
"git2",
|
"git2",
|
||||||
"gpui",
|
"gpui",
|
||||||
"lazy_static",
|
|
||||||
"libc",
|
"libc",
|
||||||
"notify",
|
"notify",
|
||||||
"objc",
|
"objc",
|
||||||
@ -4632,7 +4627,6 @@ dependencies = [
|
|||||||
"git2",
|
"git2",
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
@ -4831,7 +4825,6 @@ dependencies = [
|
|||||||
"http_client",
|
"http_client",
|
||||||
"image",
|
"image",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
"lazy_static",
|
|
||||||
"linkme",
|
"linkme",
|
||||||
"log",
|
"log",
|
||||||
"media",
|
"media",
|
||||||
@ -5947,7 +5940,6 @@ dependencies = [
|
|||||||
"http_client",
|
"http_client",
|
||||||
"indoc",
|
"indoc",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"lsp",
|
"lsp",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
@ -6081,7 +6073,6 @@ dependencies = [
|
|||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"language",
|
"language",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"lsp",
|
"lsp",
|
||||||
"node_runtime",
|
"node_runtime",
|
||||||
@ -9741,7 +9732,6 @@ dependencies = [
|
|||||||
"futures 0.3.30",
|
"futures 0.3.30",
|
||||||
"gpui",
|
"gpui",
|
||||||
"indoc",
|
"indoc",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"paths",
|
"paths",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
@ -10153,7 +10143,6 @@ dependencies = [
|
|||||||
"collections",
|
"collections",
|
||||||
"futures 0.3.30",
|
"futures 0.3.30",
|
||||||
"indoc",
|
"indoc",
|
||||||
"lazy_static",
|
|
||||||
"libsqlite3-sys",
|
"libsqlite3-sys",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"smol",
|
"smol",
|
||||||
@ -10166,7 +10155,6 @@ dependencies = [
|
|||||||
name = "sqlez_macros"
|
name = "sqlez_macros"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
|
||||||
"sqlez",
|
"sqlez",
|
||||||
"sqlformat",
|
"sqlformat",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
@ -11014,7 +11002,6 @@ dependencies = [
|
|||||||
"env_logger",
|
"env_logger",
|
||||||
"gpui",
|
"gpui",
|
||||||
"http_client",
|
"http_client",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"postage",
|
"postage",
|
||||||
@ -12212,7 +12199,6 @@ dependencies = [
|
|||||||
"indoc",
|
"indoc",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
"language",
|
"language",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"lsp",
|
"lsp",
|
||||||
"multi_buffer",
|
"multi_buffer",
|
||||||
@ -13555,7 +13541,6 @@ dependencies = [
|
|||||||
"http_client",
|
"http_client",
|
||||||
"itertools 0.11.0",
|
"itertools 0.11.0",
|
||||||
"language",
|
"language",
|
||||||
"lazy_static",
|
|
||||||
"log",
|
"log",
|
||||||
"node_runtime",
|
"node_runtime",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
@ -359,7 +359,6 @@ isahc = { version = "1.7.2", default-features = false, features = [
|
|||||||
] }
|
] }
|
||||||
itertools = "0.11.0"
|
itertools = "0.11.0"
|
||||||
jsonwebtoken = "9.3"
|
jsonwebtoken = "9.3"
|
||||||
lazy_static = "1.4.0"
|
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
linkify = "0.10.0"
|
linkify = "0.10.0"
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde", "serde"] }
|
||||||
|
@ -27,7 +27,6 @@ fs.workspace = true
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
|
@ -22,7 +22,6 @@ use gpui::{
|
|||||||
actions, AnyModel, AnyWeakModel, AppContext, AsyncAppContext, Global, Model, Task, WeakModel,
|
actions, AnyModel, AnyWeakModel, AppContext, AsyncAppContext, Global, Model, Task, WeakModel,
|
||||||
};
|
};
|
||||||
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
|
use http_client::{AsyncBody, HttpClient, HttpClientWithUrl};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use proto::ProtoClient;
|
use proto::ProtoClient;
|
||||||
@ -43,7 +42,7 @@ use std::{
|
|||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicU64, Ordering},
|
atomic::{AtomicU64, Ordering},
|
||||||
Arc, Weak,
|
Arc, LazyLock, Weak,
|
||||||
},
|
},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
@ -65,27 +64,35 @@ impl fmt::Display for DevServerToken {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static ZED_SERVER_URL: LazyLock<Option<String>> =
|
||||||
static ref ZED_SERVER_URL: Option<String> = std::env::var("ZED_SERVER_URL").ok();
|
LazyLock::new(|| std::env::var("ZED_SERVER_URL").ok());
|
||||||
static ref ZED_RPC_URL: Option<String> = std::env::var("ZED_RPC_URL").ok();
|
static ZED_RPC_URL: LazyLock<Option<String>> = LazyLock::new(|| std::env::var("ZED_RPC_URL").ok());
|
||||||
/// An environment variable whose presence indicates that the development auth
|
|
||||||
/// provider should be used.
|
/// An environment variable whose presence indicates that the development auth
|
||||||
///
|
/// provider should be used.
|
||||||
/// Only works in development. Setting this environment variable in other release
|
///
|
||||||
/// channels is a no-op.
|
/// Only works in development. Setting this environment variable in other release
|
||||||
pub static ref ZED_DEVELOPMENT_AUTH: bool =
|
/// channels is a no-op.
|
||||||
std::env::var("ZED_DEVELOPMENT_AUTH").map_or(false, |value| !value.is_empty());
|
pub static ZED_DEVELOPMENT_AUTH: LazyLock<bool> = LazyLock::new(|| {
|
||||||
pub static ref IMPERSONATE_LOGIN: Option<String> = std::env::var("ZED_IMPERSONATE")
|
std::env::var("ZED_DEVELOPMENT_AUTH").map_or(false, |value| !value.is_empty())
|
||||||
|
});
|
||||||
|
pub static IMPERSONATE_LOGIN: LazyLock<Option<String>> = LazyLock::new(|| {
|
||||||
|
std::env::var("ZED_IMPERSONATE")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| if s.is_empty() { None } else { Some(s) });
|
.and_then(|s| if s.is_empty() { None } else { Some(s) })
|
||||||
pub static ref ADMIN_API_TOKEN: Option<String> = std::env::var("ZED_ADMIN_API_TOKEN")
|
});
|
||||||
|
|
||||||
|
pub static ADMIN_API_TOKEN: LazyLock<Option<String>> = LazyLock::new(|| {
|
||||||
|
std::env::var("ZED_ADMIN_API_TOKEN")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| if s.is_empty() { None } else { Some(s) });
|
.and_then(|s| if s.is_empty() { None } else { Some(s) })
|
||||||
pub static ref ZED_APP_PATH: Option<PathBuf> =
|
});
|
||||||
std::env::var("ZED_APP_PATH").ok().map(PathBuf::from);
|
|
||||||
pub static ref ZED_ALWAYS_ACTIVE: bool =
|
pub static ZED_APP_PATH: LazyLock<Option<PathBuf>> =
|
||||||
std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| !e.is_empty());
|
LazyLock::new(|| std::env::var("ZED_APP_PATH").ok().map(PathBuf::from));
|
||||||
}
|
|
||||||
|
pub static ZED_ALWAYS_ACTIVE: LazyLock<bool> =
|
||||||
|
LazyLock::new(|| std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| !e.is_empty()));
|
||||||
|
|
||||||
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(500);
|
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(500);
|
||||||
pub const MAX_RECONNECTION_DELAY: Duration = Duration::from_secs(10);
|
pub const MAX_RECONNECTION_DELAY: Duration = Duration::from_secs(10);
|
||||||
|
@ -42,7 +42,6 @@ futures.workspace = true
|
|||||||
fuzzy.workspace = true
|
fuzzy.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
menu.workspace = true
|
menu.workspace = true
|
||||||
notifications.workspace = true
|
notifications.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
|
@ -12,11 +12,10 @@ use language::{
|
|||||||
language_settings::SoftWrap, Anchor, Buffer, BufferSnapshot, CodeLabel, LanguageRegistry,
|
language_settings::SoftWrap, Anchor, Buffer, BufferSnapshot, CodeLabel, LanguageRegistry,
|
||||||
LanguageServerId, ToOffset,
|
LanguageServerId, ToOffset,
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use project::{search::SearchQuery, Completion};
|
use project::{search::SearchQuery, Completion};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{ops::Range, sync::Arc, time::Duration};
|
use std::{ops::Range, sync::Arc, sync::LazyLock, time::Duration};
|
||||||
use theme::ThemeSettings;
|
use theme::ThemeSettings;
|
||||||
use ui::{prelude::*, TextSize};
|
use ui::{prelude::*, TextSize};
|
||||||
|
|
||||||
@ -24,17 +23,17 @@ use crate::panel_settings::MessageEditorSettings;
|
|||||||
|
|
||||||
const MENTIONS_DEBOUNCE_INTERVAL: Duration = Duration::from_millis(50);
|
const MENTIONS_DEBOUNCE_INTERVAL: Duration = Duration::from_millis(50);
|
||||||
|
|
||||||
lazy_static! {
|
static MENTIONS_SEARCH: LazyLock<SearchQuery> = LazyLock::new(|| {
|
||||||
static ref MENTIONS_SEARCH: SearchQuery = SearchQuery::regex(
|
SearchQuery::regex(
|
||||||
"@[-_\\w]+",
|
"@[-_\\w]+",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
Default::default()
|
Default::default(),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap()
|
||||||
}
|
});
|
||||||
|
|
||||||
pub struct MessageEditor {
|
pub struct MessageEditor {
|
||||||
pub editor: View<Editor>,
|
pub editor: View<Editor>,
|
||||||
@ -399,8 +398,8 @@ impl MessageEditor {
|
|||||||
end_anchor: Anchor,
|
end_anchor: Anchor,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Option<(Anchor, String, &'static [StringMatchCandidate])> {
|
) -> Option<(Anchor, String, &'static [StringMatchCandidate])> {
|
||||||
lazy_static! {
|
static EMOJI_FUZZY_MATCH_CANDIDATES: LazyLock<Vec<StringMatchCandidate>> =
|
||||||
static ref EMOJI_FUZZY_MATCH_CANDIDATES: Vec<StringMatchCandidate> = {
|
LazyLock::new(|| {
|
||||||
let emojis = emojis::iter()
|
let emojis = emojis::iter()
|
||||||
.flat_map(|s| s.shortcodes())
|
.flat_map(|s| s.shortcodes())
|
||||||
.map(|emoji| StringMatchCandidate {
|
.map(|emoji| StringMatchCandidate {
|
||||||
@ -410,8 +409,7 @@ impl MessageEditor {
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
emojis
|
emojis
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
let end_offset = end_anchor.to_offset(buffer.read(cx));
|
let end_offset = end_anchor.to_offset(buffer.read(cx));
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ test-support = []
|
|||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
release_channel.workspace = true
|
release_channel.workspace = true
|
||||||
|
@ -6,7 +6,6 @@ pub use anyhow;
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use gpui::AppContext;
|
use gpui::AppContext;
|
||||||
pub use indoc::indoc;
|
pub use indoc::indoc;
|
||||||
pub use lazy_static;
|
|
||||||
pub use paths::database_dir;
|
pub use paths::database_dir;
|
||||||
pub use smol;
|
pub use smol;
|
||||||
pub use sqlez;
|
pub use sqlez;
|
||||||
@ -17,9 +16,11 @@ pub use release_channel::RELEASE_CHANNEL;
|
|||||||
use sqlez::domain::Migrator;
|
use sqlez::domain::Migrator;
|
||||||
use sqlez::thread_safe_connection::ThreadSafeConnection;
|
use sqlez::thread_safe_connection::ThreadSafeConnection;
|
||||||
use sqlez_macros::sql;
|
use sqlez_macros::sql;
|
||||||
|
use std::env;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::LazyLock;
|
||||||
use util::{maybe, ResultExt};
|
use util::{maybe, ResultExt};
|
||||||
|
|
||||||
const CONNECTION_INITIALIZE_QUERY: &str = sql!(
|
const CONNECTION_INITIALIZE_QUERY: &str = sql!(
|
||||||
@ -37,10 +38,10 @@ const FALLBACK_DB_NAME: &str = "FALLBACK_MEMORY_DB";
|
|||||||
|
|
||||||
const DB_FILE_NAME: &str = "db.sqlite";
|
const DB_FILE_NAME: &str = "db.sqlite";
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
pub static ZED_STATELESS: LazyLock<bool> =
|
||||||
pub static ref ZED_STATELESS: bool = std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty());
|
LazyLock::new(|| env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty()));
|
||||||
pub static ref ALL_FILE_DB_FAILED: AtomicBool = AtomicBool::new(false);
|
|
||||||
}
|
pub static ALL_FILE_DB_FAILED: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
|
||||||
|
|
||||||
/// Open or create a database at the given directory path.
|
/// Open or create a database at the given directory path.
|
||||||
/// This will retry a couple times if there are failures. If opening fails once, the db directory
|
/// This will retry a couple times if there are failures. If opening fails once, the db directory
|
||||||
@ -138,15 +139,16 @@ macro_rules! define_connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use std::sync::LazyLock;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
$crate::lazy_static::lazy_static! {
|
pub static $id: LazyLock<$t> = LazyLock::new(|| {
|
||||||
pub static ref $id: $t = $t($crate::smol::block_on($crate::open_test_db(stringify!($id))));
|
$t($crate::smol::block_on($crate::open_test_db(stringify!($id))))
|
||||||
}
|
});
|
||||||
|
|
||||||
#[cfg(not(any(test, feature = "test-support")))]
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
$crate::lazy_static::lazy_static! {
|
pub static $id: LazyLock<$t> = LazyLock::new(|| {
|
||||||
pub static ref $id: $t = $t($crate::smol::block_on($crate::open_db($crate::database_dir(), &$crate::RELEASE_CHANNEL)));
|
$t($crate::smol::block_on($crate::open_db($crate::database_dir(), &$crate::RELEASE_CHANNEL)))
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
(pub static ref $id:ident: $t:ident<$($d:ty),+> = $migrations:expr;) => {
|
(pub static ref $id:ident: $t:ident<$($d:ty),+> = $migrations:expr;) => {
|
||||||
pub struct $t($crate::sqlez::thread_safe_connection::ThreadSafeConnection<( $($d),+, $t )>);
|
pub struct $t($crate::sqlez::thread_safe_connection::ThreadSafeConnection<( $($d),+, $t )>);
|
||||||
@ -170,14 +172,14 @@ macro_rules! define_connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
$crate::lazy_static::lazy_static! {
|
pub static $id: std::sync::LazyLock<$t> = std::sync::LazyLock::new(|| {
|
||||||
pub static ref $id: $t = $t($crate::smol::block_on($crate::open_test_db(stringify!($id))));
|
$t($crate::smol::block_on($crate::open_test_db(stringify!($id))))
|
||||||
}
|
});
|
||||||
|
|
||||||
#[cfg(not(any(test, feature = "test-support")))]
|
#[cfg(not(any(test, feature = "test-support")))]
|
||||||
$crate::lazy_static::lazy_static! {
|
pub static $id: std::sync::LazyLock<$t> = std::sync::LazyLock::new(|| {
|
||||||
pub static ref $id: $t = $t($crate::smol::block_on($crate::open_db($crate::database_dir(), &$crate::RELEASE_CHANNEL)));
|
$t($crate::smol::block_on($crate::open_db($crate::database_dir(), &$crate::RELEASE_CHANNEL)))
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,6 @@ http_client.workspace = true
|
|||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
linkify.workspace = true
|
linkify.workspace = true
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp.workspace = true
|
lsp.workspace = true
|
||||||
|
@ -5,9 +5,9 @@ use super::{
|
|||||||
};
|
};
|
||||||
use gpui::{AppContext, Context, Font, LineWrapper, Model, ModelContext, Pixels, Task};
|
use gpui::{AppContext, Context, Font, LineWrapper, Model, ModelContext, Pixels, Task};
|
||||||
use language::{Chunk, Point};
|
use language::{Chunk, Point};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use multi_buffer::MultiBufferSnapshot;
|
use multi_buffer::MultiBufferSnapshot;
|
||||||
use smol::future::yield_now;
|
use smol::future::yield_now;
|
||||||
|
use std::sync::LazyLock;
|
||||||
use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration};
|
use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration};
|
||||||
use sum_tree::{Bias, Cursor, SumTree};
|
use sum_tree::{Bias, Cursor, SumTree};
|
||||||
use text::Patch;
|
use text::Patch;
|
||||||
@ -887,14 +887,12 @@ impl Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn wrap(indent: u32) -> Self {
|
fn wrap(indent: u32) -> Self {
|
||||||
lazy_static! {
|
static WRAP_TEXT: LazyLock<String> = LazyLock::new(|| {
|
||||||
static ref WRAP_TEXT: String = {
|
let mut wrap_text = String::new();
|
||||||
let mut wrap_text = String::new();
|
wrap_text.push('\n');
|
||||||
wrap_text.push('\n');
|
wrap_text.extend((0..LineWrapper::MAX_INDENT as usize).map(|_| ' '));
|
||||||
wrap_text.extend((0..LineWrapper::MAX_INDENT as usize).map(|_| ' '));
|
wrap_text
|
||||||
wrap_text
|
});
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
summary: TransformSummary {
|
summary: TransformSummary {
|
||||||
|
@ -20,7 +20,6 @@ futures.workspace = true
|
|||||||
git.workspace = true
|
git.workspace = true
|
||||||
git2.workspace = true
|
git2.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
libc.workspace = true
|
libc.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
|
@ -794,9 +794,8 @@ impl FakeFsState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
lazy_static::lazy_static! {
|
pub static FS_DOT_GIT: std::sync::LazyLock<&'static OsStr> =
|
||||||
pub static ref FS_DOT_GIT: &'static OsStr = OsStr::new(".git");
|
std::sync::LazyLock::new(|| OsStr::new(".git"));
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl FakeFs {
|
impl FakeFs {
|
||||||
|
@ -20,7 +20,6 @@ derive_more.workspace = true
|
|||||||
git2.workspace = true
|
git2.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
rope.workspace = true
|
rope.workspace = true
|
||||||
|
@ -5,9 +5,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
pub use git2 as libgit;
|
pub use git2 as libgit;
|
||||||
pub use lazy_static::lazy_static;
|
|
||||||
|
|
||||||
pub use crate::hosting_provider::*;
|
pub use crate::hosting_provider::*;
|
||||||
|
|
||||||
@ -17,10 +17,8 @@ pub mod diff;
|
|||||||
pub mod repository;
|
pub mod repository;
|
||||||
pub mod status;
|
pub mod status;
|
||||||
|
|
||||||
lazy_static! {
|
pub static DOT_GIT: LazyLock<&'static OsStr> = LazyLock::new(|| OsStr::new(".git"));
|
||||||
pub static ref DOT_GIT: &'static OsStr = OsStr::new(".git");
|
pub static GITIGNORE: LazyLock<&'static OsStr> = LazyLock::new(|| OsStr::new(".gitignore"));
|
||||||
pub static ref GITIGNORE: &'static OsStr = OsStr::new(".gitignore");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
#[derive(Clone, Copy, Eq, Hash, PartialEq)]
|
||||||
pub struct Oid(libgit::Oid);
|
pub struct Oid(libgit::Oid);
|
||||||
|
@ -43,7 +43,6 @@ gpui_macros.workspace = true
|
|||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
image = "0.25.1"
|
image = "0.25.1"
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
linkme = "0.3"
|
linkme = "0.3"
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
num_cpus = "1.13"
|
num_cpus = "1.13"
|
||||||
|
@ -642,10 +642,8 @@ impl<T> PartialEq<Model<T>> for WeakModel<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
lazy_static::lazy_static! {
|
static LEAK_BACKTRACE: std::sync::LazyLock<bool> =
|
||||||
static ref LEAK_BACKTRACE: bool =
|
std::sync::LazyLock::new(|| std::env::var("LEAK_BACKTRACE").map_or(false, |b| !b.is_empty()));
|
||||||
std::env::var("LEAK_BACKTRACE").map_or(false, |b| !b.is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq)]
|
||||||
|
@ -37,7 +37,6 @@ globset.workspace = true
|
|||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp.workspace = true
|
lsp.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
|
@ -24,7 +24,6 @@ use gpui::{
|
|||||||
AnyElement, AppContext, EventEmitter, HighlightStyle, ModelContext, Task, TaskLabel,
|
AnyElement, AppContext, EventEmitter, HighlightStyle, ModelContext, Task, TaskLabel,
|
||||||
WindowContext,
|
WindowContext,
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use lsp::LanguageServerId;
|
use lsp::LanguageServerId;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
@ -44,7 +43,7 @@ use std::{
|
|||||||
ops::{Deref, Range},
|
ops::{Deref, Range},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
str,
|
str,
|
||||||
sync::Arc,
|
sync::{Arc, LazyLock},
|
||||||
time::{Duration, Instant, SystemTime},
|
time::{Duration, Instant, SystemTime},
|
||||||
vec,
|
vec,
|
||||||
};
|
};
|
||||||
@ -67,11 +66,9 @@ pub use {tree_sitter_rust, tree_sitter_typescript};
|
|||||||
|
|
||||||
pub use lsp::DiagnosticSeverity;
|
pub use lsp::DiagnosticSeverity;
|
||||||
|
|
||||||
lazy_static! {
|
/// A label for the background task spawned by the buffer to compute
|
||||||
/// A label for the background task spawned by the buffer to compute
|
/// a diff against the contents of its file.
|
||||||
/// a diff against the contents of its file.
|
pub static BUFFER_DIFF_TASK: LazyLock<TaskLabel> = LazyLock::new(|| TaskLabel::new());
|
||||||
pub static ref BUFFER_DIFF_TASK: TaskLabel = TaskLabel::new();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Indicate whether a [Buffer] has permissions to edit.
|
/// Indicate whether a [Buffer] has permissions to edit.
|
||||||
#[derive(PartialEq, Clone, Copy, Debug)]
|
#[derive(PartialEq, Clone, Copy, Debug)]
|
||||||
|
@ -16,6 +16,7 @@ use settings::SettingsStore;
|
|||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
|
sync::LazyLock,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
use text::network::Network;
|
use text::network::Network;
|
||||||
@ -24,12 +25,12 @@ use text::{Point, ToPoint};
|
|||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
use util::{assert_set_eq, post_inc, test::marked_text_ranges, RandomCharIter};
|
use util::{assert_set_eq, post_inc, test::marked_text_ranges, RandomCharIter};
|
||||||
|
|
||||||
lazy_static! {
|
pub static TRAILING_WHITESPACE_REGEX: LazyLock<regex::Regex> = LazyLock::new(|| {
|
||||||
static ref TRAILING_WHITESPACE_REGEX: Regex = RegexBuilder::new("[ \t]+$")
|
RegexBuilder::new(r"[ \t]+$")
|
||||||
.multi_line(true)
|
.multi_line(true)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.expect("Failed to create TRAILING_WHITESPACE_REGEX")
|
||||||
}
|
});
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[ctor::ctor]
|
#[ctor::ctor]
|
||||||
|
@ -28,7 +28,6 @@ use futures::Future;
|
|||||||
use gpui::{AppContext, AsyncAppContext, Model, SharedString, Task};
|
use gpui::{AppContext, AsyncAppContext, Model, SharedString, Task};
|
||||||
pub use highlight_map::HighlightMap;
|
pub use highlight_map::HighlightMap;
|
||||||
use http_client::HttpClient;
|
use http_client::HttpClient;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use lsp::{CodeActionKind, LanguageServerBinary};
|
use lsp::{CodeActionKind, LanguageServerBinary};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@ -53,7 +52,7 @@ use std::{
|
|||||||
str,
|
str,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicU64, AtomicUsize, Ordering::SeqCst},
|
atomic::{AtomicU64, AtomicUsize, Ordering::SeqCst},
|
||||||
Arc,
|
Arc, LazyLock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use syntax_map::{QueryCursorHandle, SyntaxSnapshot};
|
use syntax_map::{QueryCursorHandle, SyntaxSnapshot};
|
||||||
@ -111,23 +110,23 @@ where
|
|||||||
func(cursor.deref_mut())
|
func(cursor.deref_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static NEXT_LANGUAGE_ID: LazyLock<AtomicUsize> = LazyLock::new(Default::default);
|
||||||
static ref NEXT_LANGUAGE_ID: AtomicUsize = Default::default();
|
static NEXT_GRAMMAR_ID: LazyLock<AtomicUsize> = LazyLock::new(Default::default);
|
||||||
static ref NEXT_GRAMMAR_ID: AtomicUsize = Default::default();
|
static WASM_ENGINE: LazyLock<wasmtime::Engine> = LazyLock::new(|| {
|
||||||
static ref WASM_ENGINE: wasmtime::Engine = {
|
wasmtime::Engine::new(&wasmtime::Config::new()).expect("Failed to create Wasmtime engine")
|
||||||
wasmtime::Engine::new(&wasmtime::Config::new()).unwrap()
|
});
|
||||||
};
|
|
||||||
|
|
||||||
/// A shared grammar for plain text, exposed for reuse by downstream crates.
|
/// A shared grammar for plain text, exposed for reuse by downstream crates.
|
||||||
pub static ref PLAIN_TEXT: Arc<Language> = Arc::new(Language::new(
|
pub static PLAIN_TEXT: LazyLock<Arc<Language>> = LazyLock::new(|| {
|
||||||
|
Arc::new(Language::new(
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Plain Text".into(),
|
name: "Plain Text".into(),
|
||||||
soft_wrap: Some(SoftWrap::EditorWidth),
|
soft_wrap: Some(SoftWrap::EditorWidth),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
));
|
))
|
||||||
}
|
});
|
||||||
|
|
||||||
/// Types that represent a position in a buffer, and can be converted into
|
/// Types that represent a position in a buffer, and can be converted into
|
||||||
/// an LSP position, to send to a language server.
|
/// an LSP position, to send to a language server.
|
||||||
|
@ -22,7 +22,6 @@ futures.workspace = true
|
|||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
lsp.workspace = true
|
lsp.workspace = true
|
||||||
node_runtime.workspace = true
|
node_runtime.workspace = true
|
||||||
|
@ -4,7 +4,6 @@ use futures::StreamExt;
|
|||||||
use gpui::{AppContext, AsyncAppContext, Task};
|
use gpui::{AppContext, AsyncAppContext, Task};
|
||||||
use http_client::github::latest_github_release;
|
use http_client::github::latest_github_release;
|
||||||
pub use language::*;
|
pub use language::*;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use lsp::LanguageServerBinary;
|
use lsp::LanguageServerBinary;
|
||||||
use project::project_settings::{BinarySettings, ProjectSettings};
|
use project::project_settings::{BinarySettings, ProjectSettings};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@ -20,7 +19,7 @@ use std::{
|
|||||||
str,
|
str,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering::SeqCst},
|
atomic::{AtomicBool, Ordering::SeqCst},
|
||||||
Arc,
|
Arc, LazyLock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
|
use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
|
||||||
@ -37,12 +36,12 @@ impl GoLspAdapter {
|
|||||||
const SERVER_NAME: &'static str = "gopls";
|
const SERVER_NAME: &'static str = "gopls";
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
static GOPLS_VERSION_REGEX: LazyLock<Regex> =
|
||||||
static ref GOPLS_VERSION_REGEX: Regex = Regex::new(r"\d+\.\d+\.\d+").unwrap();
|
LazyLock::new(|| Regex::new(r"\d+\.\d+\.\d+").expect("Failed to create GOPLS_VERSION_REGEX"));
|
||||||
static ref GO_EXTRACT_SUBTEST_NAME_REGEX: Regex =
|
|
||||||
Regex::new(r#".*t\.Run\("([^"]*)".*"#).unwrap();
|
static GO_ESCAPE_SUBTEST_NAME_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
static ref GO_ESCAPE_SUBTEST_NAME_REGEX: Regex = Regex::new(r#"[.*+?^${}()|\[\]\\]"#).unwrap();
|
Regex::new(r#"[.*+?^${}()|\[\]\\]"#).expect("Failed to create GO_ESCAPE_SUBTEST_NAME_REGEX")
|
||||||
}
|
});
|
||||||
|
|
||||||
#[async_trait(?Send)]
|
#[async_trait(?Send)]
|
||||||
impl super::LspAdapter for GoLspAdapter {
|
impl super::LspAdapter for GoLspAdapter {
|
||||||
|
@ -6,7 +6,6 @@ use gpui::{AppContext, AsyncAppContext};
|
|||||||
use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
|
use http_client::github::{latest_github_release, GitHubLspBinaryVersion};
|
||||||
pub use language::*;
|
pub use language::*;
|
||||||
use language_settings::all_language_settings;
|
use language_settings::all_language_settings;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use lsp::LanguageServerBinary;
|
use lsp::LanguageServerBinary;
|
||||||
use project::project_settings::{BinarySettings, ProjectSettings};
|
use project::project_settings::{BinarySettings, ProjectSettings};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
@ -18,6 +17,7 @@ use std::{
|
|||||||
env::consts,
|
env::consts,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
sync::LazyLock,
|
||||||
};
|
};
|
||||||
use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
|
use task::{TaskTemplate, TaskTemplates, TaskVariables, VariableName};
|
||||||
use util::{fs::remove_matching, maybe, ResultExt};
|
use util::{fs::remove_matching, maybe, ResultExt};
|
||||||
@ -178,9 +178,8 @@ impl LspAdapter for RustLspAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
||||||
lazy_static! {
|
static REGEX: LazyLock<Regex> =
|
||||||
static ref REGEX: Regex = Regex::new("(?m)`([^`]+)\n`$").unwrap();
|
LazyLock::new(|| Regex::new(r"(?m)`([^`]+)\n`$").expect("Failed to create REGEX"));
|
||||||
}
|
|
||||||
|
|
||||||
for diagnostic in &mut params.diagnostics {
|
for diagnostic in &mut params.diagnostics {
|
||||||
for message in diagnostic
|
for message in diagnostic
|
||||||
@ -243,9 +242,8 @@ impl LspAdapter for RustLspAdapter {
|
|||||||
Some(lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD)
|
Some(lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD)
|
||||||
if detail.is_some() =>
|
if detail.is_some() =>
|
||||||
{
|
{
|
||||||
lazy_static! {
|
static REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new("\\(…?\\)").unwrap());
|
||||||
static ref REGEX: Regex = Regex::new("\\(…?\\)").unwrap();
|
|
||||||
}
|
|
||||||
let detail = detail.unwrap();
|
let detail = detail.unwrap();
|
||||||
const FUNCTION_PREFIXES: [&'static str; 6] = [
|
const FUNCTION_PREFIXES: [&'static str; 6] = [
|
||||||
"async fn",
|
"async fn",
|
||||||
|
@ -21,7 +21,6 @@ collections.workspace = true
|
|||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
release_channel.workspace = true
|
release_channel.workspace = true
|
||||||
|
@ -3,7 +3,6 @@ use collections::{btree_map, hash_map, BTreeMap, HashMap};
|
|||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use futures::{channel::mpsc, future::LocalBoxFuture, FutureExt, StreamExt};
|
use futures::{channel::mpsc, future::LocalBoxFuture, FutureExt, StreamExt};
|
||||||
use gpui::{AppContext, AsyncAppContext, BorrowAppContext, Global, Task, UpdateGlobal};
|
use gpui::{AppContext, AsyncAppContext, BorrowAppContext, Global, Task, UpdateGlobal};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use schemars::{gen::SchemaGenerator, schema::RootSchema, JsonSchema};
|
use schemars::{gen::SchemaGenerator, schema::RootSchema, JsonSchema};
|
||||||
use serde::{de::DeserializeOwned, Deserialize as _, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize as _, Serialize};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
@ -13,8 +12,10 @@ use std::{
|
|||||||
ops::Range,
|
ops::Range,
|
||||||
path::Path,
|
path::Path,
|
||||||
str,
|
str,
|
||||||
sync::Arc,
|
sync::{Arc, LazyLock},
|
||||||
};
|
};
|
||||||
|
use tree_sitter::Query;
|
||||||
|
use tree_sitter_json::language;
|
||||||
use util::{merge_non_null_json_value_into, RangeExt, ResultExt as _};
|
use util::{merge_non_null_json_value_into, RangeExt, ResultExt as _};
|
||||||
|
|
||||||
use crate::SettingsJsonSchemaParams;
|
use crate::SettingsJsonSchemaParams;
|
||||||
@ -944,13 +945,10 @@ fn replace_value_in_json_text(
|
|||||||
tab_size: usize,
|
tab_size: usize,
|
||||||
new_value: &serde_json::Value,
|
new_value: &serde_json::Value,
|
||||||
) -> (Range<usize>, String) {
|
) -> (Range<usize>, String) {
|
||||||
lazy_static! {
|
static PAIR_QUERY: LazyLock<Query> = LazyLock::new(|| {
|
||||||
static ref PAIR_QUERY: tree_sitter::Query = tree_sitter::Query::new(
|
Query::new(&language(), "(pair key: (string) @key value: (_) @value)")
|
||||||
&tree_sitter_json::language(),
|
.expect("Failed to create PAIR_QUERY")
|
||||||
"(pair key: (string) @key value: (_) @value)",
|
});
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut parser = tree_sitter::Parser::new();
|
let mut parser = tree_sitter::Parser::new();
|
||||||
parser.set_language(&tree_sitter_json::language()).unwrap();
|
parser.set_language(&tree_sitter_json::language()).unwrap();
|
||||||
|
@ -13,7 +13,6 @@ anyhow.workspace = true
|
|||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
libsqlite3-sys = { version = "0.26", features = ["bundled"] }
|
libsqlite3-sys = { version = "0.26", features = ["bundled"] }
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use futures::{channel::oneshot, Future, FutureExt};
|
use futures::{channel::oneshot, Future, FutureExt};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use std::{marker::PhantomData, ops::Deref, sync::Arc, thread};
|
use std::{
|
||||||
|
marker::PhantomData,
|
||||||
|
ops::Deref,
|
||||||
|
sync::{Arc, LazyLock},
|
||||||
|
thread,
|
||||||
|
};
|
||||||
use thread_local::ThreadLocal;
|
use thread_local::ThreadLocal;
|
||||||
|
|
||||||
use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender};
|
use crate::{connection::Connection, domain::Migrator, util::UnboundedSyncSender};
|
||||||
@ -13,14 +17,13 @@ const MIGRATION_RETRIES: usize = 10;
|
|||||||
type QueuedWrite = Box<dyn 'static + Send + FnOnce()>;
|
type QueuedWrite = Box<dyn 'static + Send + FnOnce()>;
|
||||||
type WriteQueue = Box<dyn 'static + Send + Sync + Fn(QueuedWrite)>;
|
type WriteQueue = Box<dyn 'static + Send + Sync + Fn(QueuedWrite)>;
|
||||||
type WriteQueueConstructor = Box<dyn 'static + Send + FnMut() -> WriteQueue>;
|
type WriteQueueConstructor = Box<dyn 'static + Send + FnMut() -> WriteQueue>;
|
||||||
lazy_static! {
|
|
||||||
/// List of queues of tasks by database uri. This lets us serialize writes to the database
|
/// List of queues of tasks by database uri. This lets us serialize writes to the database
|
||||||
/// and have a single worker thread per db file. This means many thread safe connections
|
/// and have a single worker thread per db file. This means many thread safe connections
|
||||||
/// (possibly with different migrations) could all be communicating with the same background
|
/// (possibly with different migrations) could all be communicating with the same background
|
||||||
/// thread.
|
/// thread.
|
||||||
static ref QUEUES: RwLock<HashMap<Arc<str>, WriteQueue>> =
|
static QUEUES: LazyLock<RwLock<HashMap<Arc<str>, WriteQueue>>> =
|
||||||
Default::default();
|
LazyLock::new(|| Default::default());
|
||||||
}
|
|
||||||
|
|
||||||
/// Thread safe connection to a given database file or in memory db. This can be cloned, shared, static,
|
/// Thread safe connection to a given database file or in memory db. This can be cloned, shared, static,
|
||||||
/// whatever. It derefs to a synchronous connection by thread that is read only. A write capable connection
|
/// whatever. It derefs to a synchronous connection by thread that is read only. A write capable connection
|
||||||
@ -276,7 +279,7 @@ pub fn locking_queue() -> WriteQueueConstructor {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use lazy_static::__Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ proc-macro = true
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lazy_static.workspace = true
|
|
||||||
sqlez.workspace = true
|
sqlez.workspace = true
|
||||||
sqlformat = "0.2"
|
sqlformat = "0.2"
|
||||||
syn = "1.0"
|
syn = "1.0"
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
use proc_macro::{Delimiter, Span, TokenStream, TokenTree};
|
use proc_macro::{Delimiter, Span, TokenStream, TokenTree};
|
||||||
use sqlez::thread_safe_connection::{locking_queue, ThreadSafeConnection};
|
|
||||||
use syn::Error;
|
use syn::Error;
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
#[cfg(not(target_os = "linux"))]
|
||||||
static ref SQLITE: ThreadSafeConnection = {
|
static SQLITE: std::sync::LazyLock<sqlez::thread_safe_connection::ThreadSafeConnection> =
|
||||||
ThreadSafeConnection::new(":memory:", false, None, Some(locking_queue()))
|
std::sync::LazyLock::new(|| {
|
||||||
};
|
sqlez::thread_safe_connection::ThreadSafeConnection::new(
|
||||||
}
|
":memory:",
|
||||||
|
false,
|
||||||
|
None,
|
||||||
|
Some(sqlez::thread_safe_connection::locking_queue()),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn sql(tokens: TokenStream) -> TokenStream {
|
pub fn sql(tokens: TokenStream) -> TokenStream {
|
||||||
|
@ -19,7 +19,6 @@ test-support = ["rand"]
|
|||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
clock.workspace = true
|
clock.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
postage.workspace = true
|
postage.workspace = true
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
use lazy_static::lazy_static;
|
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
lazy_static! {
|
static MIN: LazyLock<Locator> = LazyLock::new(|| Locator::min());
|
||||||
static ref MIN: Locator = Locator::min();
|
static MAX: LazyLock<Locator> = LazyLock::new(|| Locator::max());
|
||||||
static ref MAX: Locator = Locator::max();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// An identifier for a position in a ordered collection.
|
/// An identifier for a position in a ordered collection.
|
||||||
///
|
///
|
||||||
|
@ -19,7 +19,6 @@ use operation_queue::OperationQueue;
|
|||||||
pub use patch::Patch;
|
pub use patch::Patch;
|
||||||
use postage::{oneshot, prelude::*};
|
use postage::{oneshot, prelude::*};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
pub use rope::*;
|
pub use rope::*;
|
||||||
pub use selection::*;
|
pub use selection::*;
|
||||||
@ -32,7 +31,7 @@ use std::{
|
|||||||
num::NonZeroU64,
|
num::NonZeroU64,
|
||||||
ops::{self, Deref, Range, Sub},
|
ops::{self, Deref, Range, Sub},
|
||||||
str,
|
str,
|
||||||
sync::Arc,
|
sync::{Arc, LazyLock},
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
pub use subscription::*;
|
pub use subscription::*;
|
||||||
@ -44,9 +43,9 @@ use util::ResultExt;
|
|||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
use util::RandomCharIter;
|
use util::RandomCharIter;
|
||||||
|
|
||||||
lazy_static! {
|
static LINE_SEPARATORS_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
static ref LINE_SEPARATORS_REGEX: Regex = Regex::new("\r\n|\r|\u{2028}|\u{2029}").unwrap();
|
Regex::new(r"\r\n|\r|\u{2028}|\u{2029}").expect("Failed to create LINE_SEPARATORS_REGEX")
|
||||||
}
|
});
|
||||||
|
|
||||||
pub type TransactionId = clock::Lamport;
|
pub type TransactionId = clock::Lamport;
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ editor.workspace = true
|
|||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
multi_buffer.workspace = true
|
multi_buffer.workspace = true
|
||||||
nvim-rs = { git = "https://github.com/KillTheMule/nvim-rs", branch = "master", features = [
|
nvim-rs = { git = "https://github.com/KillTheMule/nvim-rs", branch = "master", features = [
|
||||||
|
@ -2,25 +2,23 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use gpui::AppContext;
|
use gpui::AppContext;
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
use std::sync::LazyLock;
|
||||||
use ui::WindowContext;
|
use ui::WindowContext;
|
||||||
|
|
||||||
use crate::{Vim, VimSettings};
|
use crate::{Vim, VimSettings};
|
||||||
|
|
||||||
mod default;
|
mod default;
|
||||||
|
|
||||||
lazy_static! {
|
static DEFAULT_DIGRAPHS_MAP: LazyLock<HashMap<String, Arc<str>>> = LazyLock::new(|| {
|
||||||
static ref DEFAULT_DIGRAPHS_MAP: HashMap<String, Arc<str>> = {
|
let mut map = HashMap::default();
|
||||||
let mut map = HashMap::default();
|
for &(a, b, c) in default::DEFAULT_DIGRAPHS {
|
||||||
for &(a, b, c) in default::DEFAULT_DIGRAPHS {
|
let key = format!("{a}{b}");
|
||||||
let key = format!("{a}{b}");
|
let value = char::from_u32(c).unwrap().to_string().into();
|
||||||
let value = char::from_u32(c).unwrap().to_string().into();
|
map.insert(key, value);
|
||||||
map.insert(key, value);
|
}
|
||||||
}
|
map
|
||||||
map
|
});
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn lookup_digraph(a: char, b: char, cx: &AppContext) -> Arc<str> {
|
fn lookup_digraph(a: char, b: char, cx: &AppContext) -> Arc<str> {
|
||||||
let custom_digraphs = &VimSettings::get_global(cx).custom_digraphs;
|
let custom_digraphs = &VimSettings::get_global(cx).custom_digraphs;
|
||||||
|
@ -43,7 +43,6 @@ gpui.workspace = true
|
|||||||
http_client.workspace = true
|
http_client.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
language.workspace = true
|
language.workspace = true
|
||||||
lazy_static.workspace = true
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
node_runtime.workspace = true
|
node_runtime.workspace = true
|
||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
|
@ -44,7 +44,6 @@ pub use item::{
|
|||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{LanguageRegistry, Rope};
|
use language::{LanguageRegistry, Rope};
|
||||||
use lazy_static::lazy_static;
|
|
||||||
pub use modal_layer::*;
|
pub use modal_layer::*;
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
use notifications::{simple_message_notification::MessageNotification, NotificationHandle};
|
use notifications::{simple_message_notification::MessageNotification, NotificationHandle};
|
||||||
@ -77,7 +76,7 @@ use std::{
|
|||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::{atomic::AtomicUsize, Arc, Weak},
|
sync::{atomic::AtomicUsize, Arc, LazyLock, Weak},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use task::SpawnInTerminal;
|
use task::SpawnInTerminal;
|
||||||
@ -101,16 +100,19 @@ use crate::persistence::{
|
|||||||
SerializedAxis,
|
SerializedAxis,
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_static! {
|
static ZED_WINDOW_SIZE: LazyLock<Option<Size<Pixels>>> = LazyLock::new(|| {
|
||||||
static ref ZED_WINDOW_SIZE: Option<Size<Pixels>> = env::var("ZED_WINDOW_SIZE")
|
env::var("ZED_WINDOW_SIZE")
|
||||||
.ok()
|
.ok()
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.and_then(parse_pixel_size_env_var);
|
.and_then(parse_pixel_size_env_var)
|
||||||
static ref ZED_WINDOW_POSITION: Option<Point<Pixels>> = env::var("ZED_WINDOW_POSITION")
|
});
|
||||||
|
|
||||||
|
static ZED_WINDOW_POSITION: LazyLock<Option<Point<Pixels>>> = LazyLock::new(|| {
|
||||||
|
env::var("ZED_WINDOW_POSITION")
|
||||||
.ok()
|
.ok()
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.and_then(parse_pixel_position_env_var);
|
.and_then(parse_pixel_position_env_var)
|
||||||
}
|
});
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
pub struct RemoveWorktreeFromProject(pub WorktreeId);
|
pub struct RemoveWorktreeFromProject(pub WorktreeId);
|
||||||
|
Loading…
Reference in New Issue
Block a user