@@ -851,31 +851,35 @@ pub fn completion(cx: &mut Context) {
851851 .timeout(Duration::from_secs(2)),
852852 )
853853 .expect("completion failed!")
854− .expect("completion failed!");
854+ .unwrap_or_default(); // if timeout, just return
855+
856+ // TODO: if no completion, show some message or something
857+ if !res.is_empty() {
858+ let picker = ui::Picker::new(
859+ res,
860+ |item| {
861+ // format_fn
862+ item.label.as_str().into()
863+
864+ // TODO: use item.filter_text for filtering
865+ },
866+ |editor: &mut Editor, item| {
867+ // if item.text_edit is Some we use that, else
868+ // let insert_text = &item.insert_text.unwrap_or(item.label);
869+ // and we insert at position.
870+ //
871+ // merge this with additional_text_edits
872+ },
873+ );
855874
856− let picker = ui::Picker::new(
857− res,
858− |item| {
859− // format_fn
860− item.label.as_str().into()
875+ cx.callback = Some(Box::new(
876+ move |compositor: &mut Compositor, editor: &mut Editor| {
877+ compositor.push(Box::new(picker));
878+ },
879+ ));
861880
862− // TODO: use item.filter_text for filtering
863− },
864− |editor: &mut Editor, item| {
865− // if item.text_edit is Some we use that, else
866− // let insert_text = &item.insert_text.unwrap_or(item.label);
867− // and we insert at position.
868− //
869− // merge this with additional_text_edits
870− },
871− );
881+ // TODO!: when iterating over items, show the docs in popup
872882
873− cx.callback = Some(Box::new(
874− move |compositor: &mut Compositor, editor: &mut Editor| {
875− compositor.push(Box::new(picker));
876− },
877− ));
878−
879− // TODO: when iterating over items, show the docs in popup
880− // language server client needs to be accessible via a registry of some sort
883+ // language server client needs to be accessible via a registry of some sort
884+ }
881885}