Introduce staff-only inline completion provider (#21739)
Release Notes: - N/A --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com> Co-authored-by: Bennet <bennet@zed.dev> Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
parent
39e8944dcc
commit
77b8296fbb
39 changed files with 2890 additions and 356 deletions
|
@ -126,6 +126,7 @@ vim_mode_setting.workspace = true
|
|||
welcome.workspace = true
|
||||
workspace.workspace = true
|
||||
zed_actions.workspace = true
|
||||
zeta.workspace = true
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
windows.workspace = true
|
||||
|
|
|
@ -399,7 +399,7 @@ fn main() {
|
|||
cx,
|
||||
);
|
||||
snippet_provider::init(cx);
|
||||
inline_completion_registry::init(app_state.client.telemetry().clone(), cx);
|
||||
inline_completion_registry::init(app_state.client.clone(), cx);
|
||||
let prompt_builder = assistant::init(
|
||||
app_state.fs.clone(),
|
||||
app_state.client.clone(),
|
||||
|
|
|
@ -197,7 +197,7 @@ pub fn initialize_workspace(
|
|||
}
|
||||
|
||||
let inline_completion_button = cx.new_view(|cx| {
|
||||
inline_completion_button::InlineCompletionButton::new(app_state.fs.clone(), cx)
|
||||
inline_completion_button::InlineCompletionButton::new(workspace.weak_handle(), app_state.fs.clone(), cx)
|
||||
});
|
||||
|
||||
let diagnostic_summary =
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
|
||||
use client::telemetry::Telemetry;
|
||||
use client::Client;
|
||||
use collections::HashMap;
|
||||
use copilot::{Copilot, CopilotCompletionProvider};
|
||||
use editor::{Editor, EditorMode};
|
||||
use feature_flags::FeatureFlagAppExt;
|
||||
use gpui::{AnyWindowHandle, AppContext, Context, ViewContext, WeakView};
|
||||
use language::language_settings::all_language_settings;
|
||||
use settings::SettingsStore;
|
||||
use supermaven::{Supermaven, SupermavenCompletionProvider};
|
||||
|
||||
pub fn init(telemetry: Arc<Telemetry>, cx: &mut AppContext) {
|
||||
pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
||||
let editors: Rc<RefCell<HashMap<WeakView<Editor>, AnyWindowHandle>>> = Rc::default();
|
||||
cx.observe_new_views({
|
||||
let editors = editors.clone();
|
||||
let telemetry = telemetry.clone();
|
||||
let client = client.clone();
|
||||
move |editor: &mut Editor, cx: &mut ViewContext<Editor>| {
|
||||
if editor.mode() != EditorMode::Full {
|
||||
return;
|
||||
|
@ -34,7 +35,7 @@ pub fn init(telemetry: Arc<Telemetry>, cx: &mut AppContext) {
|
|||
.borrow_mut()
|
||||
.insert(editor_handle, cx.window_handle());
|
||||
let provider = all_language_settings(None, cx).inline_completions.provider;
|
||||
assign_inline_completion_provider(editor, provider, &telemetry, cx);
|
||||
assign_inline_completion_provider(editor, provider, &client, cx);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
|
@ -43,7 +44,7 @@ pub fn init(telemetry: Arc<Telemetry>, cx: &mut AppContext) {
|
|||
for (editor, window) in editors.borrow().iter() {
|
||||
_ = window.update(cx, |_window, cx| {
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
assign_inline_completion_provider(editor, provider, &telemetry, cx);
|
||||
assign_inline_completion_provider(editor, provider, &client, cx);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -55,7 +56,7 @@ pub fn init(telemetry: Arc<Telemetry>, cx: &mut AppContext) {
|
|||
for (editor, window) in editors.borrow().iter() {
|
||||
_ = window.update(cx, |_window, cx| {
|
||||
_ = editor.update(cx, |editor, cx| {
|
||||
assign_inline_completion_provider(editor, provider, &telemetry, cx);
|
||||
assign_inline_completion_provider(editor, provider, &client, cx);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ fn register_backward_compatible_actions(editor: &mut Editor, cx: &ViewContext<Ed
|
|||
fn assign_inline_completion_provider(
|
||||
editor: &mut Editor,
|
||||
provider: language::language_settings::InlineCompletionProvider,
|
||||
telemetry: &Arc<Telemetry>,
|
||||
client: &Arc<Client>,
|
||||
cx: &mut ViewContext<Editor>,
|
||||
) {
|
||||
match provider {
|
||||
|
@ -117,17 +118,27 @@ fn assign_inline_completion_provider(
|
|||
});
|
||||
}
|
||||
}
|
||||
let provider = cx.new_model(|_| {
|
||||
CopilotCompletionProvider::new(copilot).with_telemetry(telemetry.clone())
|
||||
});
|
||||
let provider = cx.new_model(|_| CopilotCompletionProvider::new(copilot));
|
||||
editor.set_inline_completion_provider(Some(provider), cx);
|
||||
}
|
||||
}
|
||||
language::language_settings::InlineCompletionProvider::Supermaven => {
|
||||
if let Some(supermaven) = Supermaven::global(cx) {
|
||||
let provider = cx.new_model(|_| {
|
||||
SupermavenCompletionProvider::new(supermaven).with_telemetry(telemetry.clone())
|
||||
});
|
||||
let provider = cx.new_model(|_| SupermavenCompletionProvider::new(supermaven));
|
||||
editor.set_inline_completion_provider(Some(provider), cx);
|
||||
}
|
||||
}
|
||||
language::language_settings::InlineCompletionProvider::Zeta => {
|
||||
if cx.is_staff() {
|
||||
let zeta = zeta::Zeta::register(client.clone(), cx);
|
||||
if let Some(buffer) = editor.buffer().read(cx).as_singleton() {
|
||||
if buffer.read(cx).file().is_some() {
|
||||
zeta.update(cx, |zeta, cx| {
|
||||
zeta.register_buffer(&buffer, cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
let provider = cx.new_model(|_| zeta::ZetaInlineCompletionProvider::new(zeta));
|
||||
editor.set_inline_completion_provider(Some(provider), cx);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue