Compare commits

...
Sign in to create a new pull request.

12 commits

Author SHA1 Message Date
Joseph T. Lyons
c60aa0f355 Merge pull request #2127 from zed-industries/fix-discourse-release
Fix discourse release
2023-02-02 14:42:13 -05:00
Joseph Lyons
43fd1078f3 v0.71.x stable 2023-02-01 13:44:50 -05:00
Joseph Lyons
38ee5712b5 zed 0.71.3 2023-01-31 12:13:47 -05:00
Max Brunsfeld
c299dbe8d1 Merge pull request #2099 from zed-industries/empty-go-to-def-multibuffer
Avoid opening a definitions tab if there are no definitions found
2023-01-31 11:46:09 -05:00
Joseph T. Lyons
8690d59da1 Merge pull request #2112 from zed-industries/fix-version-for-feedback-related-commands
Fix version for feedback-related commands
2023-01-31 11:26:43 -05:00
Antonio Scandurra
88cc044f1a zed 0.71.2 2023-01-27 11:04:33 +01:00
Antonio Scandurra
85456dfcaa Merge pull request #2103 from zed-industries/connection-staleness
Fix connection staleness issues
2023-01-27 11:04:14 +01:00
Max Brunsfeld
03a8d0968c zed 0.71.1 2023-01-26 10:41:30 -08:00
Max Brunsfeld
aaaaef1246 Merge pull request #2099 from zed-industries/empty-go-to-def-multibuffer
Avoid opening a definitions tab if there are no definitions found
2023-01-26 10:41:05 -08:00
Max Brunsfeld
2cb83f1bbb Merge pull request #2096 from zed-industries/lazy-load-languages
Load languages lazily in the background
2023-01-26 10:40:45 -08:00
Joseph T. Lyons
28d1fd77fd Merge pull request #2095 from zed-industries/fix-crash-when-opening-feedback-while-in-call
Fix crash when opening feedback while in call
2023-01-26 10:39:53 -08:00
Joseph Lyons
ce9c23b669 v0.71.x preview 2023-01-25 15:20:30 -05:00
27 changed files with 458 additions and 318 deletions

View file

@ -13,23 +13,28 @@ jobs:
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
content: |
📣 Zed ${{ github.event.release.tag_name }} was just released!
Restart your Zed or head to https://zed.dev/releases/latest to grab it.
```md
# Changelog
${{ github.event.release.body }}
```
discourse_release:
if: ${{ ! github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v2
if: ${{ ! github.event.release.prerelease }}
with:
node-version: '16'
- run: script/discourse_release ${{ secrets.DISCOURSE_RELEASES_API_KEY }} ${{ github.event.release.tag_name }} ${{ github.event.release.body }}
node-version: "19"
- run: >
node "./script/discourse_release"
${{ secrets.DISCOURSE_RELEASES_API_KEY }}
${{ github.event.release.tag_name }}
${{ github.event.release.body }}
mixpanel_release:
runs-on: ubuntu-latest
steps:
@ -40,7 +45,7 @@ jobs:
architecture: "x64"
cache: "pip"
- run: pip install -r script/mixpanel_release/requirements.txt
- run: >
- run: >
python script/mixpanel_release/main.py
${{ github.event.release.tag_name }}
${{ secrets.MIXPANEL_PROJECT_ID }}

2
Cargo.lock generated
View file

@ -8216,7 +8216,7 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
[[package]]
name = "zed"
version = "0.71.0"
version = "0.71.3"
dependencies = [
"activity_indicator",
"anyhow",

View file

@ -84,5 +84,3 @@ split-debuginfo = "unpacked"
[profile.release]
debug = true

View file

@ -5,6 +5,7 @@ WORKDIR app
COPY . .
# Compile collab server
ARG CARGO_PROFILE_RELEASE_PANIC=abort
RUN --mount=type=cache,target=./script/node_modules \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=./target \

View file

@ -2,15 +2,15 @@ mod update_notification;
use anyhow::{anyhow, Context, Result};
use client::{http::HttpClient, ZED_SECRET_CLIENT_TOKEN};
use client::{ZED_APP_PATH, ZED_APP_VERSION};
use db::kvp::KEY_VALUE_STORE;
use gpui::{
actions, platform::AppVersion, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
MutableAppContext, Task, WeakViewHandle,
};
use lazy_static::lazy_static;
use serde::Deserialize;
use smol::{fs::File, io::AsyncReadExt, process::Command};
use std::{env, ffi::OsString, path::PathBuf, sync::Arc, time::Duration};
use std::{ffi::OsString, sync::Arc, time::Duration};
use update_notification::UpdateNotification;
use util::channel::ReleaseChannel;
use workspace::Workspace;
@ -18,13 +18,6 @@ use workspace::Workspace;
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &str = "auto-updater-should-show-updated-notification";
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
lazy_static! {
pub static ref ZED_APP_VERSION: Option<AppVersion> = env::var("ZED_APP_VERSION")
.ok()
.and_then(|v| v.parse().ok());
pub static ref ZED_APP_PATH: Option<PathBuf> = env::var("ZED_APP_PATH").ok().map(PathBuf::from);
}
actions!(auto_update, [Check, DismissErrorMessage, ViewReleaseNotes]);
#[derive(Clone, Copy, PartialEq, Eq)]

View file

@ -15,7 +15,7 @@ use futures::{future::LocalBoxFuture, AsyncReadExt, FutureExt, SinkExt, StreamEx
use gpui::{
actions,
serde_json::{self, Value},
AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext,
AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext, AppVersion,
AsyncAppContext, Entity, ModelHandle, MutableAppContext, Task, View, ViewContext, ViewHandle,
};
use http::HttpClient;
@ -55,6 +55,11 @@ lazy_static! {
pub static ref ADMIN_API_TOKEN: Option<String> = std::env::var("ZED_ADMIN_API_TOKEN")
.ok()
.and_then(|s| if s.is_empty() { None } else { Some(s) });
pub static ref ZED_APP_VERSION: Option<AppVersion> = std::env::var("ZED_APP_VERSION")
.ok()
.and_then(|v| v.parse().ok());
pub static ref ZED_APP_PATH: Option<PathBuf> =
std::env::var("ZED_APP_PATH").ok().map(PathBuf::from);
}
pub const ZED_SECRET_CLIENT_TOKEN: &str = "618033988749894";

View file

@ -1586,12 +1586,8 @@ impl Database {
.filter(
Condition::all()
.add(
room_participant::Column::CallingConnectionId
.eq(connection.id as i32),
)
.add(
room_participant::Column::CallingConnectionServerId
.eq(connection.owner_id as i32),
room_participant::Column::CallingUserId
.eq(leaving_participant.user_id),
)
.add(room_participant::Column::AnsweringConnectionId.is_null()),
)

View file

@ -166,12 +166,10 @@ async fn test_random_collaboration(
let contacts = server.app_state.db.get_contacts(*user_id).await.unwrap();
let pool = server.connection_pool.lock();
for contact in contacts {
if let db::Contact::Accepted { user_id, .. } = contact {
if pool.is_user_online(user_id) {
assert_ne!(
user_id, removed_user_id,
"removed client is still a contact of another peer"
);
if let db::Contact::Accepted { user_id, busy, .. } = contact {
if user_id == removed_user_id {
assert!(!pool.is_user_online(user_id));
assert!(!busy);
}
}
}

View file

@ -5042,7 +5042,7 @@ impl Editor {
pane.update(cx, |pane, _| pane.enable_history());
});
} else {
} else if !definitions.is_empty() {
let replica_id = editor_handle.read(cx).replica_id(cx);
let title = definitions
.iter()

View file

@ -2,10 +2,10 @@ use std::sync::Arc;
pub mod feedback_editor;
mod system_specs;
use gpui::{actions, impl_actions, ClipboardItem, ViewContext};
use gpui::{actions, impl_actions, ClipboardItem, MutableAppContext, PromptLevel, ViewContext};
use serde::Deserialize;
use system_specs::SystemSpecs;
use workspace::Workspace;
use workspace::{AppState, Workspace};
#[derive(Deserialize, Clone, PartialEq)]
pub struct OpenBrowser {
@ -16,23 +16,32 @@ impl_actions!(zed, [OpenBrowser]);
actions!(
zed,
[CopySystemSpecsIntoClipboard, FileBugReport, RequestFeature,]
[CopySystemSpecsIntoClipboard, FileBugReport, RequestFeature]
);
pub fn init(cx: &mut gpui::MutableAppContext) {
feedback_editor::init(cx);
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
let system_specs = SystemSpecs::new(&cx);
let system_specs_text = system_specs.to_string();
feedback_editor::init(system_specs, app_state, cx);
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
let url = format!(
"https://github.com/zed-industries/feedback/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
urlencoding::encode(&system_specs_text)
);
cx.add_action(
|_: &mut Workspace, _: &CopySystemSpecsIntoClipboard, cx: &mut ViewContext<Workspace>| {
let system_specs = SystemSpecs::new(cx).to_string();
let item = ClipboardItem::new(system_specs.clone());
move |_: &mut Workspace,
_: &CopySystemSpecsIntoClipboard,
cx: &mut ViewContext<Workspace>| {
cx.prompt(
gpui::PromptLevel::Info,
&format!("Copied into clipboard:\n\n{system_specs}"),
PromptLevel::Info,
&format!("Copied into clipboard:\n\n{system_specs_text}"),
&["OK"],
);
let item = ClipboardItem::new(system_specs_text.clone());
cx.write_to_clipboard(item);
},
);
@ -47,14 +56,9 @@ pub fn init(cx: &mut gpui::MutableAppContext) {
);
cx.add_action(
|_: &mut Workspace, _: &FileBugReport, cx: &mut ViewContext<Workspace>| {
let system_specs_text = SystemSpecs::new(cx).to_string();
let url = format!(
"https://github.com/zed-industries/feedback/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
urlencoding::encode(&system_specs_text)
);
move |_: &mut Workspace, _: &FileBugReport, cx: &mut ViewContext<Workspace>| {
cx.dispatch_action(OpenBrowser {
url: url.into(),
url: url.clone().into(),
});
},
);

View file

@ -5,7 +5,7 @@ use std::{
};
use anyhow::bail;
use client::{Client, ZED_SECRET_CLIENT_TOKEN};
use client::{Client, ZED_SECRET_CLIENT_TOKEN, ZED_SERVER_URL};
use editor::{Anchor, Editor};
use futures::AsyncReadExt;
use gpui::{
@ -19,23 +19,17 @@ use isahc::Request;
use language::Buffer;
use postage::prelude::Stream;
use lazy_static::lazy_static;
use project::Project;
use serde::Serialize;
use settings::Settings;
use workspace::{
item::{Item, ItemHandle},
searchable::{SearchableItem, SearchableItemHandle},
StatusItemView, Workspace,
AppState, StatusItemView, Workspace,
};
use crate::system_specs::SystemSpecs;
lazy_static! {
pub static ref ZED_SERVER_URL: String =
std::env::var("ZED_SERVER_URL").unwrap_or_else(|_| "https://zed.dev".to_string());
}
const FEEDBACK_CHAR_LIMIT: RangeInclusive<usize> = 10..=5000;
const FEEDBACK_PLACEHOLDER_TEXT: &str = "Thanks for spending time with Zed. Enter your feedback here as Markdown. Save the tab to submit your feedback.";
const FEEDBACK_SUBMISSION_ERROR_TEXT: &str =
@ -43,8 +37,12 @@ const FEEDBACK_SUBMISSION_ERROR_TEXT: &str =
actions!(feedback, [SubmitFeedback, GiveFeedback, DeployFeedback]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_action(FeedbackEditor::deploy);
pub fn init(system_specs: SystemSpecs, app_state: Arc<AppState>, cx: &mut MutableAppContext) {
cx.add_action({
move |workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>| {
FeedbackEditor::deploy(system_specs.clone(), workspace, app_state.clone(), cx);
}
});
}
pub struct FeedbackButton;
@ -93,12 +91,14 @@ struct FeedbackRequestBody<'a> {
#[derive(Clone)]
struct FeedbackEditor {
system_specs: SystemSpecs,
editor: ViewHandle<Editor>,
project: ModelHandle<Project>,
}
impl FeedbackEditor {
fn new_with_buffer(
fn new(
system_specs: SystemSpecs,
project: ModelHandle<Project>,
buffer: ModelHandle<Buffer>,
cx: &mut ViewContext<Self>,
@ -113,19 +113,11 @@ impl FeedbackEditor {
cx.subscribe(&editor, |_, _, e, cx| cx.emit(e.clone()))
.detach();
Self { editor, project }
}
fn new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
let markdown_language = project.read(cx).languages().language_for_name("Markdown");
let buffer = project
.update(cx, |project, cx| {
project.create_buffer("", markdown_language, cx)
})
.expect("creating buffers on a local workspace always succeeds");
Self::new_with_buffer(project, buffer, cx)
Self {
system_specs: system_specs.clone(),
editor,
project,
}
}
fn handle_save(
@ -163,7 +155,7 @@ impl FeedbackEditor {
let this = cx.handle();
let client = cx.global::<Arc<Client>>().clone();
let feedback_text = self.editor.read(cx).text(cx);
let specs = SystemSpecs::new(cx);
let specs = self.system_specs.clone();
cx.spawn(|_, mut cx| async move {
let answer = answer.recv().await;
@ -236,10 +228,26 @@ impl FeedbackEditor {
}
impl FeedbackEditor {
pub fn deploy(workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>) {
let feedback_editor =
cx.add_view(|cx| FeedbackEditor::new(workspace.project().clone(), cx));
workspace.add_item(Box::new(feedback_editor), cx);
pub fn deploy(
system_specs: SystemSpecs,
workspace: &mut Workspace,
app_state: Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) {
workspace
.with_local_workspace(&app_state, cx, |workspace, cx| {
let project = workspace.project().clone();
let markdown_language = project.read(cx).languages().language_for_name("Markdown");
let buffer = project
.update(cx, |project, cx| {
project.create_buffer("", markdown_language, cx)
})
.expect("creating buffers on a local workspace always succeeds");
let feedback_editor =
cx.add_view(|cx| FeedbackEditor::new(system_specs, project, buffer, cx));
workspace.add_item(Box::new(feedback_editor), cx);
})
.detach();
}
}
@ -334,7 +342,8 @@ impl Item for FeedbackEditor {
.as_singleton()
.expect("Feedback buffer is only ever singleton");
Some(Self::new_with_buffer(
Some(Self::new(
self.system_specs.clone(),
self.project.clone(),
buffer.clone(),
cx,

View file

@ -1,14 +1,15 @@
use std::{env, fmt::Display};
use gpui::AppContext;
use client::ZED_APP_VERSION;
use gpui::{AppContext, AppVersion};
use human_bytes::human_bytes;
use serde::Serialize;
use std::{env, fmt::Display};
use sysinfo::{System, SystemExt};
use util::channel::ReleaseChannel;
#[derive(Debug, Serialize)]
#[derive(Clone, Debug, Serialize)]
pub struct SystemSpecs {
app_version: &'static str,
#[serde(serialize_with = "serialize_app_version")]
app_version: Option<AppVersion>,
release_channel: &'static str,
os_name: &'static str,
os_version: Option<String>,
@ -19,18 +20,24 @@ pub struct SystemSpecs {
impl SystemSpecs {
pub fn new(cx: &AppContext) -> Self {
let platform = cx.platform();
let app_version = ZED_APP_VERSION.or_else(|| platform.app_version().ok());
let release_channel = cx.global::<ReleaseChannel>().dev_name();
let os_name = platform.os_name();
let system = System::new_all();
let memory = system.total_memory();
let architecture = env::consts::ARCH;
let os_version = platform
.os_version()
.ok()
.map(|os_version| os_version.to_string());
SystemSpecs {
app_version: env!("CARGO_PKG_VERSION"),
release_channel: cx.global::<ReleaseChannel>().dev_name(),
os_name: platform.os_name(),
os_version: platform
.os_version()
.ok()
.map(|os_version| os_version.to_string()),
memory: system.total_memory(),
architecture: env::consts::ARCH,
app_version,
release_channel,
os_name,
os_version,
memory,
architecture,
}
}
}
@ -41,14 +48,28 @@ impl Display for SystemSpecs {
Some(os_version) => format!("OS: {} {}", self.os_name, os_version),
None => format!("OS: {}", self.os_name),
};
let app_version_information = self
.app_version
.as_ref()
.map(|app_version| format!("Zed: v{} ({})", app_version, self.release_channel));
let system_specs = [
format!("Zed: v{} ({})", self.app_version, self.release_channel),
os_information,
format!("Memory: {}", human_bytes(self.memory as f64)),
format!("Architecture: {}", self.architecture),
app_version_information,
Some(os_information),
Some(format!("Memory: {}", human_bytes(self.memory as f64))),
Some(format!("Architecture: {}", self.architecture)),
]
.into_iter()
.flatten()
.collect::<Vec<String>>()
.join("\n");
write!(f, "{system_specs}")
}
}
fn serialize_app_version<S>(version: &Option<AppVersion>, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
version.map(|v| v.to_string()).serialize(serializer)
}

View file

@ -51,7 +51,7 @@ fn test_line_endings(cx: &mut gpui::MutableAppContext) {
#[gpui::test]
fn test_select_language() {
let registry = LanguageRegistry::test();
let registry = Arc::new(LanguageRegistry::test());
registry.add(Arc::new(Language::new(
LanguageConfig {
name: "Rust".into(),
@ -71,27 +71,33 @@ fn test_select_language() {
// matching file extension
assert_eq!(
registry.select_language("zed/lib.rs").map(|l| l.name()),
registry.language_for_path("zed/lib.rs").map(|l| l.name()),
Some("Rust".into())
);
assert_eq!(
registry.select_language("zed/lib.mk").map(|l| l.name()),
registry.language_for_path("zed/lib.mk").map(|l| l.name()),
Some("Make".into())
);
// matching filename
assert_eq!(
registry.select_language("zed/Makefile").map(|l| l.name()),
registry.language_for_path("zed/Makefile").map(|l| l.name()),
Some("Make".into())
);
// 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()),
registry.language_for_path("zed/cars").map(|l| l.name()),
None
);
assert_eq!(
registry.language_for_path("zed/a.cars").map(|l| l.name()),
None
);
assert_eq!(
registry.language_for_path("zed/sumk").map(|l| l.name()),
None
);
assert_eq!(registry.select_language("zed/sumk").map(|l| l.name()), None);
}
#[gpui::test]

View file

@ -16,7 +16,7 @@ use futures::{
future::{BoxFuture, Shared},
FutureExt, TryFutureExt,
};
use gpui::{MutableAppContext, Task};
use gpui::{executor::Background, MutableAppContext, Task};
use highlight_map::HighlightMap;
use lazy_static::lazy_static;
use parking_lot::{Mutex, RwLock};
@ -26,6 +26,7 @@ use serde::{de, Deserialize, Deserializer};
use serde_json::Value;
use std::{
any::Any,
borrow::Cow,
cell::RefCell,
fmt::Debug,
hash::Hash,
@ -89,8 +90,7 @@ pub struct CachedLspAdapter {
}
impl CachedLspAdapter {
pub async fn new<T: LspAdapter>(adapter: T) -> Arc<Self> {
let adapter = Box::new(adapter);
pub async fn new(adapter: Box<dyn LspAdapter>) -> Arc<Self> {
let name = adapter.name().await;
let server_args = adapter.server_args().await;
let initialization_options = adapter.initialization_options().await;
@ -248,6 +248,16 @@ pub struct LanguageConfig {
pub overrides: HashMap<String, LanguageConfigOverride>,
}
#[derive(Debug, Default)]
pub struct LanguageQueries {
pub highlights: Option<Cow<'static, str>>,
pub brackets: Option<Cow<'static, str>>,
pub indents: Option<Cow<'static, str>>,
pub outline: Option<Cow<'static, str>>,
pub injections: Option<Cow<'static, str>>,
pub overrides: Option<Cow<'static, str>>,
}
#[derive(Clone)]
pub struct LanguageScope {
language: Arc<Language>,
@ -407,8 +417,17 @@ pub enum LanguageServerBinaryStatus {
Failed { error: String },
}
struct AvailableLanguage {
path: &'static str,
config: LanguageConfig,
grammar: tree_sitter::Language,
lsp_adapter: Option<Box<dyn LspAdapter>>,
get_queries: fn(&str) -> LanguageQueries,
}
pub struct LanguageRegistry {
languages: RwLock<Vec<Arc<Language>>>,
available_languages: RwLock<Vec<AvailableLanguage>>,
language_server_download_dir: Option<Arc<Path>>,
lsp_binary_statuses_tx: async_broadcast::Sender<(Arc<Language>, LanguageServerBinaryStatus)>,
lsp_binary_statuses_rx: async_broadcast::Receiver<(Arc<Language>, LanguageServerBinaryStatus)>,
@ -422,6 +441,7 @@ pub struct LanguageRegistry {
>,
subscription: RwLock<(watch::Sender<()>, watch::Receiver<()>)>,
theme: RwLock<Option<Arc<Theme>>>,
executor: Option<Arc<Background>>,
version: AtomicUsize,
}
@ -431,6 +451,7 @@ impl LanguageRegistry {
Self {
language_server_download_dir: None,
languages: Default::default(),
available_languages: Default::default(),
lsp_binary_statuses_tx,
lsp_binary_statuses_rx,
login_shell_env_loaded: login_shell_env_loaded.shared(),
@ -438,6 +459,7 @@ impl LanguageRegistry {
subscription: RwLock::new(watch::channel()),
theme: Default::default(),
version: Default::default(),
executor: None,
}
}
@ -446,6 +468,44 @@ impl LanguageRegistry {
Self::new(Task::ready(()))
}
pub fn set_executor(&mut self, executor: Arc<Background>) {
self.executor = Some(executor);
}
pub fn register(
&self,
path: &'static str,
config: LanguageConfig,
grammar: tree_sitter::Language,
lsp_adapter: Option<Box<dyn LspAdapter>>,
get_queries: fn(&str) -> LanguageQueries,
) {
self.available_languages.write().push(AvailableLanguage {
path,
config,
grammar,
lsp_adapter,
get_queries,
});
}
pub fn language_names(&self) -> Vec<String> {
let mut result = self
.available_languages
.read()
.iter()
.map(|l| l.config.name.to_string())
.chain(
self.languages
.read()
.iter()
.map(|l| l.config.name.to_string()),
)
.collect::<Vec<_>>();
result.sort_unstable();
result
}
pub fn add(&self, language: Arc<Language>) {
if let Some(theme) = self.theme.read().clone() {
language.set_theme(&theme.editor.syntax);
@ -474,58 +534,79 @@ impl LanguageRegistry {
self.language_server_download_dir = Some(path.into());
}
pub fn language_for_name(&self, name: &str) -> Option<Arc<Language>> {
pub fn language_for_name(self: &Arc<Self>, name: &str) -> Option<Arc<Language>> {
let name = UniCase::new(name);
self.languages
.read()
.iter()
.find(|language| UniCase::new(language.name()) == name)
.cloned()
self.get_or_load_language(|config| UniCase::new(config.name.as_ref()) == name)
}
pub fn language_for_extension(&self, extension: &str) -> Option<Arc<Language>> {
let extension = UniCase::new(extension);
self.languages
.read()
.iter()
.find(|language| {
language
.config
pub fn language_for_name_or_extension(self: &Arc<Self>, string: &str) -> Option<Arc<Language>> {
let string = UniCase::new(string);
self.get_or_load_language(|config| {
UniCase::new(config.name.as_ref()) == string
|| config
.path_suffixes
.iter()
.any(|suffix| UniCase::new(suffix) == extension)
})
.cloned()
.any(|suffix| UniCase::new(suffix) == string)
})
}
pub fn to_vec(&self) -> Vec<Arc<Language>> {
self.languages.read().iter().cloned().collect()
}
pub fn language_names(&self) -> Vec<String> {
self.languages
.read()
.iter()
.map(|language| language.name().to_string())
.collect()
}
pub fn select_language(&self, path: impl AsRef<Path>) -> Option<Arc<Language>> {
pub fn language_for_path(self: &Arc<Self>, path: impl AsRef<Path>) -> Option<Arc<Language>> {
let path = path.as_ref();
let filename = path.file_name().and_then(|name| name.to_str());
let extension = path.extension().and_then(|name| name.to_str());
let path_suffixes = [extension, filename];
self.languages
self.get_or_load_language(|config| {
config
.path_suffixes
.iter()
.any(|suffix| path_suffixes.contains(&Some(suffix.as_str())))
})
}
fn get_or_load_language(
self: &Arc<Self>,
callback: impl Fn(&LanguageConfig) -> bool,
) -> Option<Arc<Language>> {
if let Some(language) = self
.languages
.read()
.iter()
.find(|language| {
language
.config
.path_suffixes
.iter()
.any(|suffix| path_suffixes.contains(&Some(suffix.as_str())))
})
.cloned()
.find(|language| callback(&language.config))
{
return Some(language.clone());
}
if let Some(executor) = self.executor.clone() {
let mut available_languages = self.available_languages.write();
if let Some(ix) = available_languages.iter().position(|l| callback(&l.config)) {
let language = available_languages.remove(ix);
drop(available_languages);
let name = language.config.name.clone();
let this = self.clone();
executor
.spawn(async move {
let queries = (language.get_queries)(&language.path);
let language = Language::new(language.config, Some(language.grammar))
.with_lsp_adapter(language.lsp_adapter)
.await;
match language.with_queries(queries) {
Ok(language) => this.add(Arc::new(language)),
Err(err) => {
log::error!("failed to load language {}: {}", name, err);
return;
}
};
})
.detach();
}
}
None
}
pub fn to_vec(&self) -> Vec<Arc<Language>> {
self.languages.read().iter().cloned().collect()
}
pub fn start_language_server(
@ -729,12 +810,70 @@ impl Language {
self.grammar.as_ref().map(|g| g.id)
}
pub fn with_queries(mut self, queries: LanguageQueries) -> Result<Self> {
if let Some(query) = queries.highlights {
self = self
.with_highlights_query(query.as_ref())
.expect("failed to evaluate highlights query");
}
if let Some(query) = queries.brackets {
self = self
.with_brackets_query(query.as_ref())
.expect("failed to load brackets query");
}
if let Some(query) = queries.indents {
self = self
.with_indents_query(query.as_ref())
.expect("failed to load indents query");
}
if let Some(query) = queries.outline {
self = self
.with_outline_query(query.as_ref())
.expect("failed to load outline query");
}
if let Some(query) = queries.injections {
self = self
.with_injection_query(query.as_ref())
.expect("failed to load injection query");
}
if let Some(query) = queries.overrides {
self = self
.with_override_query(query.as_ref())
.expect("failed to load override query");
}
Ok(self)
}
pub fn with_highlights_query(mut self, source: &str) -> Result<Self> {
let grammar = self.grammar_mut();
grammar.highlights_query = Some(Query::new(grammar.ts_language, source)?);
Ok(self)
}
pub fn with_outline_query(mut self, source: &str) -> Result<Self> {
let grammar = self.grammar_mut();
let query = Query::new(grammar.ts_language, source)?;
let mut item_capture_ix = None;
let mut name_capture_ix = None;
let mut context_capture_ix = None;
get_capture_indices(
&query,
&mut [
("item", &mut item_capture_ix),
("name", &mut name_capture_ix),
("context", &mut context_capture_ix),
],
);
if let Some((item_capture_ix, name_capture_ix)) = item_capture_ix.zip(name_capture_ix) {
grammar.outline_config = Some(OutlineConfig {
query,
item_capture_ix,
name_capture_ix,
context_capture_ix,
});
}
Ok(self)
}
pub fn with_brackets_query(mut self, source: &str) -> Result<Self> {
let grammar = self.grammar_mut();
let query = Query::new(grammar.ts_language, source)?;
@ -785,31 +924,6 @@ impl Language {
Ok(self)
}
pub fn with_outline_query(mut self, source: &str) -> Result<Self> {
let grammar = self.grammar_mut();
let query = Query::new(grammar.ts_language, source)?;
let mut item_capture_ix = None;
let mut name_capture_ix = None;
let mut context_capture_ix = None;
get_capture_indices(
&query,
&mut [
("item", &mut item_capture_ix),
("name", &mut name_capture_ix),
("context", &mut context_capture_ix),
],
);
if let Some((item_capture_ix, name_capture_ix)) = item_capture_ix.zip(name_capture_ix) {
grammar.outline_config = Some(OutlineConfig {
query,
item_capture_ix,
name_capture_ix,
context_capture_ix,
});
}
Ok(self)
}
pub fn with_injection_query(mut self, source: &str) -> Result<Self> {
let grammar = self.grammar_mut();
let query = Query::new(grammar.ts_language, source)?;
@ -882,8 +996,10 @@ impl Language {
Arc::get_mut(self.grammar.as_mut().unwrap()).unwrap()
}
pub fn with_lsp_adapter(mut self, lsp_adapter: Arc<CachedLspAdapter>) -> Self {
self.adapter = Some(lsp_adapter);
pub async fn with_lsp_adapter(mut self, lsp_adapter: Option<Box<dyn LspAdapter>>) -> Self {
if let Some(adapter) = lsp_adapter {
self.adapter = Some(CachedLspAdapter::new(adapter).await);
}
self
}
@ -894,7 +1010,7 @@ impl Language {
) -> mpsc::UnboundedReceiver<lsp::FakeLanguageServer> {
let (servers_tx, servers_rx) = mpsc::unbounded();
self.fake_adapter = Some((servers_tx, fake_lsp_adapter.clone()));
let adapter = CachedLspAdapter::new(fake_lsp_adapter).await;
let adapter = CachedLspAdapter::new(Box::new(fake_lsp_adapter)).await;
self.adapter = Some(adapter);
servers_rx
}

View file

@ -381,7 +381,12 @@ impl SyntaxSnapshot {
cursor.next(text);
while let Some(layer) = cursor.item() {
let SyntaxLayerContent::Pending { language_name } = &layer.content else { unreachable!() };
if language_for_injection(language_name, &registry).is_some() {
if {
let language_registry = &registry;
language_registry.language_for_name_or_extension(language_name)
}
.is_some()
{
resolved_injection_ranges.push(layer.range.to_offset(text));
}
@ -1066,7 +1071,7 @@ fn get_injections(
config: &InjectionConfig,
text: &BufferSnapshot,
node: Node,
language_registry: &LanguageRegistry,
language_registry: &Arc<LanguageRegistry>,
depth: usize,
changed_ranges: &[Range<usize>],
combined_injection_ranges: &mut HashMap<Arc<Language>, Vec<tree_sitter::Range>>,
@ -1078,7 +1083,8 @@ fn get_injections(
combined_injection_ranges.clear();
for pattern in &config.patterns {
if let (Some(language_name), true) = (pattern.language.as_ref(), pattern.combined) {
if let Some(language) = language_for_injection(language_name, language_registry) {
if let Some(language) = language_registry.language_for_name_or_extension(language_name)
{
combined_injection_ranges.insert(language, Vec::new());
}
}
@ -1123,7 +1129,10 @@ fn get_injections(
};
if let Some(language_name) = language_name {
let language = language_for_injection(&language_name, language_registry);
let language = {
let language_name: &str = &language_name;
language_registry.language_for_name_or_extension(language_name)
};
let range = text.anchor_before(step_range.start)..text.anchor_after(step_range.end);
if let Some(language) = language {
if combined {
@ -1171,15 +1180,6 @@ fn get_injections(
}
}
fn language_for_injection(
language_name: &str,
language_registry: &LanguageRegistry,
) -> Option<Arc<Language>> {
language_registry
.language_for_name(language_name)
.or_else(|| language_registry.language_for_extension(language_name))
}
fn splice_included_ranges(
mut ranges: Vec<tree_sitter::Range>,
changed_ranges: &[Range<usize>],

View file

@ -1802,7 +1802,7 @@ impl Project {
) -> Option<()> {
// If the buffer has a language, set it and start the language server if we haven't already.
let full_path = buffer.read(cx).file()?.full_path(cx);
let new_language = self.languages.select_language(&full_path)?;
let new_language = self.languages.language_for_path(&full_path)?;
buffer.update(cx, |buffer, cx| {
if buffer.language().map_or(true, |old_language| {
!Arc::ptr_eq(old_language, &new_language)
@ -2211,7 +2211,7 @@ impl Project {
})
.collect();
for (worktree_id, worktree_abs_path, full_path) in language_server_lookup_info {
let language = self.languages.select_language(&full_path)?;
let language = self.languages.language_for_path(&full_path)?;
self.restart_language_server(worktree_id, worktree_abs_path, language, cx);
}
@ -3171,7 +3171,7 @@ impl Project {
let signature = this.symbol_signature(&project_path);
let language = this
.languages
.select_language(&project_path.path)
.language_for_path(&project_path.path)
.unwrap_or(adapter_language.clone());
let language_server_name = adapter.name.clone();
Some(async move {
@ -5947,7 +5947,7 @@ impl Project {
worktree_id,
path: PathBuf::from(serialized_symbol.path).into(),
};
let language = languages.select_language(&path.path);
let language = languages.language_for_path(&path.path);
Ok(Symbol {
language_server_name: LanguageServerName(
serialized_symbol.language_server_name.into(),

View file

@ -9,7 +9,7 @@ use std::fmt;
use std::{
cmp,
fmt::Debug,
io, iter, mem,
io, iter,
time::{Duration, SystemTime, UNIX_EPOCH},
};
@ -489,16 +489,26 @@ pub fn split_worktree_update(
return None;
}
let chunk_size = cmp::min(message.updated_entries.len(), max_chunk_size);
let updated_entries = message.updated_entries.drain(..chunk_size).collect();
done = message.updated_entries.is_empty();
let updated_entries_chunk_size = cmp::min(message.updated_entries.len(), max_chunk_size);
let updated_entries = message
.updated_entries
.drain(..updated_entries_chunk_size)
.collect();
let removed_entries_chunk_size = cmp::min(message.removed_entries.len(), max_chunk_size);
let removed_entries = message
.removed_entries
.drain(..removed_entries_chunk_size)
.collect();
done = message.updated_entries.is_empty() && message.removed_entries.is_empty();
Some(UpdateWorktree {
project_id: message.project_id,
worktree_id: message.worktree_id,
root_name: message.root_name.clone(),
abs_path: message.abs_path.clone(),
updated_entries,
removed_entries: mem::take(&mut message.removed_entries),
removed_entries,
scan_id: message.scan_id,
is_last_update: done && message.is_last_update,
})

View file

@ -3,7 +3,7 @@ authors = ["Nathan Sobo <nathansobo@gmail.com>"]
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.71.0"
version = "0.71.3"
publish = false
[lib]

View file

@ -1 +1 @@
dev
stable

View file

@ -1,7 +1,5 @@
use anyhow::Context;
use gpui::executor::Background;
pub use language::*;
use lazy_static::lazy_static;
use rust_embed::RustEmbed;
use std::{borrow::Cow, str, sync::Arc};
@ -32,32 +30,17 @@ mod typescript;
#[exclude = "*.rs"]
struct LanguageDir;
// TODO - Remove this once the `init` function is synchronous again.
lazy_static! {
pub static ref LANGUAGE_NAMES: Vec<String> = LanguageDir::iter()
.filter_map(|path| {
if path.ends_with("config.toml") {
let config = LanguageDir::get(&path)?;
let config = toml::from_slice::<LanguageConfig>(&config.data).ok()?;
Some(config.name.to_string())
} else {
None
}
})
.collect();
}
pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>) {
pub fn init(languages: Arc<LanguageRegistry>) {
for (name, grammar, lsp_adapter) in [
(
"c",
tree_sitter_c::language(),
Some(CachedLspAdapter::new(c::CLspAdapter).await),
Some(Box::new(c::CLspAdapter) as Box<dyn LspAdapter>),
),
(
"cpp",
tree_sitter_cpp::language(),
Some(CachedLspAdapter::new(c::CLspAdapter).await),
Some(Box::new(c::CLspAdapter)),
),
(
"css",
@ -67,17 +50,17 @@ pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>)
(
"elixir",
tree_sitter_elixir::language(),
Some(CachedLspAdapter::new(elixir::ElixirLspAdapter).await),
Some(Box::new(elixir::ElixirLspAdapter)),
),
(
"go",
tree_sitter_go::language(),
Some(CachedLspAdapter::new(go::GoLspAdapter).await),
Some(Box::new(go::GoLspAdapter)),
),
(
"json",
tree_sitter_json::language(),
Some(CachedLspAdapter::new(json::JsonLspAdapter).await),
Some(Box::new(json::JsonLspAdapter)),
),
(
"markdown",
@ -87,12 +70,12 @@ pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>)
(
"python",
tree_sitter_python::language(),
Some(CachedLspAdapter::new(python::PythonLspAdapter).await),
Some(Box::new(python::PythonLspAdapter)),
),
(
"rust",
tree_sitter_rust::language(),
Some(CachedLspAdapter::new(rust::RustLspAdapter).await),
Some(Box::new(rust::RustLspAdapter)),
),
(
"toml",
@ -102,89 +85,82 @@ pub async fn init(languages: Arc<LanguageRegistry>, _executor: Arc<Background>)
(
"tsx",
tree_sitter_typescript::language_tsx(),
Some(CachedLspAdapter::new(typescript::TypeScriptLspAdapter).await),
Some(Box::new(typescript::TypeScriptLspAdapter)),
),
(
"typescript",
tree_sitter_typescript::language_typescript(),
Some(CachedLspAdapter::new(typescript::TypeScriptLspAdapter).await),
Some(Box::new(typescript::TypeScriptLspAdapter)),
),
(
"javascript",
tree_sitter_typescript::language_tsx(),
Some(CachedLspAdapter::new(typescript::TypeScriptLspAdapter).await),
Some(Box::new(typescript::TypeScriptLspAdapter)),
),
(
"html",
tree_sitter_html::language(),
Some(CachedLspAdapter::new(html::HtmlLspAdapter).await),
Some(Box::new(html::HtmlLspAdapter)),
),
(
"ruby",
tree_sitter_ruby::language(),
Some(CachedLspAdapter::new(ruby::RubyLanguageServer).await),
Some(Box::new(ruby::RubyLanguageServer)),
),
(
"erb",
tree_sitter_embedded_template::language(),
Some(CachedLspAdapter::new(ruby::RubyLanguageServer).await),
Some(Box::new(ruby::RubyLanguageServer)),
),
(
"scheme",
tree_sitter_scheme::language(),
None, //
),
(
"racket",
tree_sitter_racket::language(),
None, //
),
("scheme", tree_sitter_scheme::language(), None),
("racket", tree_sitter_racket::language(), None),
] {
languages.add(language(name, grammar, lsp_adapter));
languages.register(name, load_config(name), grammar, lsp_adapter, load_queries);
}
}
pub(crate) fn language(
#[cfg(any(test, feature = "test-support"))]
pub async fn language(
name: &str,
grammar: tree_sitter::Language,
lsp_adapter: Option<Arc<CachedLspAdapter>>,
lsp_adapter: Option<Box<dyn LspAdapter>>,
) -> Arc<Language> {
let config = toml::from_slice(
Arc::new(
Language::new(load_config(name), Some(grammar))
.with_lsp_adapter(lsp_adapter)
.await
.with_queries(load_queries(name))
.unwrap(),
)
}
fn load_config(name: &str) -> LanguageConfig {
toml::from_slice(
&LanguageDir::get(&format!("{}/config.toml", name))
.unwrap()
.data,
)
.with_context(|| format!("failed to load config.toml for language {name:?}"))
.unwrap();
.unwrap()
}
let mut language = Language::new(config, Some(grammar));
if let Some(query) = load_query(name, "/highlights") {
language = language
.with_highlights_query(query.as_ref())
.expect("failed to evaluate highlights query");
fn load_queries(name: &str) -> LanguageQueries {
LanguageQueries {
highlights: load_query(name, "/highlights"),
brackets: load_query(name, "/brackets"),
indents: load_query(name, "/indents"),
outline: load_query(name, "/outline"),
injections: load_query(name, "/injections"),
overrides: load_query(name, "/overrides"),
}
if let Some(query) = load_query(name, "/brackets") {
language = language
.with_brackets_query(query.as_ref())
.expect("failed to load brackets query");
}
if let Some(query) = load_query(name, "/indents") {
language = language
.with_indents_query(query.as_ref())
.expect("failed to load indents query");
}
if let Some(query) = load_query(name, "/outline") {
language = language
.with_outline_query(query.as_ref())
.expect("failed to load outline query");
}
if let Some(query) = load_query(name, "/injections") {
language = language
.with_injection_query(query.as_ref())
.expect("failed to load injection query");
}
if let Some(query) = load_query(name, "/overrides") {
language = language
.with_override_query(query.as_ref())
.expect("failed to load override query");
}
if let Some(lsp_adapter) = lsp_adapter {
language = language.with_lsp_adapter(lsp_adapter)
}
Arc::new(language)
}
fn load_query(name: &str, filename_prefix: &str) -> Option<Cow<'static, str>> {

View file

@ -248,17 +248,19 @@ impl super::LspAdapter for CLspAdapter {
#[cfg(test)]
mod tests {
use gpui::MutableAppContext;
use gpui::TestAppContext;
use language::{AutoindentMode, Buffer};
use settings::Settings;
#[gpui::test]
fn test_c_autoindent(cx: &mut MutableAppContext) {
async fn test_c_autoindent(cx: &mut TestAppContext) {
cx.foreground().set_block_on_ticks(usize::MAX..=usize::MAX);
let mut settings = Settings::test(cx);
settings.editor_overrides.tab_size = Some(2.try_into().unwrap());
cx.set_global(settings);
let language = crate::languages::language("c", tree_sitter_c::language(), None);
cx.update(|cx| {
let mut settings = Settings::test(cx);
settings.editor_overrides.tab_size = Some(2.try_into().unwrap());
cx.set_global(settings);
});
let language = crate::languages::language("c", tree_sitter_c::language(), None).await;
cx.add_model(|cx| {
let mut buffer = Buffer::new(0, "", cx).with_language(language, cx);

View file

@ -314,8 +314,9 @@ mod tests {
let language = language(
"go",
tree_sitter_go::language(),
Some(CachedLspAdapter::new(GoLspAdapter).await),
);
Some(Box::new(GoLspAdapter)),
)
.await;
let theme = SyntaxTheme::new(vec![
("type".into(), Color::green().into()),

View file

@ -165,17 +165,20 @@ impl LspAdapter for PythonLspAdapter {
#[cfg(test)]
mod tests {
use gpui::{ModelContext, MutableAppContext};
use gpui::{ModelContext, TestAppContext};
use language::{AutoindentMode, Buffer};
use settings::Settings;
#[gpui::test]
fn test_python_autoindent(cx: &mut MutableAppContext) {
async fn test_python_autoindent(cx: &mut TestAppContext) {
cx.foreground().set_block_on_ticks(usize::MAX..=usize::MAX);
let language = crate::languages::language("python", tree_sitter_python::language(), None);
let mut settings = Settings::test(cx);
settings.editor_overrides.tab_size = Some(2.try_into().unwrap());
cx.set_global(settings);
let language =
crate::languages::language("python", tree_sitter_python::language(), None).await;
cx.update(|cx| {
let mut settings = Settings::test(cx);
settings.editor_overrides.tab_size = Some(2.try_into().unwrap());
cx.set_global(settings);
});
cx.add_model(|cx| {
let mut buffer = Buffer::new(0, "", cx).with_language(language, cx);

View file

@ -255,8 +255,8 @@ impl LspAdapter for RustLspAdapter {
#[cfg(test)]
mod tests {
use super::*;
use crate::languages::{language, CachedLspAdapter};
use gpui::{color::Color, MutableAppContext};
use crate::languages::language;
use gpui::{color::Color, TestAppContext};
use settings::Settings;
use theme::SyntaxTheme;
@ -306,8 +306,9 @@ mod tests {
let language = language(
"rust",
tree_sitter_rust::language(),
Some(CachedLspAdapter::new(RustLspAdapter).await),
);
Some(Box::new(RustLspAdapter)),
)
.await;
let grammar = language.grammar().unwrap();
let theme = SyntaxTheme::new(vec![
("type".into(), Color::green().into()),
@ -391,8 +392,9 @@ mod tests {
let language = language(
"rust",
tree_sitter_rust::language(),
Some(CachedLspAdapter::new(RustLspAdapter).await),
);
Some(Box::new(RustLspAdapter)),
)
.await;
let grammar = language.grammar().unwrap();
let theme = SyntaxTheme::new(vec![
("type".into(), Color::green().into()),
@ -431,12 +433,15 @@ mod tests {
}
#[gpui::test]
fn test_rust_autoindent(cx: &mut MutableAppContext) {
async fn test_rust_autoindent(cx: &mut TestAppContext) {
cx.foreground().set_block_on_ticks(usize::MAX..=usize::MAX);
let language = crate::languages::language("rust", tree_sitter_rust::language(), None);
let mut settings = Settings::test(cx);
settings.editor_overrides.tab_size = Some(2.try_into().unwrap());
cx.set_global(settings);
cx.update(|cx| {
let mut settings = Settings::test(cx);
settings.editor_overrides.tab_size = Some(2.try_into().unwrap());
cx.set_global(settings);
});
let language = crate::languages::language("rust", tree_sitter_rust::language(), None).await;
cx.add_model(|cx| {
let mut buffer = Buffer::new(0, "", cx).with_language(language, cx);

View file

@ -154,17 +154,17 @@ impl LspAdapter for TypeScriptLspAdapter {
#[cfg(test)]
mod tests {
use gpui::MutableAppContext;
use gpui::TestAppContext;
use unindent::Unindent;
#[gpui::test]
fn test_outline(cx: &mut MutableAppContext) {
async fn test_outline(cx: &mut TestAppContext) {
let language = crate::languages::language(
"typescript",
tree_sitter_typescript::language_typescript(),
None,
);
)
.await;
let text = r#"
function a() {
@ -183,7 +183,7 @@ mod tests {
let buffer =
cx.add_model(|cx| language::Buffer::new(0, text, cx).with_language(language, cx));
let outline = buffer.read(cx).snapshot().outline(None).unwrap();
let outline = buffer.read_with(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
assert_eq!(
outline
.items

View file

@ -3,7 +3,6 @@
use anyhow::{anyhow, Context, Result};
use assets::Assets;
use auto_update::ZED_APP_VERSION;
use backtrace::Backtrace;
use cli::{
ipc::{self, IpcSender},
@ -12,7 +11,7 @@ use cli::{
use client::{
self,
http::{self, HttpClient},
UserStore, ZED_SECRET_CLIENT_TOKEN,
UserStore, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN,
};
use futures::{
@ -120,11 +119,10 @@ fn main() {
let client = client::Client::new(http.clone(), cx);
let mut languages = LanguageRegistry::new(login_shell_env_loaded);
languages.set_executor(cx.background().clone());
languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
let languages = Arc::new(languages);
let init_languages = cx
.background()
.spawn(languages::init(languages.clone(), cx.background().clone()));
languages::init(languages.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
watch_keymap_file(keymap_file, cx);
@ -136,7 +134,6 @@ fn main() {
client::init(client.clone(), cx);
command_palette::init(cx);
editor::init(cx);
feedback::init(cx);
go_to_line::init(cx);
file_finder::init(cx);
outline::init(cx);
@ -152,14 +149,7 @@ fn main() {
cx.spawn(|cx| watch_themes(fs.clone(), themes.clone(), cx))
.detach();
cx.spawn({
let languages = languages.clone();
|cx| async move {
cx.read(|cx| languages.set_theme(cx.global::<Settings>().theme.clone()));
init_languages.await;
}
})
.detach();
languages.set_theme(cx.global::<Settings>().theme.clone());
cx.observe_global::<Settings, _>({
let languages = languages.clone();
move |cx| languages.set_theme(cx.global::<Settings>().theme.clone())
@ -191,6 +181,7 @@ fn main() {
theme_selector::init(app_state.clone(), cx);
zed::init(&app_state, cx);
collab_ui::init(app_state.clone(), cx);
feedback::init(app_state.clone(), cx);
cx.set_menus(menus::menus());

View file

@ -306,7 +306,7 @@ pub fn initialize_workspace(
)
.map(|meta| meta.name)
.collect();
let language_names = &languages::LANGUAGE_NAMES;
let language_names = app_state.languages.language_names();
workspace.project().update(cx, |project, cx| {
let action_names = cx.all_action_names().collect::<Vec<_>>();
@ -318,7 +318,7 @@ pub fn initialize_workspace(
"schemas": [
{
"fileMatch": [schema_file_match(&paths::SETTINGS)],
"schema": settings_file_json_schema(theme_names, language_names),
"schema": settings_file_json_schema(theme_names, &language_names),
},
{
"fileMatch": [schema_file_match(&paths::KEYMAP)],