Add experimental LSP-based context retrieval system for edit prediction (#44036)
To do * [x] Default to no context retrieval. Allow opting in to LSP-based retrieval via a setting (for users in `zeta2` feature flag) * [x] Feed this context to models when enabled * [x] Make the zeta2 context view work well with LSP retrieval * [x] Add a UI for the setting (for feature-flagged users) * [x] Ensure Zeta CLI `context` command is usable --- * [ ] Filter out LSP definitions that are too large / entire files (e.g. modules) * [ ] Introduce timeouts * [ ] Test with other LSPs * [ ] Figure out hangs Release Notes: - N/A --------- Co-authored-by: Ben Kunkle <ben@zed.dev> Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
co-authored by
Ben Kunkle
Agus Zubiaga
parent
cd8679e81a
commit
76167109db
@@ -485,6 +485,7 @@ pub struct Table<const COLS: usize = 3> {
|
||||
interaction_state: Option<WeakEntity<TableInteractionState>>,
|
||||
col_widths: Option<TableWidths<COLS>>,
|
||||
map_row: Option<Rc<dyn Fn((usize, Stateful<Div>), &mut Window, &mut App) -> AnyElement>>,
|
||||
use_ui_font: bool,
|
||||
empty_table_callback: Option<Rc<dyn Fn(&mut Window, &mut App) -> AnyElement>>,
|
||||
}
|
||||
|
||||
@@ -498,6 +499,7 @@ impl<const COLS: usize> Table<COLS> {
|
||||
rows: TableContents::Vec(Vec::new()),
|
||||
interaction_state: None,
|
||||
map_row: None,
|
||||
use_ui_font: true,
|
||||
empty_table_callback: None,
|
||||
col_widths: None,
|
||||
}
|
||||
@@ -590,6 +592,11 @@ impl<const COLS: usize> Table<COLS> {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn no_ui_font(mut self) -> Self {
|
||||
self.use_ui_font = false;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn map_row(
|
||||
mut self,
|
||||
callback: impl Fn((usize, Stateful<Div>), &mut Window, &mut App) -> AnyElement + 'static,
|
||||
@@ -618,8 +625,8 @@ fn base_cell_style(width: Option<Length>) -> Div {
|
||||
.overflow_hidden()
|
||||
}
|
||||
|
||||
fn base_cell_style_text(width: Option<Length>, cx: &App) -> Div {
|
||||
base_cell_style(width).text_ui(cx)
|
||||
fn base_cell_style_text(width: Option<Length>, use_ui_font: bool, cx: &App) -> Div {
|
||||
base_cell_style(width).when(use_ui_font, |el| el.text_ui(cx))
|
||||
}
|
||||
|
||||
pub fn render_table_row<const COLS: usize>(
|
||||
@@ -656,7 +663,12 @@ pub fn render_table_row<const COLS: usize>(
|
||||
.map(IntoElement::into_any_element)
|
||||
.into_iter()
|
||||
.zip(column_widths)
|
||||
.map(|(cell, width)| base_cell_style_text(width, cx).px_1().py_0p5().child(cell)),
|
||||
.map(|(cell, width)| {
|
||||
base_cell_style_text(width, table_context.use_ui_font, cx)
|
||||
.px_1()
|
||||
.py_0p5()
|
||||
.child(cell)
|
||||
}),
|
||||
);
|
||||
|
||||
let row = if let Some(map_row) = table_context.map_row {
|
||||
@@ -700,7 +712,7 @@ pub fn render_table_header<const COLS: usize>(
|
||||
.border_color(cx.theme().colors().border)
|
||||
.children(headers.into_iter().enumerate().zip(column_widths).map(
|
||||
|((header_idx, h), width)| {
|
||||
base_cell_style_text(width, cx)
|
||||
base_cell_style_text(width, table_context.use_ui_font, cx)
|
||||
.child(h)
|
||||
.id(ElementId::NamedInteger(
|
||||
shared_element_id.clone(),
|
||||
@@ -739,6 +751,7 @@ pub struct TableRenderContext<const COLS: usize> {
|
||||
pub total_row_count: usize,
|
||||
pub column_widths: Option<[Length; COLS]>,
|
||||
pub map_row: Option<Rc<dyn Fn((usize, Stateful<Div>), &mut Window, &mut App) -> AnyElement>>,
|
||||
pub use_ui_font: bool,
|
||||
}
|
||||
|
||||
impl<const COLS: usize> TableRenderContext<COLS> {
|
||||
@@ -748,6 +761,7 @@ impl<const COLS: usize> TableRenderContext<COLS> {
|
||||
total_row_count: table.rows.len(),
|
||||
column_widths: table.col_widths.as_ref().map(|widths| widths.lengths(cx)),
|
||||
map_row: table.map_row.clone(),
|
||||
use_ui_font: table.use_ui_font,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user