Merge branch 'main' into multi-server-completions-tailwind

This commit is contained in:
Julia 2023-08-30 22:41:12 -04:00
commit ff3865a4ad
427 changed files with 43123 additions and 12861 deletions

View file

@ -3,7 +3,7 @@ authors = ["Nathan Sobo <nathansobo@gmail.com>"]
description = "The fast, collaborative code editor."
edition = "2021"
name = "zed"
version = "0.100.0"
version = "0.103.0"
publish = false
[lib]
@ -21,10 +21,12 @@ activity_indicator = { path = "../activity_indicator" }
auto_update = { path = "../auto_update" }
breadcrumbs = { path = "../breadcrumbs" }
call = { path = "../call" }
channel = { path = "../channel" }
cli = { path = "../cli" }
collab_ui = { path = "../collab_ui" }
collections = { path = "../collections" }
command_palette = { path = "../command_palette" }
component_test = { path = "../component_test" }
context_menu = { path = "../context_menu" }
client = { path = "../client" }
clock = { path = "../clock" }
@ -54,10 +56,11 @@ plugin_runtime = { path = "../plugin_runtime",optional = true }
project = { path = "../project" }
project_panel = { path = "../project_panel" }
project_symbols = { path = "../project_symbols" }
quick_action_bar = { path = "../quick_action_bar" }
recent_projects = { path = "../recent_projects" }
rpc = { path = "../rpc" }
settings = { path = "../settings" }
staff_mode = { path = "../staff_mode" }
feature_flags = { path = "../feature_flags" }
sum_tree = { path = "../sum_tree" }
text = { path = "../text" }
terminal_view = { path = "../terminal_view" }
@ -92,7 +95,7 @@ postage.workspace = true
rand.workspace = true
regex.workspace = true
rsa = "0.4"
rust-embed = { version = "6.3", features = ["include-exclude"] }
rust-embed.workspace = true
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true

View file

@ -18,11 +18,7 @@
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<!-- <key>com.apple.security.cs.disable-library-validation</key>
<true/> -->
</dict>
</plist>

View file

@ -293,7 +293,7 @@ mod tests {
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);
let mut buffer = Buffer::new(0, cx.model_id() as u64, "").with_language(language, cx);
// empty function
buffer.edit([(0..0, "int main() {}")], None, cx);

View file

@ -1,5 +1,5 @@
name = "C++"
path_suffixes = ["cc", "cpp", "h", "hpp"]
path_suffixes = ["cc", "cpp", "h", "hpp", "cxx", "hxx", "inl"]
line_comment = "// "
autoclose_before = ";:.,=}])>"
brackets = [

View file

@ -1,5 +1,5 @@
name = "JavaScript"
path_suffixes = ["js", "jsx", "mjs"]
path_suffixes = ["js", "jsx", "mjs", "cjs"]
first_line_pattern = '^#!.*\bnode\b'
line_comment = "// "
autoclose_before = ";:.,=}])>"
@ -13,6 +13,7 @@ brackets = [
{ start = "`", end = "`", close = true, newline = false, not_in = ["comment", "string"] },
{ start = "/*", end = " */", close = true, newline = false, not_in = ["comment", "string"] },
]
word_characters = ["$", "#"]
scope_opt_in_language_servers = ["tailwindcss-language-server"]
[overrides.element]

View file

@ -1,6 +1,7 @@
use anyhow::{anyhow, Result};
use async_trait::async_trait;
use collections::HashMap;
use feature_flags::FeatureFlagAppExt;
use futures::{future::BoxFuture, FutureExt, StreamExt};
use gpui::AppContext;
use language::{LanguageRegistry, LanguageServerName, LspAdapter, LspAdapterDelegate};
@ -9,7 +10,6 @@ use node_runtime::NodeRuntime;
use serde_json::json;
use settings::{KeymapFile, SettingsJsonSchemaParams, SettingsStore};
use smol::fs;
use staff_mode::StaffMode;
use std::{
any::Any,
ffi::OsString,
@ -108,7 +108,7 @@ impl LspAdapter for JsonLspAdapter {
cx: &mut AppContext,
) -> BoxFuture<'static, serde_json::Value> {
let action_names = cx.all_action_names().collect::<Vec<_>>();
let staff_mode = cx.default_global::<StaffMode>().0;
let staff_mode = cx.is_staff();
let language_names = &self.languages.language_names();
let settings_schema = cx.global::<SettingsStore>().json_schema(
&SettingsJsonSchemaParams {

View file

@ -93,7 +93,9 @@ impl LspAdapter for PythonLspAdapter {
// to allow our own fuzzy score to be used to break ties.
//
// see https://github.com/microsoft/pyright/blob/95ef4e103b9b2f129c9320427e51b73ea7cf78bd/packages/pyright-internal/src/languageService/completionProvider.ts#LL2873
let Some(sort_text) = &mut item.sort_text else { return };
let Some(sort_text) = &mut item.sort_text else {
return;
};
let mut parts = sort_text.split('.');
let Some(first) = parts.next() else { return };
let Some(second) = parts.next() else { return };
@ -212,7 +214,7 @@ mod tests {
});
cx.add_model(|cx| {
let mut buffer = Buffer::new(0, "", cx).with_language(language, cx);
let mut buffer = Buffer::new(0, cx.model_id() as u64, "").with_language(language, cx);
let append = |buffer: &mut Buffer, text: &str, cx: &mut ModelContext<Buffer>| {
let ix = buffer.len();
buffer.edit([(ix..ix, text)], Some(AutoindentMode::EachLine), cx);

View file

@ -1,5 +1,5 @@
name = "Python"
path_suffixes = ["py", "pyi"]
path_suffixes = ["py", "pyi", "mpy"]
first_line_pattern = '^#!.*\bpython[0-9.]*\b'
line_comment = "# "
autoclose_before = ";:.,=}])>"

View file

@ -478,7 +478,7 @@ mod tests {
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);
let mut buffer = Buffer::new(0, cx.model_id() as u64, "").with_language(language, cx);
// indent between braces
buffer.set_text("fn a() {}", cx);

View file

@ -12,6 +12,7 @@ brackets = [
{ start = "`", end = "`", close = true, newline = false, not_in = ["string"] },
{ start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },
]
word_characters = ["#", "$"]
scope_opt_in_language_servers = ["tailwindcss-language-server"]
[overrides.element]

View file

@ -362,8 +362,9 @@ mod tests {
"#
.unindent();
let buffer =
cx.add_model(|cx| language::Buffer::new(0, text, cx).with_language(language, cx));
let buffer = cx.add_model(|cx| {
language::Buffer::new(0, cx.model_id() as u64, text).with_language(language, cx)
});
let outline = buffer.read_with(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
assert_eq!(
outline

View file

@ -1,5 +1,5 @@
name = "TypeScript"
path_suffixes = ["ts"]
path_suffixes = ["ts", "cts", "d.cts", "d.mts", "mts"]
line_comment = "// "
autoclose_before = ";:.,=}])>"
brackets = [
@ -12,3 +12,4 @@ brackets = [
{ start = "`", end = "`", close = true, newline = false, not_in = ["string"] },
{ start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] },
]
word_characters = ["#", "$"]

View file

@ -3,6 +3,7 @@
use anyhow::{anyhow, Context, Result};
use backtrace::Backtrace;
use channel::ChannelStore;
use cli::{
ipc::{self, IpcSender},
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
@ -30,7 +31,7 @@ use std::{
env,
ffi::OsStr,
fs::OpenOptions,
io::Write as _,
io::{IsTerminal, Write as _},
os::unix::prelude::OsStrExt,
panic,
path::{Path, PathBuf},
@ -52,8 +53,6 @@ use uuid::Uuid;
use welcome::{show_welcome_experience, FIRST_OPEN};
use fs::RealFs;
#[cfg(debug_assertions)]
use staff_mode::StaffMode;
use util::{channel::RELEASE_CHANNEL, paths, ResultExt, TryFutureExt};
use workspace::AppState;
use zed::{
@ -121,7 +120,10 @@ fn main() {
cx.set_global(*RELEASE_CHANNEL);
#[cfg(debug_assertions)]
cx.set_global(StaffMode(true));
{
use feature_flags::FeatureFlagAppExt;
cx.set_staff(true);
}
let mut store = SettingsStore::default();
store
@ -140,6 +142,8 @@ fn main() {
languages::init(languages.clone(), node_runtime.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
let channel_store =
cx.add_model(|cx| ChannelStore::new(client.clone(), user_store.clone(), cx));
cx.set_global(client.clone());
@ -155,6 +159,7 @@ fn main() {
outline::init(cx);
project_symbols::init(cx);
project_panel::init(Assets, cx);
channel::init(&client);
diagnostics::init(cx);
search::init(cx);
semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
@ -162,6 +167,7 @@ fn main() {
terminal_view::init(cx);
copilot::init(http.clone(), node_runtime, cx);
ai::init(cx);
component_test::init(cx);
cx.spawn(|cx| watch_themes(fs.clone(), cx)).detach();
cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
@ -181,6 +187,7 @@ fn main() {
languages,
client: client.clone(),
user_store,
channel_store,
fs,
build_window_options,
initialize_workspace,
@ -628,8 +635,7 @@ async fn load_login_shell_environment() -> Result<()> {
}
fn stdout_is_a_pty() -> bool {
std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none()
&& unsafe { libc::isatty(libc::STDOUT_FILENO as i32) != 0 }
std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
}
fn collect_path_args() -> Vec<PathBuf> {

View file

@ -10,7 +10,7 @@ use anyhow::Context;
use assets::Assets;
use breadcrumbs::Breadcrumbs;
pub use client;
use collab_ui::{CollabTitlebarItem, ToggleContactsMenu};
use collab_ui::CollabTitlebarItem; // TODO: Add back toggle collab ui shortcut
use collections::VecDeque;
pub use editor;
use editor::{Editor, MultiBuffer};
@ -30,6 +30,7 @@ use gpui::{
pub use lsp;
pub use project;
use project_panel::ProjectPanel;
use quick_action_bar::QuickActionBar;
use search::{BufferSearchBar, ProjectSearchBar};
use serde::Deserialize;
use serde_json::to_string_pretty;
@ -85,20 +86,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
cx.toggle_full_screen();
},
);
cx.add_action(
|workspace: &mut Workspace, _: &ToggleContactsMenu, cx: &mut ViewContext<Workspace>| {
if let Some(item) = workspace
.titlebar_item()
.and_then(|item| item.downcast::<CollabTitlebarItem>())
{
cx.defer(move |_, cx| {
item.update(cx, |item, cx| {
item.toggle_contacts_popover(&Default::default(), cx);
});
});
}
},
);
cx.add_global_action(quit);
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {
@ -220,6 +207,13 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::AppContext) {
workspace.toggle_panel_focus::<ProjectPanel>(cx);
},
);
cx.add_action(
|workspace: &mut Workspace,
_: &collab_ui::collab_panel::ToggleFocus,
cx: &mut ViewContext<Workspace>| {
workspace.toggle_panel_focus::<collab_ui::collab_panel::CollabPanel>(cx);
},
);
cx.add_action(
|workspace: &mut Workspace,
_: &terminal_panel::ToggleFocus,
@ -269,7 +263,11 @@ pub fn initialize_workspace(
let breadcrumbs = cx.add_view(|_| Breadcrumbs::new(workspace));
toolbar.add_item(breadcrumbs, cx);
let buffer_search_bar = cx.add_view(BufferSearchBar::new);
toolbar.add_item(buffer_search_bar, cx);
toolbar.add_item(buffer_search_bar.clone(), cx);
let quick_action_bar = cx.add_view(|_| {
QuickActionBar::new(buffer_search_bar, workspace)
});
toolbar.add_item(quick_action_bar, cx);
let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
toolbar.add_item(project_search_bar, cx);
let submit_feedback_button =
@ -338,9 +336,14 @@ pub fn initialize_workspace(
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());
let terminal_panel = TerminalPanel::load(workspace_handle.clone(), cx.clone());
let assistant_panel = AssistantPanel::load(workspace_handle.clone(), cx.clone());
let (project_panel, terminal_panel, assistant_panel) =
futures::try_join!(project_panel, terminal_panel, assistant_panel)?;
let channels_panel =
collab_ui::collab_panel::CollabPanel::load(workspace_handle.clone(), cx.clone());
let (project_panel, terminal_panel, assistant_panel, channels_panel) = futures::try_join!(
project_panel,
terminal_panel,
assistant_panel,
channels_panel
)?;
workspace_handle.update(&mut cx, |workspace, cx| {
let project_panel_position = project_panel.position(cx);
workspace.add_panel_with_extra_event_handler(
@ -358,6 +361,7 @@ pub fn initialize_workspace(
);
workspace.add_panel(terminal_panel, cx);
workspace.add_panel(assistant_panel, cx);
workspace.add_panel(channels_panel, cx);
if !was_deserialized
&& workspace
@ -1703,6 +1707,8 @@ mod tests {
.remove_file(Path::new("/root/a/file2"), Default::default())
.await
.unwrap();
cx.foreground().run_until_parked();
workspace
.update(cx, |w, cx| w.go_back(w.active_pane().downgrade(), cx))
.await
@ -2382,6 +2388,7 @@ mod tests {
language::init(cx);
editor::init(cx);
project_panel::init_settings(cx);
collab_ui::init(&app_state, cx);
pane::init(cx);
project_panel::init((), cx);
terminal_view::init(cx);