crates/chat_panel/Cargo.toml 🔗
@@ -3,6 +3,9 @@ name = "chat_panel"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/chat_panel.rs"
+
[dependencies]
client = { path = "../client" }
editor = { path = "../editor" }
Nathan Sobo and Max Brunsfeld created
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
crates/chat_panel/Cargo.toml | 3 +
crates/chat_panel/src/chat_panel.rs | 0
crates/client/Cargo.toml | 3 +
crates/client/src/client.rs | 0
crates/clock/Cargo.toml | 3 +
crates/clock/src/clock.rs | 0
crates/collections/Cargo.toml | 3 +
crates/collections/src/collections.rs | 0
crates/contacts_panel/Cargo.toml | 3 +
crates/contacts_panel/src/contacts_panel.rs | 0
crates/editor/Cargo.toml | 3 +
crates/editor/src/editor.rs | 0
crates/file_finder/Cargo.toml | 3 +
crates/file_finder/src/file_finder.rs | 0
crates/fsevent/Cargo.toml | 3 +
crates/fsevent/src/fsevent.rs | 0
crates/fuzzy/Cargo.toml | 3 +
crates/fuzzy/src/fuzzy.rs | 0
crates/go_to_line/Cargo.toml | 3 +
crates/go_to_line/src/go_to_line.rs | 0
crates/gpui/Cargo.toml | 3 +
crates/gpui/src/gpui.rs | 0
crates/gpui_macros/Cargo.toml | 1
crates/gpui_macros/src/gpui_macros.rs | 0
crates/language/Cargo.toml | 3 +
crates/language/src/buffer.rs | 30 ++++------
crates/language/src/language.rs | 63 +++-------------------
crates/language/src/proto.rs | 4 -
crates/language/src/tests.rs | 52 ++++++++++++++++++
crates/lsp/Cargo.toml | 3 +
crates/lsp/src/lsp.rs | 0
crates/project/Cargo.toml | 3 +
crates/project/src/project.rs | 0
crates/project_panel/Cargo.toml | 3 +
crates/project_panel/src/project_panel.rs | 0
crates/rpc/Cargo.toml | 3 +
crates/rpc/src/rpc.rs | 0
crates/sum_tree/Cargo.toml | 3 +
crates/sum_tree/src/sum_tree.rs | 0
crates/theme/Cargo.toml | 3 +
crates/theme/src/theme.rs | 0
crates/theme_selector/Cargo.toml | 3 +
crates/theme_selector/src/theme_selector.rs | 0
crates/workspace/Cargo.toml | 3 +
crates/workspace/src/workspace.rs | 0
crates/zed/Cargo.toml | 2
crates/zed/src/zed.rs | 0
47 files changed, 133 insertions(+), 79 deletions(-)
@@ -3,6 +3,9 @@ name = "chat_panel"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/chat_panel.rs"
+
[dependencies]
client = { path = "../client" }
editor = { path = "../editor" }
@@ -3,6 +3,9 @@ name = "client"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/client.rs"
+
[features]
test-support = ["rpc/test-support"]
@@ -3,6 +3,9 @@ name = "clock"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/clock.rs"
+
[dependencies]
smallvec = { version = "1.6", features = ["union"] }
rpc = { path = "../rpc" }
@@ -3,6 +3,9 @@ name = "collections"
version = "0.1.0"
edition = "2021"
+[lib]
+path = "src/collections.rs"
+
[features]
test-support = ["seahash"]
@@ -3,6 +3,9 @@ name = "contacts_panel"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/contacts_panel.rs"
+
[dependencies]
client = { path = "../client" }
gpui = { path = "../gpui" }
@@ -3,6 +3,9 @@ name = "editor"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/editor.rs"
+
[features]
test-support = [
"text/test-support",
@@ -3,6 +3,9 @@ name = "file_finder"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/file_finder.rs"
+
[dependencies]
editor = { path = "../editor" }
fuzzy = { path = "../fuzzy" }
@@ -4,6 +4,9 @@ version = "2.0.2"
license = "MIT"
edition = "2018"
+[lib]
+path = "src/fsevent.rs"
+
[dependencies]
bitflags = "1"
fsevent-sys = "3.0.2"
@@ -3,6 +3,9 @@ name = "fuzzy"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/fuzzy.rs"
+
[dependencies]
gpui = { path = "../gpui" }
util = { path = "../util" }
@@ -3,6 +3,9 @@ name = "go_to_line"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/go_to_line.rs"
+
[dependencies]
text = { path = "../text" }
editor = { path = "../editor" }
@@ -4,6 +4,9 @@ edition = "2018"
name = "gpui"
version = "0.1.0"
+[lib]
+path = "src/gpui.rs"
+
[features]
test-support = ["env_logger"]
@@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2018"
[lib]
+path = "src/gpui_macros.rs"
proc-macro = true
[dependencies]
@@ -3,6 +3,9 @@ name = "language"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/language.rs"
+
[features]
test-support = [
"rand",
@@ -1,15 +1,7 @@
-mod highlight_map;
-mod language;
-pub mod proto;
-#[cfg(test)]
-mod tests;
-
-pub use self::{
+pub use crate::{
highlight_map::{HighlightId, HighlightMap},
- language::{
- BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
- PLAIN_TEXT,
- },
+ proto, BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
+ PLAIN_TEXT,
};
use anyhow::{anyhow, Result};
use clock::ReplicaId;
@@ -73,7 +65,7 @@ pub struct Buffer {
diagnostics_update_count: usize,
language_server: Option<LanguageServerState>,
#[cfg(test)]
- operations: Vec<Operation>,
+ pub(crate) operations: Vec<Operation>,
}
pub struct Snapshot {
@@ -217,7 +209,7 @@ pub struct Chunk<'a> {
pub diagnostic: Option<DiagnosticSeverity>,
}
-struct Diff {
+pub(crate) struct Diff {
base_version: clock::Global,
new_text: Arc<str>,
changes: Vec<(ChangeTag, usize)>,
@@ -573,7 +565,7 @@ impl Buffer {
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() {
self.interpolate_tree(syntax_tree);
Some(syntax_tree.tree.clone())
@@ -1094,7 +1086,7 @@ impl Buffer {
.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.
let old_text = self.text();
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 {
self.start_transaction(None).unwrap();
let mut offset = 0;
@@ -1153,7 +1145,7 @@ impl Buffer {
self.start_transaction_at(selection_set_ids, Instant::now())
}
- fn start_transaction_at(
+ pub(crate) fn start_transaction_at(
&mut self,
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
now: Instant,
@@ -1169,7 +1161,7 @@ impl Buffer {
self.end_transaction_at(selection_set_ids, Instant::now(), cx)
}
- fn end_transaction_at(
+ pub(crate) fn end_transaction_at(
&mut self,
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
now: Instant,
@@ -1995,7 +1987,7 @@ fn diagnostic_ranges<'a>(
))
}
-fn contiguous_ranges(
+pub fn contiguous_ranges(
values: impl IntoIterator<Item = u32>,
max_len: usize,
) -> 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};
+pub use buffer::Operation;
+pub use buffer::*;
use gpui::{executor::Background, AppContext};
+use highlight_map::HighlightMap;
use lazy_static::lazy_static;
use lsp::LanguageServer;
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 crate::Diagnostic;
-
-use super::Operation;
+use crate::{Diagnostic, Operation};
use anyhow::{anyhow, Result};
use clock::ReplicaId;
use lsp::DiagnosticSeverity;
@@ -1,8 +1,56 @@
use super::*;
-use gpui::{ModelHandle, MutableAppContext};
-use std::{iter::FromIterator, rc::Rc};
+use gpui::{ModelHandle, MutableAppContext, Task};
+use std::{any::Any, cell::RefCell, ffi::OsString, iter::FromIterator, ops::Range, path::PathBuf, rc::Rc, time::{Duration, Instant, SystemTime}};
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]
fn test_edit_events(cx: &mut gpui::MutableAppContext) {
let mut now = Instant::now();
@@ -3,6 +3,9 @@ name = "lsp"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/lsp.rs"
+
[features]
test-support = ["async-pipe"]
@@ -3,6 +3,9 @@ name = "project"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/project.rs"
+
[features]
test-support = ["language/test-support", "text/test-support"]
@@ -3,6 +3,9 @@ name = "project_panel"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/project_panel.rs"
+
[dependencies]
gpui = { path = "../gpui" }
project = { path = "../project" }
@@ -4,6 +4,9 @@ edition = "2018"
name = "rpc"
version = "0.1.0"
+[lib]
+path = "src/rpc.rs"
+
[features]
test-support = []
@@ -3,6 +3,9 @@ name = "sum_tree"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/sum_tree.rs"
+
[dependencies]
arrayvec = "0.7.1"
@@ -3,6 +3,9 @@ name = "theme"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/theme.rs"
+
[dependencies]
gpui = { path = "../gpui" }
anyhow = "1.0.38"
@@ -3,6 +3,9 @@ name = "theme_selector"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/theme_selector.rs"
+
[dependencies]
editor = { path = "../editor" }
fuzzy = { path = "../fuzzy" }
@@ -3,6 +3,9 @@ name = "workspace"
version = "0.1.0"
edition = "2018"
+[lib]
+path = "src/workspace.rs"
+
[features]
test-support = [
"client/test-support",
@@ -7,7 +7,7 @@ version = "0.9.0"
[lib]
name = "zed"
-path = "src/lib.rs"
+path = "src/zed.rs"
[[bin]]
name = "Zed"