Merge remote-tracking branch 'origin/main' into zed2-workspace
This commit is contained in:
commit
269a72464d
128 changed files with 1718 additions and 1670 deletions
|
@ -15,12 +15,12 @@ name = "Zed"
|
|||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
ai2 = { path = "../ai2"}
|
||||
ai = { package = "ai2", path = "../ai2"}
|
||||
# audio = { path = "../audio" }
|
||||
# activity_indicator = { path = "../activity_indicator" }
|
||||
# auto_update = { path = "../auto_update" }
|
||||
# breadcrumbs = { path = "../breadcrumbs" }
|
||||
call2 = { path = "../call2" }
|
||||
call = { package = "call2", path = "../call2" }
|
||||
# channel = { path = "../channel" }
|
||||
cli = { path = "../cli" }
|
||||
# collab_ui = { path = "../collab_ui" }
|
||||
|
@ -28,44 +28,44 @@ collections = { path = "../collections" }
|
|||
# command_palette = { path = "../command_palette" }
|
||||
# component_test = { path = "../component_test" }
|
||||
# context_menu = { path = "../context_menu" }
|
||||
client2 = { path = "../client2" }
|
||||
client = { package = "client2", path = "../client2" }
|
||||
# clock = { path = "../clock" }
|
||||
copilot2 = { path = "../copilot2" }
|
||||
copilot = { package = "copilot2", path = "../copilot2" }
|
||||
# copilot_button = { path = "../copilot_button" }
|
||||
# diagnostics = { path = "../diagnostics" }
|
||||
db2 = { path = "../db2" }
|
||||
db = { package = "db2", path = "../db2" }
|
||||
# editor = { path = "../editor" }
|
||||
# feedback = { path = "../feedback" }
|
||||
# file_finder = { path = "../file_finder" }
|
||||
# search = { path = "../search" }
|
||||
fs2 = { path = "../fs2" }
|
||||
fs = { package = "fs2", path = "../fs2" }
|
||||
fsevent = { path = "../fsevent" }
|
||||
fuzzy = { path = "../fuzzy" }
|
||||
# go_to_line = { path = "../go_to_line" }
|
||||
gpui2 = { path = "../gpui2" }
|
||||
gpui = { package = "gpui2", path = "../gpui2" }
|
||||
install_cli = { path = "../install_cli" }
|
||||
journal2 = { path = "../journal2" }
|
||||
language2 = { path = "../language2" }
|
||||
journal = { package = "journal2", path = "../journal2" }
|
||||
language = { package = "language2", path = "../language2" }
|
||||
# language_selector = { path = "../language_selector" }
|
||||
lsp2 = { path = "../lsp2" }
|
||||
lsp = { package = "lsp2", path = "../lsp2" }
|
||||
language_tools = { path = "../language_tools" }
|
||||
node_runtime = { path = "../node_runtime" }
|
||||
# assistant = { path = "../assistant" }
|
||||
# outline = { path = "../outline" }
|
||||
# plugin_runtime = { path = "../plugin_runtime",optional = true }
|
||||
project2 = { path = "../project2" }
|
||||
project = { package = "project2", path = "../project2" }
|
||||
# project_panel = { path = "../project_panel" }
|
||||
# project_symbols = { path = "../project_symbols" }
|
||||
# quick_action_bar = { path = "../quick_action_bar" }
|
||||
# recent_projects = { path = "../recent_projects" }
|
||||
rpc2 = { path = "../rpc2" }
|
||||
settings2 = { path = "../settings2" }
|
||||
feature_flags2 = { path = "../feature_flags2" }
|
||||
rpc = { package = "rpc2", path = "../rpc2" }
|
||||
settings = { package = "settings2", path = "../settings2" }
|
||||
feature_flags = { package = "feature_flags2", path = "../feature_flags2" }
|
||||
sum_tree = { path = "../sum_tree" }
|
||||
shellexpand = "2.1.0"
|
||||
text2 = { path = "../text2" }
|
||||
text = { package = "text2", path = "../text2" }
|
||||
# terminal_view = { path = "../terminal_view" }
|
||||
theme2 = { path = "../theme2" }
|
||||
theme = { package = "theme2", path = "../theme2" }
|
||||
# theme_selector = { path = "../theme_selector" }
|
||||
util = { path = "../util" }
|
||||
# semantic_index = { path = "../semantic_index" }
|
||||
|
@ -142,17 +142,17 @@ urlencoding = "2.1.2"
|
|||
uuid.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
call2 = { path = "../call2", features = ["test-support"] }
|
||||
call = { package = "call2", path = "../call2", features = ["test-support"] }
|
||||
# client = { path = "../client", features = ["test-support"] }
|
||||
# editor = { path = "../editor", features = ["test-support"] }
|
||||
# gpui = { path = "../gpui", features = ["test-support"] }
|
||||
gpui2 = { path = "../gpui2", features = ["test-support"] }
|
||||
language2 = { path = "../language2", features = ["test-support"] }
|
||||
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
|
||||
language = { package = "language2", path = "../language2", features = ["test-support"] }
|
||||
# lsp = { path = "../lsp", features = ["test-support"] }
|
||||
project2 = { path = "../project2", features = ["test-support"] }
|
||||
project = { package = "project2", path = "../project2", features = ["test-support"] }
|
||||
# rpc = { path = "../rpc", features = ["test-support"] }
|
||||
# settings = { path = "../settings", features = ["test-support"] }
|
||||
text2 = { path = "../text2", features = ["test-support"] }
|
||||
text = { package = "text2", path = "../text2", features = ["test-support"] }
|
||||
# util = { path = "../util", features = ["test-support"] }
|
||||
# workspace = { path = "../workspace", features = ["test-support"] }
|
||||
unindent.workspace = true
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use anyhow::anyhow;
|
||||
use gpui2::{AssetSource, Result, SharedString};
|
||||
|
||||
use gpui::{AssetSource, Result, SharedString};
|
||||
use rust_embed::RustEmbed;
|
||||
|
||||
#[derive(RustEmbed)]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use anyhow::Context;
|
||||
use gpui2::AppContext;
|
||||
pub use language2::*;
|
||||
use gpui::AppContext;
|
||||
pub use language::*;
|
||||
use node_runtime::NodeRuntime;
|
||||
use rust_embed::RustEmbed;
|
||||
use settings2::Settings;
|
||||
use settings::Settings;
|
||||
use std::{borrow::Cow, str, sync::Arc};
|
||||
use util::asset_str;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use anyhow::{anyhow, Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
pub use language2::*;
|
||||
use lsp2::LanguageServerBinary;
|
||||
pub use language::*;
|
||||
use lsp::LanguageServerBinary;
|
||||
use smol::fs::{self, File};
|
||||
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||
use util::{
|
||||
|
@ -108,7 +108,7 @@ impl super::LspAdapter for CLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
let label = completion
|
||||
|
@ -118,7 +118,7 @@ impl super::LspAdapter for CLspAdapter {
|
|||
.trim();
|
||||
|
||||
match completion.kind {
|
||||
Some(lsp2::CompletionItemKind::FIELD) if completion.detail.is_some() => {
|
||||
Some(lsp::CompletionItemKind::FIELD) if completion.detail.is_some() => {
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
let text = format!("{} {}", detail, label);
|
||||
let source = Rope::from(format!("struct S {{ {} }}", text).as_str());
|
||||
|
@ -129,7 +129,7 @@ impl super::LspAdapter for CLspAdapter {
|
|||
runs,
|
||||
});
|
||||
}
|
||||
Some(lsp2::CompletionItemKind::CONSTANT | lsp2::CompletionItemKind::VARIABLE)
|
||||
Some(lsp::CompletionItemKind::CONSTANT | lsp::CompletionItemKind::VARIABLE)
|
||||
if completion.detail.is_some() =>
|
||||
{
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
|
@ -141,7 +141,7 @@ impl super::LspAdapter for CLspAdapter {
|
|||
runs,
|
||||
});
|
||||
}
|
||||
Some(lsp2::CompletionItemKind::FUNCTION | lsp2::CompletionItemKind::METHOD)
|
||||
Some(lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD)
|
||||
if completion.detail.is_some() =>
|
||||
{
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
|
@ -155,13 +155,13 @@ impl super::LspAdapter for CLspAdapter {
|
|||
}
|
||||
Some(kind) => {
|
||||
let highlight_name = match kind {
|
||||
lsp2::CompletionItemKind::STRUCT
|
||||
| lsp2::CompletionItemKind::INTERFACE
|
||||
| lsp2::CompletionItemKind::CLASS
|
||||
| lsp2::CompletionItemKind::ENUM => Some("type"),
|
||||
lsp2::CompletionItemKind::ENUM_MEMBER => Some("variant"),
|
||||
lsp2::CompletionItemKind::KEYWORD => Some("keyword"),
|
||||
lsp2::CompletionItemKind::VALUE | lsp2::CompletionItemKind::CONSTANT => {
|
||||
lsp::CompletionItemKind::STRUCT
|
||||
| lsp::CompletionItemKind::INTERFACE
|
||||
| lsp::CompletionItemKind::CLASS
|
||||
| lsp::CompletionItemKind::ENUM => Some("type"),
|
||||
lsp::CompletionItemKind::ENUM_MEMBER => Some("variant"),
|
||||
lsp::CompletionItemKind::KEYWORD => Some("keyword"),
|
||||
lsp::CompletionItemKind::VALUE | lsp::CompletionItemKind::CONSTANT => {
|
||||
Some("constant")
|
||||
}
|
||||
_ => None,
|
||||
|
@ -186,47 +186,47 @@ impl super::LspAdapter for CLspAdapter {
|
|||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp2::SymbolKind,
|
||||
kind: lsp::SymbolKind,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
lsp2::SymbolKind::METHOD | lsp2::SymbolKind::FUNCTION => {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("void {} () {{}}", name);
|
||||
let filter_range = 0..name.len();
|
||||
let display_range = 5..5 + name.len();
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::STRUCT => {
|
||||
lsp::SymbolKind::STRUCT => {
|
||||
let text = format!("struct {} {{}}", name);
|
||||
let filter_range = 7..7 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::ENUM => {
|
||||
lsp::SymbolKind::ENUM => {
|
||||
let text = format!("enum {} {{}}", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::INTERFACE | lsp2::SymbolKind::CLASS => {
|
||||
lsp::SymbolKind::INTERFACE | lsp::SymbolKind::CLASS => {
|
||||
let text = format!("class {} {{}}", name);
|
||||
let filter_range = 6..6 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::CONSTANT => {
|
||||
lsp::SymbolKind::CONSTANT => {
|
||||
let text = format!("const int {} = 0;", name);
|
||||
let filter_range = 10..10 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::MODULE => {
|
||||
lsp::SymbolKind::MODULE => {
|
||||
let text = format!("namespace {} {{}}", name);
|
||||
let filter_range = 10..10 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::TYPE_PARAMETER => {
|
||||
lsp::SymbolKind::TYPE_PARAMETER => {
|
||||
let text = format!("typename {} {{}};", name);
|
||||
let filter_range = 9..9 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
|
@ -273,18 +273,18 @@ async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServ
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gpui2::{Context, TestAppContext};
|
||||
use language2::{language_settings::AllLanguageSettings, AutoindentMode, Buffer};
|
||||
use settings2::SettingsStore;
|
||||
use gpui::{Context, TestAppContext};
|
||||
use language::{language_settings::AllLanguageSettings, AutoindentMode, Buffer};
|
||||
use settings::SettingsStore;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_c_autoindent(cx: &mut TestAppContext) {
|
||||
// cx.executor().set_block_on_ticks(usize::MAX..=usize::MAX);
|
||||
cx.update(|cx| {
|
||||
let test_settings = SettingsStore::test(cx);
|
||||
cx.set_global(test_settings);
|
||||
language2::init(cx);
|
||||
language::init(cx);
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, |s| {
|
||||
s.defaults.tab_size = NonZeroU32::new(2);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::json;
|
||||
use smol::fs;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
use gpui2::{AsyncAppContext, Task};
|
||||
pub use language2::*;
|
||||
use lsp2::{CompletionItemKind, LanguageServerBinary, SymbolKind};
|
||||
use gpui::{AsyncAppContext, Task};
|
||||
pub use language::*;
|
||||
use lsp::{CompletionItemKind, LanguageServerBinary, SymbolKind};
|
||||
use schemars::JsonSchema;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use settings2::Settings;
|
||||
use settings::Settings;
|
||||
use smol::fs::{self, File};
|
||||
use std::{
|
||||
any::Any,
|
||||
|
@ -54,7 +54,7 @@ impl Settings for ElixirSettings {
|
|||
fn load(
|
||||
default_value: &Self::FileContent,
|
||||
user_values: &[&Self::FileContent],
|
||||
_: &mut gpui2::AppContext,
|
||||
_: &mut gpui::AppContext,
|
||||
) -> Result<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -200,7 +200,7 @@ impl LspAdapter for ElixirLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
match completion.kind.zip(completion.detail.as_ref()) {
|
||||
|
@ -404,7 +404,7 @@ impl LspAdapter for NextLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
label_for_completion_elixir(completion, language)
|
||||
|
@ -506,7 +506,7 @@ impl LspAdapter for LocalLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
label_for_completion_elixir(completion, language)
|
||||
|
@ -523,7 +523,7 @@ impl LspAdapter for LocalLspAdapter {
|
|||
}
|
||||
|
||||
fn label_for_completion_elixir(
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
return Some(CodeLabel {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
use gpui2::{AsyncAppContext, Task};
|
||||
pub use language2::*;
|
||||
use gpui::{AsyncAppContext, Task};
|
||||
pub use language::*;
|
||||
use lazy_static::lazy_static;
|
||||
use lsp2::LanguageServerBinary;
|
||||
use lsp::LanguageServerBinary;
|
||||
use regex::Regex;
|
||||
use smol::{fs, process};
|
||||
use std::{
|
||||
|
@ -170,7 +170,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
let label = &completion.label;
|
||||
|
@ -181,7 +181,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
let name_offset = label.rfind('.').unwrap_or(0);
|
||||
|
||||
match completion.kind.zip(completion.detail.as_ref()) {
|
||||
Some((lsp2::CompletionItemKind::MODULE, detail)) => {
|
||||
Some((lsp::CompletionItemKind::MODULE, detail)) => {
|
||||
let text = format!("{label} {detail}");
|
||||
let source = Rope::from(format!("import {text}").as_str());
|
||||
let runs = language.highlight_text(&source, 7..7 + text.len());
|
||||
|
@ -192,7 +192,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
});
|
||||
}
|
||||
Some((
|
||||
lsp2::CompletionItemKind::CONSTANT | lsp2::CompletionItemKind::VARIABLE,
|
||||
lsp::CompletionItemKind::CONSTANT | lsp::CompletionItemKind::VARIABLE,
|
||||
detail,
|
||||
)) => {
|
||||
let text = format!("{label} {detail}");
|
||||
|
@ -208,7 +208,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
filter_range: 0..label.len(),
|
||||
});
|
||||
}
|
||||
Some((lsp2::CompletionItemKind::STRUCT, _)) => {
|
||||
Some((lsp::CompletionItemKind::STRUCT, _)) => {
|
||||
let text = format!("{label} struct {{}}");
|
||||
let source = Rope::from(format!("type {}", &text[name_offset..]).as_str());
|
||||
let runs = adjust_runs(
|
||||
|
@ -221,7 +221,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
filter_range: 0..label.len(),
|
||||
});
|
||||
}
|
||||
Some((lsp2::CompletionItemKind::INTERFACE, _)) => {
|
||||
Some((lsp::CompletionItemKind::INTERFACE, _)) => {
|
||||
let text = format!("{label} interface {{}}");
|
||||
let source = Rope::from(format!("type {}", &text[name_offset..]).as_str());
|
||||
let runs = adjust_runs(
|
||||
|
@ -234,7 +234,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
filter_range: 0..label.len(),
|
||||
});
|
||||
}
|
||||
Some((lsp2::CompletionItemKind::FIELD, detail)) => {
|
||||
Some((lsp::CompletionItemKind::FIELD, detail)) => {
|
||||
let text = format!("{label} {detail}");
|
||||
let source =
|
||||
Rope::from(format!("type T struct {{ {} }}", &text[name_offset..]).as_str());
|
||||
|
@ -248,10 +248,7 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
filter_range: 0..label.len(),
|
||||
});
|
||||
}
|
||||
Some((
|
||||
lsp2::CompletionItemKind::FUNCTION | lsp2::CompletionItemKind::METHOD,
|
||||
detail,
|
||||
)) => {
|
||||
Some((lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD, detail)) => {
|
||||
if let Some(signature) = detail.strip_prefix("func") {
|
||||
let text = format!("{label}{signature}");
|
||||
let source = Rope::from(format!("func {} {{}}", &text[name_offset..]).as_str());
|
||||
|
@ -274,47 +271,47 @@ impl super::LspAdapter for GoLspAdapter {
|
|||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp2::SymbolKind,
|
||||
kind: lsp::SymbolKind,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
lsp2::SymbolKind::METHOD | lsp2::SymbolKind::FUNCTION => {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("func {} () {{}}", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::STRUCT => {
|
||||
lsp::SymbolKind::STRUCT => {
|
||||
let text = format!("type {} struct {{}}", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..text.len();
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::INTERFACE => {
|
||||
lsp::SymbolKind::INTERFACE => {
|
||||
let text = format!("type {} interface {{}}", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..text.len();
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::CLASS => {
|
||||
lsp::SymbolKind::CLASS => {
|
||||
let text = format!("type {} T", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::CONSTANT => {
|
||||
lsp::SymbolKind::CONSTANT => {
|
||||
let text = format!("const {} = nil", name);
|
||||
let filter_range = 6..6 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::VARIABLE => {
|
||||
lsp::SymbolKind::VARIABLE => {
|
||||
let text = format!("var {} = nil", name);
|
||||
let filter_range = 4..4 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::MODULE => {
|
||||
lsp::SymbolKind::MODULE => {
|
||||
let text = format!("package {}", name);
|
||||
let filter_range = 8..8 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
|
@ -375,10 +372,10 @@ fn adjust_runs(
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::languages::language;
|
||||
use gpui2::Hsla;
|
||||
use theme2::SyntaxTheme;
|
||||
use gpui::Hsla;
|
||||
use theme::SyntaxTheme;
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_go_label_for_completion() {
|
||||
let language = language(
|
||||
"go",
|
||||
|
@ -405,8 +402,8 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::FUNCTION),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::FUNCTION),
|
||||
label: "Hello".to_string(),
|
||||
detail: Some("func(a B) c.D".to_string()),
|
||||
..Default::default()
|
||||
|
@ -426,8 +423,8 @@ mod tests {
|
|||
// Nested methods
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::METHOD),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::METHOD),
|
||||
label: "one.two.Three".to_string(),
|
||||
detail: Some("func() [3]interface{}".to_string()),
|
||||
..Default::default()
|
||||
|
@ -447,8 +444,8 @@ mod tests {
|
|||
// Nested fields
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::FIELD),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::FIELD),
|
||||
label: "two.Three".to_string(),
|
||||
detail: Some("a.Bcd".to_string()),
|
||||
..Default::default()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::json;
|
||||
use smol::fs;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use collections::HashMap;
|
||||
use feature_flags2::FeatureFlagAppExt;
|
||||
use feature_flags::FeatureFlagAppExt;
|
||||
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
||||
use gpui2::AppContext;
|
||||
use language2::{LanguageRegistry, LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use gpui::AppContext;
|
||||
use language::{LanguageRegistry, LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::json;
|
||||
use settings2::{KeymapFile, SettingsJsonSchemaParams, SettingsStore};
|
||||
use settings::{KeymapFile, SettingsJsonSchemaParams, SettingsStore};
|
||||
use smol::fs;
|
||||
use std::{
|
||||
any::Any,
|
||||
|
|
|
@ -3,8 +3,8 @@ use async_compression::futures::bufread::GzipDecoder;
|
|||
use async_tar::Archive;
|
||||
use async_trait::async_trait;
|
||||
use futures::{io::BufReader, StreamExt};
|
||||
use language2::{LanguageServerName, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use smol::fs;
|
||||
use std::{any::Any, env::consts, path::PathBuf};
|
||||
use util::{
|
||||
|
|
|
@ -3,8 +3,8 @@ use anyhow::{anyhow, Result};
|
|||
use async_trait::async_trait;
|
||||
use collections::HashMap;
|
||||
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
|
||||
use smol::{fs, stream::StreamExt};
|
||||
|
@ -91,9 +91,9 @@ impl LspAdapter for IntelephenseLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
_item: &lsp2::CompletionItem,
|
||||
_language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
_item: &lsp::CompletionItem,
|
||||
_language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use smol::fs;
|
||||
use std::{
|
||||
|
@ -81,7 +81,7 @@ impl LspAdapter for PythonLspAdapter {
|
|||
get_cached_server_binary(container_dir, &*self.node).await
|
||||
}
|
||||
|
||||
async fn process_completion(&self, item: &mut lsp2::CompletionItem) {
|
||||
async fn process_completion(&self, item: &mut lsp::CompletionItem) {
|
||||
// Pyright assigns each completion item a `sortText` of the form `XX.YYYY.name`.
|
||||
// Where `XX` is the sorting category, `YYYY` is based on most recent usage,
|
||||
// and `name` is the symbol name itself.
|
||||
|
@ -104,19 +104,19 @@ impl LspAdapter for PythonLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
item: &lsp2::CompletionItem,
|
||||
language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
item: &lsp::CompletionItem,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let label = &item.label;
|
||||
let grammar = language.grammar()?;
|
||||
let highlight_id = match item.kind? {
|
||||
lsp2::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method")?,
|
||||
lsp2::CompletionItemKind::FUNCTION => grammar.highlight_id_for_name("function")?,
|
||||
lsp2::CompletionItemKind::CLASS => grammar.highlight_id_for_name("type")?,
|
||||
lsp2::CompletionItemKind::CONSTANT => grammar.highlight_id_for_name("constant")?,
|
||||
lsp::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method")?,
|
||||
lsp::CompletionItemKind::FUNCTION => grammar.highlight_id_for_name("function")?,
|
||||
lsp::CompletionItemKind::CLASS => grammar.highlight_id_for_name("type")?,
|
||||
lsp::CompletionItemKind::CONSTANT => grammar.highlight_id_for_name("constant")?,
|
||||
_ => return None,
|
||||
};
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text: label.clone(),
|
||||
runs: vec![(0..label.len(), highlight_id)],
|
||||
filter_range: 0..label.len(),
|
||||
|
@ -126,23 +126,23 @@ impl LspAdapter for PythonLspAdapter {
|
|||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp2::SymbolKind,
|
||||
language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
kind: lsp::SymbolKind,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
lsp2::SymbolKind::METHOD | lsp2::SymbolKind::FUNCTION => {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("def {}():\n", name);
|
||||
let filter_range = 4..4 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::CLASS => {
|
||||
lsp::SymbolKind::CLASS => {
|
||||
let text = format!("class {}:", name);
|
||||
let filter_range = 6..6 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::CONSTANT => {
|
||||
lsp::SymbolKind::CONSTANT => {
|
||||
let text = format!("{} = 0", name);
|
||||
let filter_range = 0..name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
|
@ -151,7 +151,7 @@ impl LspAdapter for PythonLspAdapter {
|
|||
_ => return None,
|
||||
};
|
||||
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
runs: language.highlight_text(&text.as_str().into(), display_range.clone()),
|
||||
text: text[display_range].to_string(),
|
||||
filter_range,
|
||||
|
@ -177,12 +177,12 @@ async fn get_cached_server_binary(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gpui2::{Context, ModelContext, TestAppContext};
|
||||
use language2::{language_settings::AllLanguageSettings, AutoindentMode, Buffer};
|
||||
use settings2::SettingsStore;
|
||||
use gpui::{Context, ModelContext, TestAppContext};
|
||||
use language::{language_settings::AllLanguageSettings, AutoindentMode, Buffer};
|
||||
use settings::SettingsStore;
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_python_autoindent(cx: &mut TestAppContext) {
|
||||
// cx.executor().set_block_on_ticks(usize::MAX..=usize::MAX);
|
||||
let language =
|
||||
|
@ -190,7 +190,7 @@ mod tests {
|
|||
cx.update(|cx| {
|
||||
let test_settings = SettingsStore::test(cx);
|
||||
cx.set_global(test_settings);
|
||||
language2::init(cx);
|
||||
language::init(cx);
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, |s| {
|
||||
s.defaults.tab_size = NonZeroU32::new(2);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use std::{any::Any, path::PathBuf, sync::Arc};
|
||||
|
||||
pub struct RubyLanguageServer;
|
||||
|
@ -53,25 +53,25 @@ impl LspAdapter for RubyLanguageServer {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
item: &lsp2::CompletionItem,
|
||||
language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
item: &lsp::CompletionItem,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let label = &item.label;
|
||||
let grammar = language.grammar()?;
|
||||
let highlight_id = match item.kind? {
|
||||
lsp2::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method")?,
|
||||
lsp2::CompletionItemKind::CONSTANT => grammar.highlight_id_for_name("constant")?,
|
||||
lsp2::CompletionItemKind::CLASS | lsp2::CompletionItemKind::MODULE => {
|
||||
lsp::CompletionItemKind::METHOD => grammar.highlight_id_for_name("function.method")?,
|
||||
lsp::CompletionItemKind::CONSTANT => grammar.highlight_id_for_name("constant")?,
|
||||
lsp::CompletionItemKind::CLASS | lsp::CompletionItemKind::MODULE => {
|
||||
grammar.highlight_id_for_name("type")?
|
||||
}
|
||||
lsp2::CompletionItemKind::KEYWORD => {
|
||||
lsp::CompletionItemKind::KEYWORD => {
|
||||
if label.starts_with(':') {
|
||||
grammar.highlight_id_for_name("string.special.symbol")?
|
||||
} else {
|
||||
grammar.highlight_id_for_name("keyword")?
|
||||
}
|
||||
}
|
||||
lsp2::CompletionItemKind::VARIABLE => {
|
||||
lsp::CompletionItemKind::VARIABLE => {
|
||||
if label.starts_with('@') {
|
||||
grammar.highlight_id_for_name("property")?
|
||||
} else {
|
||||
|
@ -80,7 +80,7 @@ impl LspAdapter for RubyLanguageServer {
|
|||
}
|
||||
_ => return None,
|
||||
};
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text: label.clone(),
|
||||
runs: vec![(0..label.len(), highlight_id)],
|
||||
filter_range: 0..label.len(),
|
||||
|
@ -90,12 +90,12 @@ impl LspAdapter for RubyLanguageServer {
|
|||
async fn label_for_symbol(
|
||||
&self,
|
||||
label: &str,
|
||||
kind: lsp2::SymbolKind,
|
||||
language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
kind: lsp::SymbolKind,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
let grammar = language.grammar()?;
|
||||
match kind {
|
||||
lsp2::SymbolKind::METHOD => {
|
||||
lsp::SymbolKind::METHOD => {
|
||||
let mut parts = label.split('#');
|
||||
let classes = parts.next()?;
|
||||
let method = parts.next()?;
|
||||
|
@ -120,21 +120,21 @@ impl LspAdapter for RubyLanguageServer {
|
|||
ix += 1;
|
||||
let end_ix = ix + method.len();
|
||||
runs.push((ix..end_ix, method_id));
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text: label.to_string(),
|
||||
runs,
|
||||
filter_range: 0..label.len(),
|
||||
})
|
||||
}
|
||||
lsp2::SymbolKind::CONSTANT => {
|
||||
lsp::SymbolKind::CONSTANT => {
|
||||
let constant_id = grammar.highlight_id_for_name("constant")?;
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text: label.to_string(),
|
||||
runs: vec![(0..label.len(), constant_id)],
|
||||
filter_range: 0..label.len(),
|
||||
})
|
||||
}
|
||||
lsp2::SymbolKind::CLASS | lsp2::SymbolKind::MODULE => {
|
||||
lsp::SymbolKind::CLASS | lsp::SymbolKind::MODULE => {
|
||||
let class_id = grammar.highlight_id_for_name("type")?;
|
||||
|
||||
let mut ix = 0;
|
||||
|
@ -148,7 +148,7 @@ impl LspAdapter for RubyLanguageServer {
|
|||
ix = end_ix;
|
||||
}
|
||||
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text: label.to_string(),
|
||||
runs,
|
||||
filter_range: 0..label.len(),
|
||||
|
|
|
@ -2,9 +2,9 @@ use anyhow::{anyhow, Result};
|
|||
use async_compression::futures::bufread::GzipDecoder;
|
||||
use async_trait::async_trait;
|
||||
use futures::{io::BufReader, StreamExt};
|
||||
pub use language2::*;
|
||||
pub use language::*;
|
||||
use lazy_static::lazy_static;
|
||||
use lsp2::LanguageServerBinary;
|
||||
use lsp::LanguageServerBinary;
|
||||
use regex::Regex;
|
||||
use smol::fs::{self, File};
|
||||
use std::{any::Any, borrow::Cow, env::consts, path::PathBuf, str, sync::Arc};
|
||||
|
@ -106,7 +106,7 @@ impl LspAdapter for RustLspAdapter {
|
|||
Some("rust-analyzer/flycheck".into())
|
||||
}
|
||||
|
||||
fn process_diagnostics(&self, params: &mut lsp2::PublishDiagnosticsParams) {
|
||||
fn process_diagnostics(&self, params: &mut lsp::PublishDiagnosticsParams) {
|
||||
lazy_static! {
|
||||
static ref REGEX: Regex = Regex::new("(?m)`([^`]+)\n`$").unwrap();
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ impl LspAdapter for RustLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
completion: &lsp2::CompletionItem,
|
||||
completion: &lsp::CompletionItem,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
match completion.kind {
|
||||
Some(lsp2::CompletionItemKind::FIELD) if completion.detail.is_some() => {
|
||||
Some(lsp::CompletionItemKind::FIELD) if completion.detail.is_some() => {
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
let name = &completion.label;
|
||||
let text = format!("{}: {}", name, detail);
|
||||
|
@ -144,9 +144,9 @@ impl LspAdapter for RustLspAdapter {
|
|||
filter_range: 0..name.len(),
|
||||
});
|
||||
}
|
||||
Some(lsp2::CompletionItemKind::CONSTANT | lsp2::CompletionItemKind::VARIABLE)
|
||||
Some(lsp::CompletionItemKind::CONSTANT | lsp::CompletionItemKind::VARIABLE)
|
||||
if completion.detail.is_some()
|
||||
&& completion.insert_text_format != Some(lsp2::InsertTextFormat::SNIPPET) =>
|
||||
&& completion.insert_text_format != Some(lsp::InsertTextFormat::SNIPPET) =>
|
||||
{
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
let name = &completion.label;
|
||||
|
@ -159,7 +159,7 @@ impl LspAdapter for RustLspAdapter {
|
|||
filter_range: 0..name.len(),
|
||||
});
|
||||
}
|
||||
Some(lsp2::CompletionItemKind::FUNCTION | lsp2::CompletionItemKind::METHOD)
|
||||
Some(lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD)
|
||||
if completion.detail.is_some() =>
|
||||
{
|
||||
lazy_static! {
|
||||
|
@ -188,12 +188,12 @@ impl LspAdapter for RustLspAdapter {
|
|||
}
|
||||
Some(kind) => {
|
||||
let highlight_name = match kind {
|
||||
lsp2::CompletionItemKind::STRUCT
|
||||
| lsp2::CompletionItemKind::INTERFACE
|
||||
| lsp2::CompletionItemKind::ENUM => Some("type"),
|
||||
lsp2::CompletionItemKind::ENUM_MEMBER => Some("variant"),
|
||||
lsp2::CompletionItemKind::KEYWORD => Some("keyword"),
|
||||
lsp2::CompletionItemKind::VALUE | lsp2::CompletionItemKind::CONSTANT => {
|
||||
lsp::CompletionItemKind::STRUCT
|
||||
| lsp::CompletionItemKind::INTERFACE
|
||||
| lsp::CompletionItemKind::ENUM => Some("type"),
|
||||
lsp::CompletionItemKind::ENUM_MEMBER => Some("variant"),
|
||||
lsp::CompletionItemKind::KEYWORD => Some("keyword"),
|
||||
lsp::CompletionItemKind::VALUE | lsp::CompletionItemKind::CONSTANT => {
|
||||
Some("constant")
|
||||
}
|
||||
_ => None,
|
||||
|
@ -214,47 +214,47 @@ impl LspAdapter for RustLspAdapter {
|
|||
async fn label_for_symbol(
|
||||
&self,
|
||||
name: &str,
|
||||
kind: lsp2::SymbolKind,
|
||||
kind: lsp::SymbolKind,
|
||||
language: &Arc<Language>,
|
||||
) -> Option<CodeLabel> {
|
||||
let (text, filter_range, display_range) = match kind {
|
||||
lsp2::SymbolKind::METHOD | lsp2::SymbolKind::FUNCTION => {
|
||||
lsp::SymbolKind::METHOD | lsp::SymbolKind::FUNCTION => {
|
||||
let text = format!("fn {} () {{}}", name);
|
||||
let filter_range = 3..3 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::STRUCT => {
|
||||
lsp::SymbolKind::STRUCT => {
|
||||
let text = format!("struct {} {{}}", name);
|
||||
let filter_range = 7..7 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::ENUM => {
|
||||
lsp::SymbolKind::ENUM => {
|
||||
let text = format!("enum {} {{}}", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::INTERFACE => {
|
||||
lsp::SymbolKind::INTERFACE => {
|
||||
let text = format!("trait {} {{}}", name);
|
||||
let filter_range = 6..6 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::CONSTANT => {
|
||||
lsp::SymbolKind::CONSTANT => {
|
||||
let text = format!("const {}: () = ();", name);
|
||||
let filter_range = 6..6 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::MODULE => {
|
||||
lsp::SymbolKind::MODULE => {
|
||||
let text = format!("mod {} {{}}", name);
|
||||
let filter_range = 4..4 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
(text, filter_range, display_range)
|
||||
}
|
||||
lsp2::SymbolKind::TYPE_PARAMETER => {
|
||||
lsp::SymbolKind::TYPE_PARAMETER => {
|
||||
let text = format!("type {} {{}}", name);
|
||||
let filter_range = 5..5 + name.len();
|
||||
let display_range = 0..filter_range.end;
|
||||
|
@ -294,29 +294,29 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
use crate::languages::language;
|
||||
use gpui2::{Context, Hsla, TestAppContext};
|
||||
use language2::language_settings::AllLanguageSettings;
|
||||
use settings2::SettingsStore;
|
||||
use theme2::SyntaxTheme;
|
||||
use gpui::{Context, Hsla, TestAppContext};
|
||||
use language::language_settings::AllLanguageSettings;
|
||||
use settings::SettingsStore;
|
||||
use theme::SyntaxTheme;
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_process_rust_diagnostics() {
|
||||
let mut params = lsp2::PublishDiagnosticsParams {
|
||||
uri: lsp2::Url::from_file_path("/a").unwrap(),
|
||||
let mut params = lsp::PublishDiagnosticsParams {
|
||||
uri: lsp::Url::from_file_path("/a").unwrap(),
|
||||
version: None,
|
||||
diagnostics: vec![
|
||||
// no newlines
|
||||
lsp2::Diagnostic {
|
||||
lsp::Diagnostic {
|
||||
message: "use of moved value `a`".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
// newline at the end of a code span
|
||||
lsp2::Diagnostic {
|
||||
lsp::Diagnostic {
|
||||
message: "consider importing this struct: `use b::c;\n`".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
// code span starting right after a newline
|
||||
lsp2::Diagnostic {
|
||||
lsp::Diagnostic {
|
||||
message: "cannot borrow `self.d` as mutable\n`self` is a `&` reference"
|
||||
.to_string(),
|
||||
..Default::default()
|
||||
|
@ -340,7 +340,7 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_rust_label_for_completion() {
|
||||
let language = language(
|
||||
"rust",
|
||||
|
@ -365,8 +365,8 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::FUNCTION),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::FUNCTION),
|
||||
label: "hello(…)".to_string(),
|
||||
detail: Some("fn(&mut Option<T>) -> Vec<T>".to_string()),
|
||||
..Default::default()
|
||||
|
@ -387,8 +387,8 @@ mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::FUNCTION),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::FUNCTION),
|
||||
label: "hello(…)".to_string(),
|
||||
detail: Some("async fn(&mut Option<T>) -> Vec<T>".to_string()),
|
||||
..Default::default()
|
||||
|
@ -409,8 +409,8 @@ mod tests {
|
|||
);
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::FIELD),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::FIELD),
|
||||
label: "len".to_string(),
|
||||
detail: Some("usize".to_string()),
|
||||
..Default::default()
|
||||
|
@ -425,8 +425,8 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_completion(&lsp2::CompletionItem {
|
||||
kind: Some(lsp2::CompletionItemKind::FUNCTION),
|
||||
.label_for_completion(&lsp::CompletionItem {
|
||||
kind: Some(lsp::CompletionItemKind::FUNCTION),
|
||||
label: "hello(…)".to_string(),
|
||||
detail: Some("fn(&mut Option<T>) -> Vec<T>".to_string()),
|
||||
..Default::default()
|
||||
|
@ -447,7 +447,7 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_rust_label_for_symbol() {
|
||||
let language = language(
|
||||
"rust",
|
||||
|
@ -471,7 +471,7 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_symbol("hello", lsp2::SymbolKind::FUNCTION)
|
||||
.label_for_symbol("hello", lsp::SymbolKind::FUNCTION)
|
||||
.await,
|
||||
Some(CodeLabel {
|
||||
text: "fn hello".to_string(),
|
||||
|
@ -482,7 +482,7 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
language
|
||||
.label_for_symbol("World", lsp2::SymbolKind::TYPE_PARAMETER)
|
||||
.label_for_symbol("World", lsp::SymbolKind::TYPE_PARAMETER)
|
||||
.await,
|
||||
Some(CodeLabel {
|
||||
text: "type World".to_string(),
|
||||
|
@ -492,13 +492,13 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_rust_autoindent(cx: &mut TestAppContext) {
|
||||
// cx.executor().set_block_on_ticks(usize::MAX..=usize::MAX);
|
||||
cx.update(|cx| {
|
||||
let test_settings = SettingsStore::test(cx);
|
||||
cx.set_global(test_settings);
|
||||
language2::init(cx);
|
||||
language::init(cx);
|
||||
cx.update_global::<SettingsStore, _>(|store, cx| {
|
||||
store.update_user_settings::<AllLanguageSettings>(cx, |s| {
|
||||
s.defaults.tab_size = NonZeroU32::new(2);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::json;
|
||||
use smol::fs;
|
||||
|
|
|
@ -5,9 +5,9 @@ use futures::{
|
|||
future::{self, BoxFuture},
|
||||
FutureExt, StreamExt,
|
||||
};
|
||||
use gpui2::AppContext;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use gpui::AppContext;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::{json, Value};
|
||||
use smol::fs;
|
||||
|
|
|
@ -3,9 +3,9 @@ use async_compression::futures::bufread::GzipDecoder;
|
|||
use async_tar::Archive;
|
||||
use async_trait::async_trait;
|
||||
use futures::{future::BoxFuture, FutureExt};
|
||||
use gpui2::AppContext;
|
||||
use language2::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp2::{CodeActionKind, LanguageServerBinary};
|
||||
use gpui::AppContext;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::{CodeActionKind, LanguageServerBinary};
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::{json, Value};
|
||||
use smol::{fs, io::BufReader, stream::StreamExt};
|
||||
|
@ -129,10 +129,10 @@ impl LspAdapter for TypeScriptLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
item: &lsp2::CompletionItem,
|
||||
language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
use lsp2::CompletionItemKind as Kind;
|
||||
item: &lsp::CompletionItem,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
use lsp::CompletionItemKind as Kind;
|
||||
let len = item.label.len();
|
||||
let grammar = language.grammar()?;
|
||||
let highlight_id = match item.kind? {
|
||||
|
@ -149,7 +149,7 @@ impl LspAdapter for TypeScriptLspAdapter {
|
|||
None => item.label.clone(),
|
||||
};
|
||||
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text,
|
||||
runs: vec![(0..len, highlight_id)],
|
||||
filter_range: 0..len,
|
||||
|
@ -300,9 +300,9 @@ impl LspAdapter for EsLintLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
_item: &lsp2::CompletionItem,
|
||||
_language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
_item: &lsp::CompletionItem,
|
||||
_language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -335,10 +335,10 @@ async fn get_cached_eslint_server_binary(
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use gpui2::{Context, TestAppContext};
|
||||
use gpui::{Context, TestAppContext};
|
||||
use unindent::Unindent;
|
||||
|
||||
#[gpui2::test]
|
||||
#[gpui::test]
|
||||
async fn test_outline(cx: &mut TestAppContext) {
|
||||
let language = crate::languages::language(
|
||||
"typescript",
|
||||
|
@ -363,7 +363,7 @@ mod tests {
|
|||
.unindent();
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
language2::Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
language::Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
let outline = buffer.update(cx, |buffer, _| buffer.snapshot().outline(None).unwrap());
|
||||
assert_eq!(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use anyhow::{anyhow, ensure, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::StreamExt;
|
||||
pub use language2::*;
|
||||
use lsp2::{CodeActionKind, LanguageServerBinary};
|
||||
pub use language::*;
|
||||
use lsp::{CodeActionKind, LanguageServerBinary};
|
||||
use node_runtime::NodeRuntime;
|
||||
use parking_lot::Mutex;
|
||||
use serde_json::Value;
|
||||
|
@ -148,10 +148,10 @@ impl super::LspAdapter for VueLspAdapter {
|
|||
|
||||
async fn label_for_completion(
|
||||
&self,
|
||||
item: &lsp2::CompletionItem,
|
||||
language: &Arc<language2::Language>,
|
||||
) -> Option<language2::CodeLabel> {
|
||||
use lsp2::CompletionItemKind as Kind;
|
||||
item: &lsp::CompletionItem,
|
||||
language: &Arc<language::Language>,
|
||||
) -> Option<language::CodeLabel> {
|
||||
use lsp::CompletionItemKind as Kind;
|
||||
let len = item.label.len();
|
||||
let grammar = language.grammar()?;
|
||||
let highlight_id = match item.kind? {
|
||||
|
@ -171,7 +171,7 @@ impl super::LspAdapter for VueLspAdapter {
|
|||
None => item.label.clone(),
|
||||
};
|
||||
|
||||
Some(language2::CodeLabel {
|
||||
Some(language::CodeLabel {
|
||||
text,
|
||||
runs: vec![(0..len, highlight_id)],
|
||||
filter_range: 0..len,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
||||
use gpui2::AppContext;
|
||||
use language2::{
|
||||
use gpui::AppContext;
|
||||
use language::{
|
||||
language_settings::all_language_settings, LanguageServerName, LspAdapter, LspAdapterDelegate,
|
||||
};
|
||||
use lsp2::LanguageServerBinary;
|
||||
use lsp::LanguageServerBinary;
|
||||
use node_runtime::NodeRuntime;
|
||||
use serde_json::Value;
|
||||
use smol::fs;
|
||||
|
|
|
@ -8,19 +8,19 @@ use cli::{
|
|||
ipc::{self, IpcSender},
|
||||
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
||||
};
|
||||
use client2::UserStore;
|
||||
use db2::kvp::KEY_VALUE_STORE;
|
||||
use fs2::RealFs;
|
||||
use client::UserStore;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use fs::RealFs;
|
||||
use futures::{channel::mpsc, SinkExt, StreamExt};
|
||||
use gpui2::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
|
||||
use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
|
||||
use isahc::{prelude::Configurable, Request};
|
||||
use language2::LanguageRegistry;
|
||||
use language::LanguageRegistry;
|
||||
use log::LevelFilter;
|
||||
|
||||
use node_runtime::RealNodeRuntime;
|
||||
use parking_lot::Mutex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings2::{
|
||||
use settings::{
|
||||
default_settings, handle_settings_file_changes, watch_config_file, Settings, SettingsStore,
|
||||
};
|
||||
use simplelog::ConfigBuilder;
|
||||
|
@ -116,7 +116,7 @@ fn main() {
|
|||
handle_settings_file_changes(user_settings_file_rx, cx);
|
||||
// handle_keymap_file_changes(user_keymap_file_rx, cx);
|
||||
|
||||
let client = client2::Client::new(http.clone(), cx);
|
||||
let client = client::Client::new(http.clone(), cx);
|
||||
let mut languages = LanguageRegistry::new(login_shell_env_loaded);
|
||||
let copilot_language_server_id = languages.next_language_server_id();
|
||||
languages.set_executor(cx.background_executor().clone());
|
||||
|
@ -124,19 +124,19 @@ fn main() {
|
|||
let languages = Arc::new(languages);
|
||||
let node_runtime = RealNodeRuntime::new(http.clone());
|
||||
|
||||
language2::init(cx);
|
||||
language::init(cx);
|
||||
languages::init(languages.clone(), node_runtime.clone(), cx);
|
||||
let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
|
||||
let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
|
||||
cx.set_global(client.clone());
|
||||
|
||||
theme2::init(cx);
|
||||
theme::init(cx);
|
||||
// context_menu::init(cx);
|
||||
project2::Project::init(&client, cx);
|
||||
client2::init(&client, cx);
|
||||
project::Project::init(&client, cx);
|
||||
client::init(&client, cx);
|
||||
// command_palette::init(cx);
|
||||
language2::init(cx);
|
||||
language::init(cx);
|
||||
// editor::init(cx);
|
||||
// go_to_line::init(cx);
|
||||
// file_finder::init(cx);
|
||||
|
@ -149,7 +149,7 @@ fn main() {
|
|||
// semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
|
||||
// vim::init(cx);
|
||||
// terminal_view::init(cx);
|
||||
copilot2::init(
|
||||
copilot::init(
|
||||
copilot_language_server_id,
|
||||
http.clone(),
|
||||
node_runtime.clone(),
|
||||
|
@ -196,7 +196,7 @@ fn main() {
|
|||
// theme_selector::init(cx);
|
||||
// activity_indicator::init(cx);
|
||||
// language_tools::init(cx);
|
||||
call2::init(app_state.client.clone(), app_state.user_store.clone(), cx);
|
||||
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
|
||||
// collab_ui::init(&app_state, cx);
|
||||
// feedback::init(cx);
|
||||
// welcome::init(cx);
|
||||
|
@ -451,7 +451,7 @@ fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: Strin
|
|||
std::process::exit(-1);
|
||||
}
|
||||
|
||||
let app_version = client2::ZED_APP_VERSION
|
||||
let app_version = client::ZED_APP_VERSION
|
||||
.or(app_metadata.app_version)
|
||||
.map_or("dev".to_string(), |v| v.to_string());
|
||||
|
||||
|
@ -519,11 +519,11 @@ fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: Strin
|
|||
}
|
||||
|
||||
fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
|
||||
let telemetry_settings = *client2::TelemetrySettings::get_global(cx);
|
||||
let telemetry_settings = *client::TelemetrySettings::get_global(cx);
|
||||
|
||||
cx.background_executor()
|
||||
.spawn(async move {
|
||||
let panic_report_url = format!("{}/api/panic", &*client2::ZED_SERVER_URL);
|
||||
let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);
|
||||
let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
|
||||
while let Some(child) = children.next().await {
|
||||
let child = child?;
|
||||
|
@ -566,7 +566,7 @@ fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
|
|||
if let Some(panic) = panic {
|
||||
let body = serde_json::to_string(&PanicRequest {
|
||||
panic,
|
||||
token: client2::ZED_SECRET_CLIENT_TOKEN.into(),
|
||||
token: client::ZED_SECRET_CLIENT_TOKEN.into(),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ mod open_listener;
|
|||
|
||||
pub use assets::*;
|
||||
use collections::HashMap;
|
||||
use gpui2::{
|
||||
use client::{Client, UserStore};
|
||||
use gpui::{
|
||||
point, px, AppContext, AsyncAppContext, AsyncWindowContext, Point, Task, TitlebarOptions,
|
||||
WeakView, WindowBounds, WindowKind, WindowOptions,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue