Skip to content

Commit

Permalink
Improved completion for variable definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
cutsoy committed Jan 15, 2023
1 parent 00d427a commit 030cb55
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions litho-lsp/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,6 @@ impl<'a> CompletionVisitor<'a> {

let name = match ty {
Type::List(_) => {
// items.push(CompletionItem {
// label: "[".to_owned(),
// label_details: Some(CompletionItemLabelDetails {
// detail: Some("...]".to_owned()),
// description: None,
// }),
// insert_text: Some("[${0}]".to_owned()),
// insert_text_format: Some(InsertTextFormat::SNIPPET),
// kind: Some(CompletionItemKind::OPERATOR),
// ..Default::default()
// });

return items.into_iter();
}
ty => match ty.name() {
Expand Down Expand Up @@ -460,4 +448,22 @@ impl<'a> Visit<'a, SmolStr> for CompletionVisitor<'a> {
_ => {}
}
}

fn visit_variable_definitions(
&self,
node: &'a VariableDefinitions<SmolStr>,
accumulator: &mut Self::Accumulator,
) {
if !node.parens.span().contains(self.offset) {
return;
}

for definition in node.variable_definitions.iter() {
if !definition.colon.span().before(self.offset) {
continue;
}

accumulator.extend(self.complete_all_types(true));
}
}
}

0 comments on commit 030cb55

Please sign in to comment.