chore: Extract languages from zed crate (#8270)

- Moves languages module from `zed` into a separate crate. That way we
have less of a long pole at the end of compilation.
- Removes moot dependencies on editor/picker. This is totally harmless
and might help in the future if we decide to decouple picker from
editor.

Before:
```
Number of crates that depend on 'picker' but not on 'editor': 1
Total number of crates that depend on 'picker': 13
Total number of crates that depend on 'editor': 30
```
After:
```
Number of crates that depend on 'picker' but not on 'editor': 5
Total number of crates that depend on 'picker': 12
Total number of crates that depend on 'editor': 26
```
The more crates depend on just picker but not editor, the better in that
case.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-02-23 15:56:08 +01:00 committed by GitHub
parent 7cf0696c89
commit 0f584cb353
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
309 changed files with 221 additions and 154 deletions

169
Cargo.lock generated
View File

@ -415,9 +415,9 @@ dependencies = [
[[package]]
name = "async-compression"
version = "0.4.5"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc2d0cfb2a7388d34f590e76686704c494ed7aaceed62ee1ba35cbf363abc2a5"
checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c"
dependencies = [
"flate2",
"futures-core",
@ -692,9 +692,9 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799"
[[package]]
name = "async-trait"
version = "0.1.73"
version = "0.1.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0"
checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9"
dependencies = [
"proc-macro2",
"quote",
@ -3313,7 +3313,6 @@ dependencies = [
"fuzzy",
"gpui",
"log",
"picker",
"project",
"serde",
"serde_json",
@ -4799,7 +4798,7 @@ dependencies = [
"schemars",
"serde",
"settings",
"shellexpand",
"shellexpand 2.1.2",
"util",
"workspace",
]
@ -4994,6 +4993,89 @@ dependencies = [
"workspace",
]
[[package]]
name = "languages"
version = "0.1.0"
dependencies = [
"anyhow",
"async-compression",
"async-tar",
"async-trait",
"collections",
"feature_flags",
"futures 0.3.28",
"gpui",
"language",
"lazy_static",
"log",
"lsp",
"node_runtime",
"parking_lot 0.11.2",
"project",
"regex",
"rope",
"rust-embed",
"schemars",
"serde",
"serde_derive",
"serde_json",
"settings",
"shellexpand 3.1.0",
"smol",
"task",
"text",
"theme",
"toml 0.8.10",
"tree-sitter",
"tree-sitter-astro",
"tree-sitter-bash",
"tree-sitter-c",
"tree-sitter-c-sharp",
"tree-sitter-clojure",
"tree-sitter-cpp",
"tree-sitter-css",
"tree-sitter-dart",
"tree-sitter-dockerfile",
"tree-sitter-elixir",
"tree-sitter-elm",
"tree-sitter-embedded-template",
"tree-sitter-erlang",
"tree-sitter-gitcommit",
"tree-sitter-gleam",
"tree-sitter-glsl",
"tree-sitter-go",
"tree-sitter-gomod",
"tree-sitter-gowork",
"tree-sitter-haskell",
"tree-sitter-hcl",
"tree-sitter-heex",
"tree-sitter-html",
"tree-sitter-json 0.20.0",
"tree-sitter-lua",
"tree-sitter-markdown",
"tree-sitter-nix",
"tree-sitter-nu",
"tree-sitter-ocaml",
"tree-sitter-php",
"tree-sitter-prisma-io",
"tree-sitter-proto",
"tree-sitter-purescript",
"tree-sitter-python",
"tree-sitter-racket",
"tree-sitter-ruby",
"tree-sitter-rust",
"tree-sitter-scheme",
"tree-sitter-svelte",
"tree-sitter-toml",
"tree-sitter-typescript",
"tree-sitter-uiua",
"tree-sitter-vue",
"tree-sitter-yaml",
"tree-sitter-zig",
"unindent",
"util",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@ -7339,7 +7421,6 @@ dependencies = [
name = "recent_projects"
version = "0.1.0"
dependencies = [
"editor",
"futures 0.3.28",
"fuzzy",
"gpui",
@ -7801,9 +7882,9 @@ dependencies = [
[[package]]
name = "rust-embed"
version = "8.0.0"
version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1e7d90385b59f0a6bf3d3b757f3ca4ece2048265d70db20a2016043d4509a40"
checksum = "a82c0bbc10308ed323529fd3c1dce8badda635aa319a5ff0e6466f33b8101e3f"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
@ -7812,9 +7893,9 @@ dependencies = [
[[package]]
name = "rust-embed-impl"
version = "8.0.0"
version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c3d8c6fd84090ae348e63a84336b112b5c3918b3bf0493a581f7bd8ee623c29"
checksum = "6227c01b1783cdfee1bcf844eb44594cd16ec71c35305bf1c9fb5aade2735e16"
dependencies = [
"proc-macro2",
"quote",
@ -7825,9 +7906,9 @@ dependencies = [
[[package]]
name = "rust-embed-utils"
version = "8.0.0"
version = "8.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "873feff8cb7bf86fdf0a71bb21c95159f4e4a37dd7a4bd1855a940909b583ada"
checksum = "8cb0a25bfbb2d4b4402179c2cf030387d9990857ce08a32592c6238db9fa8665"
dependencies = [
"globset",
"sha2 0.10.7",
@ -8546,6 +8627,15 @@ dependencies = [
"dirs 4.0.0",
]
[[package]]
name = "shellexpand"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b"
dependencies = [
"dirs 4.0.0",
]
[[package]]
name = "shlex"
version = "1.3.0"
@ -9381,7 +9471,6 @@ version = "0.1.0"
dependencies = [
"anyhow",
"db",
"editor",
"fs",
"futures 0.3.28",
"fuzzy",
@ -9456,7 +9545,7 @@ dependencies = [
"serde_derive",
"serde_json",
"settings",
"shellexpand",
"shellexpand 2.1.2",
"smallvec",
"smol",
"task",
@ -9491,7 +9580,7 @@ dependencies = [
"serde_derive",
"serde_json",
"settings",
"shellexpand",
"shellexpand 2.1.2",
"smallvec",
"smol",
"task",
@ -12006,6 +12095,7 @@ dependencies = [
"language",
"language_selector",
"language_tools",
"languages",
"lazy_static",
"libc",
"log",
@ -12039,7 +12129,7 @@ dependencies = [
"serde_derive",
"serde_json",
"settings",
"shellexpand",
"shellexpand 2.1.2",
"simplelog",
"smallvec",
"smol",
@ -12054,52 +12144,7 @@ dependencies = [
"thiserror",
"tiny_http",
"toml 0.8.10",
"tree-sitter",
"tree-sitter-astro",
"tree-sitter-bash",
"tree-sitter-c",
"tree-sitter-c-sharp",
"tree-sitter-clojure",
"tree-sitter-cpp",
"tree-sitter-css",
"tree-sitter-dart",
"tree-sitter-dockerfile",
"tree-sitter-elixir",
"tree-sitter-elm",
"tree-sitter-embedded-template",
"tree-sitter-erlang",
"tree-sitter-gitcommit",
"tree-sitter-gleam",
"tree-sitter-glsl",
"tree-sitter-go",
"tree-sitter-gomod",
"tree-sitter-gowork",
"tree-sitter-haskell",
"tree-sitter-hcl",
"tree-sitter-heex",
"tree-sitter-html",
"tree-sitter-json 0.20.0",
"tree-sitter-lua",
"tree-sitter-markdown",
"tree-sitter-nix",
"tree-sitter-nu",
"tree-sitter-ocaml",
"tree-sitter-php",
"tree-sitter-prisma-io",
"tree-sitter-proto",
"tree-sitter-purescript",
"tree-sitter-python",
"tree-sitter-racket",
"tree-sitter-ruby",
"tree-sitter-rust",
"tree-sitter-scheme",
"tree-sitter-svelte",
"tree-sitter-toml",
"tree-sitter-typescript",
"tree-sitter-uiua",
"tree-sitter-vue",
"tree-sitter-yaml",
"tree-sitter-zig",
"unindent",
"url",
"urlencoding",

View File

@ -38,6 +38,7 @@ members = [
"crates/language",
"crates/language_selector",
"crates/language_tools",
"crates/languages",
"crates/live_kit_client",
"crates/live_kit_server",
"crates/lsp",

View File

@ -15,7 +15,6 @@ client.workspace = true
collections.workspace = true
# HACK: We're only depending on `copilot` here for `CommandPaletteFilter`. See the attached comment on that type.
copilot.workspace = true
editor.workspace = true
fuzzy.workspace = true
gpui.workspace = true
picker.workspace = true

View File

@ -1584,7 +1584,6 @@ mod tests {
}
fn editor_blocks(editor: &View<Editor>, cx: &mut WindowContext) -> Vec<(u32, SharedString)> {
let editor_view = editor.clone();
editor.update(cx, |editor, cx| {
let snapshot = editor.snapshot(cx);
snapshot
@ -1593,7 +1592,6 @@ mod tests {
.filter_map(|(ix, (row, block))| {
let name: SharedString = match block {
TransformBlock::Custom(block) => cx.with_element_context({
let editor_view = editor_view.clone();
|cx| -> Option<SharedString> {
block
.render(&mut BlockContext {
@ -1604,7 +1602,6 @@ mod tests {
em_width: px(0.),
max_width: px(0.),
block_id: ix,
view: editor_view,
editor_style: &editor::EditorStyle::default(),
})
.inner_id()?

View File

@ -24,10 +24,7 @@ mod tab_map;
mod wrap_map;
use crate::EditorStyle;
use crate::{
hover_links::InlayHighlight, movement::TextLayoutDetails, Anchor, AnchorRangeExt, InlayId,
MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint,
};
use crate::{hover_links::InlayHighlight, movement::TextLayoutDetails, InlayId};
pub use block_map::{BlockMap, BlockPoint};
use collections::{BTreeMap, HashMap, HashSet};
use fold_map::FoldMap;
@ -37,6 +34,7 @@ use language::{
language_settings::language_settings, OffsetUtf16, Point, Subscription as BufferSubscription,
};
use lsp::DiagnosticSeverity;
use multi_buffer::{Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, ToOffset, ToPoint};
use std::{any::TypeId, borrow::Cow, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc};
use sum_tree::{Bias, TreeMap};
use tab_map::TabMap;

View File

@ -2,10 +2,11 @@ use super::{
wrap_map::{self, WrapEdit, WrapPoint, WrapSnapshot},
Highlights,
};
use crate::{Anchor, Editor, EditorStyle, ExcerptId, ExcerptRange, GutterDimensions, ToPoint as _};
use crate::{EditorStyle, GutterDimensions};
use collections::{Bound, HashMap, HashSet};
use gpui::{AnyElement, ElementContext, Pixels, View};
use gpui::{AnyElement, ElementContext, Pixels};
use language::{BufferSnapshot, Chunk, Patch, Point};
use multi_buffer::{Anchor, ExcerptId, ExcerptRange, ToPoint as _};
use parking_lot::Mutex;
use std::{
cell::RefCell,
@ -85,7 +86,6 @@ pub enum BlockStyle {
pub struct BlockContext<'a, 'b> {
pub context: &'b mut ElementContext<'a>,
pub view: View<Editor>,
pub anchor_x: Pixels,
pub max_width: Pixels,
pub gutter_dimensions: &'b GutterDimensions,

View File

@ -2,9 +2,9 @@ use super::{
inlay_map::{InlayBufferRows, InlayChunks, InlayEdit, InlayOffset, InlayPoint, InlaySnapshot},
Highlights,
};
use crate::{Anchor, AnchorRangeExt, MultiBufferSnapshot, ToOffset};
use gpui::{ElementId, HighlightStyle, Hsla};
use language::{Chunk, Edit, Point, TextSummary};
use multi_buffer::{Anchor, AnchorRangeExt, MultiBufferSnapshot, ToOffset};
use std::{
any::TypeId,
cmp::{self, Ordering},

View File

@ -1,8 +1,8 @@
use crate::{Anchor, InlayId, MultiBufferSnapshot, ToOffset};
use crate::InlayId;
use collections::{BTreeMap, BTreeSet};
use gpui::HighlightStyle;
use language::{Chunk, Edit, Point, TextSummary};
use multi_buffer::{MultiBufferChunks, MultiBufferRows};
use multi_buffer::{Anchor, MultiBufferChunks, MultiBufferRows, MultiBufferSnapshot, ToOffset};
use std::{
any::TypeId,
cmp,

View File

@ -2,8 +2,8 @@ use super::{
fold_map::{self, FoldChunks, FoldEdit, FoldPoint, FoldSnapshot},
Highlights,
};
use crate::MultiBufferSnapshot;
use language::{Chunk, Point};
use multi_buffer::MultiBufferSnapshot;
use std::{cmp, mem, num::NonZeroU32, ops::Range};
use sum_tree::Bias;

View File

@ -3,10 +3,10 @@ use super::{
tab_map::{self, TabEdit, TabPoint, TabSnapshot},
Highlights,
};
use crate::MultiBufferSnapshot;
use gpui::{AppContext, Context, Font, LineWrapper, Model, ModelContext, Pixels, Task};
use language::{Chunk, Point};
use lazy_static::lazy_static;
use multi_buffer::MultiBufferSnapshot;
use smol::future::yield_now;
use std::{cmp, collections::VecDeque, mem, ops::Range, time::Duration};
use sum_tree::{Bias, Cursor, SumTree};

View File

@ -122,7 +122,7 @@ use ui::{
};
use util::{maybe, post_inc, RangeExt, ResultExt, TryFutureExt};
use workspace::Toast;
use workspace::{searchable::SearchEvent, ItemNavHistory, Pane, SplitDirection, ViewId, Workspace};
use workspace::{searchable::SearchEvent, ItemNavHistory, SplitDirection, ViewId, Workspace};
use crate::hover_links::find_url;
@ -356,7 +356,6 @@ type InlayBackgroundHighlight = (fn(&ThemeColors) -> Hsla, Vec<InlayHighlight>);
///
/// See the [module level documentation](self) for more information.
pub struct Editor {
handle: WeakView<Self>,
focus_handle: FocusHandle,
/// The text buffer being edited
buffer: Model<MultiBuffer>,
@ -1488,7 +1487,6 @@ impl Editor {
cx.on_blur(&focus_handle, Self::handle_blur).detach();
let mut this = Self {
handle: cx.view().downgrade(),
focus_handle,
buffer: buffer.clone(),
display_map: display_map.clone(),
@ -1686,10 +1684,6 @@ impl Editor {
self.workspace.as_ref()?.0.upgrade()
}
pub fn pane(&self, cx: &AppContext) -> Option<View<Pane>> {
self.workspace()?.read(cx).pane_for(&self.handle.upgrade()?)
}
pub fn title<'a>(&self, cx: &'a AppContext) -> Cow<'a, str> {
self.buffer().read(cx).title(cx)
}

View File

@ -2225,7 +2225,6 @@ impl EditorElement {
.width;
let scroll_width = longest_line_width.max(max_visible_line_width) + overscroll.width;
let editor_view = cx.view().clone();
let (scroll_width, blocks) = cx.with_element_context(|cx| {
cx.with_element_id(Some("editor_blocks"), |cx| {
self.layout_blocks(
@ -2241,7 +2240,6 @@ impl EditorElement {
&style,
&line_layouts,
editor,
editor_view,
cx,
)
})
@ -2436,7 +2434,6 @@ impl EditorElement {
style: &EditorStyle,
line_layouts: &[LineWithInvisibles],
editor: &mut Editor,
editor_view: View<Editor>,
cx: &mut ElementContext,
) -> (Pixels, Vec<BlockLayout>) {
let mut block_id = 0;
@ -2477,7 +2474,6 @@ impl EditorElement {
em_width,
block_id,
max_width: scroll_width.max(text_width),
view: editor_view.clone(),
editor_style: &self.style,
})
}

View File

@ -24,7 +24,6 @@ futures.workspace = true
fuzzy.workspace = true
gpui.workspace = true
log.workspace = true
picker.workspace = true
project.workspace = true
serde.workspace = true
serde_json.workspace = true

View File

@ -0,0 +1,89 @@
[package]
name = "languages"
version = "0.1.0"
edition = "2021"
publish = false
license = "GPL-3.0-or-later"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow.workspace = true
gpui.workspace = true
language.workspace = true
node_runtime.workspace = true
rust-embed = "8.2.0"
settings.workspace = true
tree-sitter-astro.workspace = true
tree-sitter-bash.workspace = true
tree-sitter-c-sharp.workspace = true
tree-sitter-c.workspace = true
tree-sitter-clojure.workspace = true
tree-sitter-cpp.workspace = true
tree-sitter-css.workspace = true
tree-sitter-dockerfile.workspace = true
tree-sitter-dart.workspace = true
tree-sitter-elixir.workspace = true
tree-sitter-elm.workspace = true
tree-sitter-embedded-template.workspace = true
tree-sitter-erlang.workspace = true
tree-sitter-gitcommit.workspace = true
tree-sitter-gleam.workspace = true
tree-sitter-glsl.workspace = true
tree-sitter-go.workspace = true
tree-sitter-gomod.workspace = true
tree-sitter-gowork.workspace = true
tree-sitter-haskell.workspace = true
tree-sitter-hcl.workspace = true
tree-sitter-heex.workspace = true
tree-sitter-html.workspace = true
tree-sitter-json.workspace = true
tree-sitter-lua.workspace = true
tree-sitter-markdown.workspace = true
tree-sitter-nix.workspace = true
tree-sitter-nu.workspace = true
tree-sitter-ocaml.workspace = true
tree-sitter-php.workspace = true
tree-sitter-prisma-io.workspace = true
tree-sitter-proto.workspace = true
tree-sitter-purescript.workspace = true
tree-sitter-python.workspace = true
tree-sitter-racket.workspace = true
tree-sitter-ruby.workspace = true
tree-sitter-rust.workspace = true
tree-sitter-scheme.workspace = true
tree-sitter-svelte.workspace = true
tree-sitter-toml.workspace = true
tree-sitter-typescript.workspace = true
tree-sitter-uiua.workspace = true
tree-sitter-vue.workspace = true
tree-sitter-yaml.workspace = true
tree-sitter-zig.workspace = true
tree-sitter.workspace = true
util.workspace = true
lsp.workspace = true
async-trait = "0.1.77"
shellexpand = "3.1.0"
serde_json.workspace = true
serde_derive.workspace = true
futures.workspace = true
smol.workspace = true
toml.workspace = true
lazy_static.workspace = true
schemars.workspace = true
log.workspace = true
task.workspace = true
parking_lot.workspace = true
async-compression = "0.4.6"
collections.workspace = true
async-tar = "0.4.2"
regex.workspace = true
feature_flags.workspace = true
project.workspace = true
serde.workspace = true
rope.workspace = true
[dev-dependencies]
text.workspace = true
theme.workspace = true
unindent.workspace = true

View File

@ -0,0 +1 @@
../../LICENSE-GPL

View File

@ -296,7 +296,7 @@ mod tests {
});
});
});
let language = crate::languages::language("c", tree_sitter_c::language(), None).await;
let language = crate::language("c", tree_sitter_c::language(), None).await;
cx.new_model(|cx| {
let mut buffer = Buffer::new(0, BufferId::new(cx.entity_id().as_u64()).unwrap(), "")

Some files were not shown because too many files have changed in this diff Show More