mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Name the root file of every crate after the crate to ease navigation
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
748b1ba602
commit
1445ce10b5
@ -3,6 +3,9 @@ name = "chat_panel"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/chat_panel.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
client = { path = "../client" }
|
client = { path = "../client" }
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
|
@ -3,6 +3,9 @@ name = "client"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/client.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["rpc/test-support"]
|
test-support = ["rpc/test-support"]
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ name = "clock"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/clock.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
|
@ -3,6 +3,9 @@ name = "collections"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/collections.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["seahash"]
|
test-support = ["seahash"]
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ name = "contacts_panel"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/contacts_panel.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
client = { path = "../client" }
|
client = { path = "../client" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
|
@ -3,6 +3,9 @@ name = "editor"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/editor.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"text/test-support",
|
"text/test-support",
|
||||||
|
@ -3,6 +3,9 @@ name = "file_finder"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/file_finder.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
fuzzy = { path = "../fuzzy" }
|
fuzzy = { path = "../fuzzy" }
|
||||||
|
@ -4,6 +4,9 @@ version = "2.0.2"
|
|||||||
license = "MIT"
|
license = "MIT"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/fsevent.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
fsevent-sys = "3.0.2"
|
fsevent-sys = "3.0.2"
|
||||||
|
@ -3,6 +3,9 @@ name = "fuzzy"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/fuzzy.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
|
@ -3,6 +3,9 @@ name = "go_to_line"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/go_to_line.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
text = { path = "../text" }
|
text = { path = "../text" }
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
|
@ -4,6 +4,9 @@ edition = "2018"
|
|||||||
name = "gpui"
|
name = "gpui"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/gpui.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["env_logger"]
|
test-support = ["env_logger"]
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
path = "src/gpui_macros.rs"
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -3,6 +3,9 @@ name = "language"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/language.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"rand",
|
"rand",
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
mod highlight_map;
|
pub use crate::{
|
||||||
mod language;
|
|
||||||
pub mod proto;
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
pub use self::{
|
|
||||||
highlight_map::{HighlightId, HighlightMap},
|
highlight_map::{HighlightId, HighlightMap},
|
||||||
language::{
|
proto, BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
|
||||||
BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
|
PLAIN_TEXT,
|
||||||
PLAIN_TEXT,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
@ -73,7 +65,7 @@ pub struct Buffer {
|
|||||||
diagnostics_update_count: usize,
|
diagnostics_update_count: usize,
|
||||||
language_server: Option<LanguageServerState>,
|
language_server: Option<LanguageServerState>,
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
operations: Vec<Operation>,
|
pub(crate) operations: Vec<Operation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Snapshot {
|
pub struct Snapshot {
|
||||||
@ -217,7 +209,7 @@ pub struct Chunk<'a> {
|
|||||||
pub diagnostic: Option<DiagnosticSeverity>,
|
pub diagnostic: Option<DiagnosticSeverity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Diff {
|
pub(crate) struct Diff {
|
||||||
base_version: clock::Global,
|
base_version: clock::Global,
|
||||||
new_text: Arc<str>,
|
new_text: Arc<str>,
|
||||||
changes: Vec<(ChangeTag, usize)>,
|
changes: Vec<(ChangeTag, usize)>,
|
||||||
@ -573,7 +565,7 @@ impl Buffer {
|
|||||||
self.parse_count
|
self.parse_count
|
||||||
}
|
}
|
||||||
|
|
||||||
fn syntax_tree(&self) -> Option<Tree> {
|
pub(crate) fn syntax_tree(&self) -> Option<Tree> {
|
||||||
if let Some(syntax_tree) = self.syntax_tree.lock().as_mut() {
|
if let Some(syntax_tree) = self.syntax_tree.lock().as_mut() {
|
||||||
self.interpolate_tree(syntax_tree);
|
self.interpolate_tree(syntax_tree);
|
||||||
Some(syntax_tree.tree.clone())
|
Some(syntax_tree.tree.clone())
|
||||||
@ -1094,7 +1086,7 @@ impl Buffer {
|
|||||||
.min_by_key(|(open_range, close_range)| close_range.end - open_range.start)
|
.min_by_key(|(open_range, close_range)| close_range.end - open_range.start)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff(&self, new_text: Arc<str>, cx: &AppContext) -> Task<Diff> {
|
pub(crate) fn diff(&self, new_text: Arc<str>, cx: &AppContext) -> Task<Diff> {
|
||||||
// TODO: it would be nice to not allocate here.
|
// TODO: it would be nice to not allocate here.
|
||||||
let old_text = self.text();
|
let old_text = self.text();
|
||||||
let base_version = self.version();
|
let base_version = self.version();
|
||||||
@ -1111,7 +1103,7 @@ impl Buffer {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_diff(&mut self, diff: Diff, cx: &mut ModelContext<Self>) -> bool {
|
pub(crate) fn apply_diff(&mut self, diff: Diff, cx: &mut ModelContext<Self>) -> bool {
|
||||||
if self.version == diff.base_version {
|
if self.version == diff.base_version {
|
||||||
self.start_transaction(None).unwrap();
|
self.start_transaction(None).unwrap();
|
||||||
let mut offset = 0;
|
let mut offset = 0;
|
||||||
@ -1153,7 +1145,7 @@ impl Buffer {
|
|||||||
self.start_transaction_at(selection_set_ids, Instant::now())
|
self.start_transaction_at(selection_set_ids, Instant::now())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_transaction_at(
|
pub(crate) fn start_transaction_at(
|
||||||
&mut self,
|
&mut self,
|
||||||
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
|
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
|
||||||
now: Instant,
|
now: Instant,
|
||||||
@ -1169,7 +1161,7 @@ impl Buffer {
|
|||||||
self.end_transaction_at(selection_set_ids, Instant::now(), cx)
|
self.end_transaction_at(selection_set_ids, Instant::now(), cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end_transaction_at(
|
pub(crate) fn end_transaction_at(
|
||||||
&mut self,
|
&mut self,
|
||||||
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
|
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
|
||||||
now: Instant,
|
now: Instant,
|
||||||
@ -1995,7 +1987,7 @@ fn diagnostic_ranges<'a>(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn contiguous_ranges(
|
pub fn contiguous_ranges(
|
||||||
values: impl IntoIterator<Item = u32>,
|
values: impl IntoIterator<Item = u32>,
|
||||||
max_len: usize,
|
max_len: usize,
|
||||||
) -> impl Iterator<Item = Range<u32>> {
|
) -> impl Iterator<Item = Range<u32>> {
|
@ -1,6 +1,14 @@
|
|||||||
use crate::HighlightMap;
|
mod buffer;
|
||||||
|
mod highlight_map;
|
||||||
|
pub mod proto;
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
pub use buffer::Operation;
|
||||||
|
pub use buffer::*;
|
||||||
use gpui::{executor::Background, AppContext};
|
use gpui::{executor::Background, AppContext};
|
||||||
|
use highlight_map::HighlightMap;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use lsp::LanguageServer;
|
use lsp::LanguageServer;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@ -223,56 +231,3 @@ impl LanguageServerConfig {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_select_language() {
|
|
||||||
let registry = LanguageRegistry {
|
|
||||||
languages: vec![
|
|
||||||
Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
|
||||||
name: "Rust".to_string(),
|
|
||||||
path_suffixes: vec!["rs".to_string()],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
Some(tree_sitter_rust::language()),
|
|
||||||
)),
|
|
||||||
Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
|
||||||
name: "Make".to_string(),
|
|
||||||
path_suffixes: vec!["Makefile".to_string(), "mk".to_string()],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
Some(tree_sitter_rust::language()),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
// matching file extension
|
|
||||||
assert_eq!(
|
|
||||||
registry.select_language("zed/lib.rs").map(|l| l.name()),
|
|
||||||
Some("Rust")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
registry.select_language("zed/lib.mk").map(|l| l.name()),
|
|
||||||
Some("Make")
|
|
||||||
);
|
|
||||||
|
|
||||||
// matching filename
|
|
||||||
assert_eq!(
|
|
||||||
registry.select_language("zed/Makefile").map(|l| l.name()),
|
|
||||||
Some("Make")
|
|
||||||
);
|
|
||||||
|
|
||||||
// matching suffix that is not the full file extension or filename
|
|
||||||
assert_eq!(registry.select_language("zed/cars").map(|l| l.name()), None);
|
|
||||||
assert_eq!(
|
|
||||||
registry.select_language("zed/a.cars").map(|l| l.name()),
|
|
||||||
None
|
|
||||||
);
|
|
||||||
assert_eq!(registry.select_language("zed/sumk").map(|l| l.name()), None);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use crate::Diagnostic;
|
use crate::{Diagnostic, Operation};
|
||||||
|
|
||||||
use super::Operation;
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use lsp::DiagnosticSeverity;
|
use lsp::DiagnosticSeverity;
|
||||||
|
@ -1,8 +1,56 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use gpui::{ModelHandle, MutableAppContext};
|
use gpui::{ModelHandle, MutableAppContext, Task};
|
||||||
use std::{iter::FromIterator, rc::Rc};
|
use std::{any::Any, cell::RefCell, ffi::OsString, iter::FromIterator, ops::Range, path::PathBuf, rc::Rc, time::{Duration, Instant, SystemTime}};
|
||||||
use unindent::Unindent as _;
|
use unindent::Unindent as _;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_select_language() {
|
||||||
|
let registry = LanguageRegistry {
|
||||||
|
languages: vec![
|
||||||
|
Arc::new(Language::new(
|
||||||
|
LanguageConfig {
|
||||||
|
name: "Rust".to_string(),
|
||||||
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
Some(tree_sitter_rust::language()),
|
||||||
|
)),
|
||||||
|
Arc::new(Language::new(
|
||||||
|
LanguageConfig {
|
||||||
|
name: "Make".to_string(),
|
||||||
|
path_suffixes: vec!["Makefile".to_string(), "mk".to_string()],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
Some(tree_sitter_rust::language()),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
// matching file extension
|
||||||
|
assert_eq!(
|
||||||
|
registry.select_language("zed/lib.rs").map(|l| l.name()),
|
||||||
|
Some("Rust")
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
registry.select_language("zed/lib.mk").map(|l| l.name()),
|
||||||
|
Some("Make")
|
||||||
|
);
|
||||||
|
|
||||||
|
// matching filename
|
||||||
|
assert_eq!(
|
||||||
|
registry.select_language("zed/Makefile").map(|l| l.name()),
|
||||||
|
Some("Make")
|
||||||
|
);
|
||||||
|
|
||||||
|
// matching suffix that is not the full file extension or filename
|
||||||
|
assert_eq!(registry.select_language("zed/cars").map(|l| l.name()), None);
|
||||||
|
assert_eq!(
|
||||||
|
registry.select_language("zed/a.cars").map(|l| l.name()),
|
||||||
|
None
|
||||||
|
);
|
||||||
|
assert_eq!(registry.select_language("zed/sumk").map(|l| l.name()), None);
|
||||||
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_edit_events(cx: &mut gpui::MutableAppContext) {
|
fn test_edit_events(cx: &mut gpui::MutableAppContext) {
|
||||||
let mut now = Instant::now();
|
let mut now = Instant::now();
|
||||||
|
@ -3,6 +3,9 @@ name = "lsp"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lsp.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["async-pipe"]
|
test-support = ["async-pipe"]
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ name = "project"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/project.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = ["language/test-support", "text/test-support"]
|
test-support = ["language/test-support", "text/test-support"]
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ name = "project_panel"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/project_panel.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
|
@ -4,6 +4,9 @@ edition = "2018"
|
|||||||
name = "rpc"
|
name = "rpc"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/rpc.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = []
|
test-support = []
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ name = "sum_tree"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/sum_tree.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
arrayvec = "0.7.1"
|
arrayvec = "0.7.1"
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@ name = "theme"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/theme.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
|
@ -3,6 +3,9 @@ name = "theme_selector"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/theme_selector.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
fuzzy = { path = "../fuzzy" }
|
fuzzy = { path = "../fuzzy" }
|
||||||
|
@ -3,6 +3,9 @@ name = "workspace"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/workspace.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
test-support = [
|
test-support = [
|
||||||
"client/test-support",
|
"client/test-support",
|
||||||
|
@ -7,7 +7,7 @@ version = "0.9.0"
|
|||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "zed"
|
name = "zed"
|
||||||
path = "src/lib.rs"
|
path = "src/zed.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "Zed"
|
name = "Zed"
|
||||||
|
Loading…
Reference in New Issue
Block a user