Skip to content

Commit 1c8a2d9

Browse files
committed
Reformat completions.rs
1 parent 7e14cbd commit 1c8a2d9

File tree

1 file changed

+91
-48
lines changed

1 file changed

+91
-48
lines changed

crates/ark/src/lsp/completions.rs

Lines changed: 91 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,12 @@ fn completion_item_from_assignment(
289289
let label = lhs.utf8_text(context.source.as_bytes())?;
290290

291291
// TODO: Resolve functions that exist in-document here.
292-
let mut item = completion_item(label, CompletionData::ScopeVariable {
293-
name: label.to_string(),
294-
})?;
292+
let mut item = completion_item(
293+
label,
294+
CompletionData::ScopeVariable {
295+
name: label.to_string(),
296+
},
297+
)?;
295298

296299
let markup = MarkupContent {
297300
kind: MarkupKind::Markdown,
@@ -323,9 +326,12 @@ unsafe fn completion_item_from_package(
323326
package: &str,
324327
append_colons: bool,
325328
) -> Result<CompletionItem> {
326-
let mut item = completion_item(package.to_string(), CompletionData::Package {
327-
name: package.to_string(),
328-
})?;
329+
let mut item = completion_item(
330+
package.to_string(),
331+
CompletionData::Package {
332+
name: package.to_string(),
333+
},
334+
)?;
329335

330336
item.kind = Some(CompletionItemKind::MODULE);
331337

@@ -348,10 +354,13 @@ pub fn completion_item_from_function<T: AsRef<str>>(
348354
parameters: &[T],
349355
) -> Result<CompletionItem> {
350356
let label = format!("{}", name);
351-
let mut item = completion_item(label, CompletionData::Function {
352-
name: name.to_string(),
353-
package: package.map(|s| s.to_string()),
354-
})?;
357+
let mut item = completion_item(
358+
label,
359+
CompletionData::Function {
360+
name: name.to_string(),
361+
package: package.map(|s| s.to_string()),
362+
},
363+
)?;
355364

356365
item.kind = Some(CompletionItemKind::FUNCTION);
357366

@@ -386,10 +395,13 @@ unsafe fn completion_item_from_data_variable(
386395
owner: &str,
387396
enquote: bool,
388397
) -> Result<CompletionItem> {
389-
let mut item = completion_item(name.to_string(), CompletionData::DataVariable {
390-
name: name.to_string(),
391-
owner: owner.to_string(),
392-
})?;
398+
let mut item = completion_item(
399+
name.to_string(),
400+
CompletionData::DataVariable {
401+
name: name.to_string(),
402+
owner: owner.to_string(),
403+
},
404+
)?;
393405

394406
if enquote {
395407
item.insert_text = Some(format!("\"{}\"", name));
@@ -426,9 +438,12 @@ unsafe fn completion_item_from_object(
426438
return completion_item_from_function(name, package, &arguments);
427439
}
428440

429-
let mut item = completion_item(name, CompletionData::Object {
430-
name: name.to_string(),
431-
})?;
441+
let mut item = completion_item(
442+
name,
443+
CompletionData::Object {
444+
name: name.to_string(),
445+
},
446+
)?;
432447

433448
item.detail = Some("(Object)".to_string());
434449
item.kind = Some(CompletionItemKind::STRUCT);
@@ -462,9 +477,12 @@ unsafe fn completion_item_from_promise(
462477

463478
// Otherwise we never want to force promises, so we return a fairly
464479
// generic completion item
465-
let mut item = completion_item(name, CompletionData::Object {
466-
name: name.to_string(),
467-
})?;
480+
let mut item = completion_item(
481+
name,
482+
CompletionData::Object {
483+
name: name.to_string(),
484+
},
485+
)?;
468486

469487
item.detail = Some("Promise".to_string());
470488
item.kind = Some(CompletionItemKind::STRUCT);
@@ -475,9 +493,12 @@ unsafe fn completion_item_from_promise(
475493
fn completion_item_from_active_binding(name: &str) -> Result<CompletionItem> {
476494
// We never want to force active bindings, so we return a fairly
477495
// generic completion item
478-
let mut item = completion_item(name, CompletionData::Object {
479-
name: name.to_string(),
480-
})?;
496+
let mut item = completion_item(
497+
name,
498+
CompletionData::Object {
499+
name: name.to_string(),
500+
},
501+
)?;
481502

482503
item.detail = Some("Active binding".to_string());
483504
item.kind = Some(CompletionItemKind::STRUCT);
@@ -574,20 +595,26 @@ fn completion_item_from_scope_parameter(
574595
parameter: &str,
575596
_context: &CompletionContext,
576597
) -> Result<CompletionItem> {
577-
let mut item = completion_item(parameter, CompletionData::ScopeParameter {
578-
name: parameter.to_string(),
579-
})?;
598+
let mut item = completion_item(
599+
parameter,
600+
CompletionData::ScopeParameter {
601+
name: parameter.to_string(),
602+
},
603+
)?;
580604

581605
item.kind = Some(CompletionItemKind::VARIABLE);
582606
Ok(item)
583607
}
584608

585609
unsafe fn completion_item_from_parameter(parameter: &str, callee: &str) -> Result<CompletionItem> {
586610
let label = r_symbol_quote_invalid(parameter);
587-
let mut item = completion_item(label, CompletionData::Parameter {
588-
name: parameter.to_string(),
589-
function: callee.to_string(),
590-
})?;
611+
let mut item = completion_item(
612+
label,
613+
CompletionData::Parameter {
614+
name: parameter.to_string(),
615+
function: callee.to_string(),
616+
},
617+
)?;
591618

592619
// TODO: It'd be nice if we could be smarter about how '...' completions are handled,
593620
// but evidently VSCode doesn't let us set an empty 'insert text' string here.
@@ -744,9 +771,12 @@ unsafe fn append_subset_completions(
744771
) -> Result<()> {
745772
info!("append_subset_completions({:?})", callee);
746773

747-
let value = r_parse_eval(callee, RParseEvalOptions {
748-
forbid_function_calls: true,
749-
})?;
774+
let value = r_parse_eval(
775+
callee,
776+
RParseEvalOptions {
777+
forbid_function_calls: true,
778+
},
779+
)?;
750780

751781
let names = RFunction::new("base", "names")
752782
.add(value)
@@ -941,9 +971,12 @@ unsafe fn append_pipe_completions(
941971
return Ok(());
942972
});
943973

944-
let value = r_parse_eval(root, RParseEvalOptions {
945-
forbid_function_calls: true,
946-
})?;
974+
let value = r_parse_eval(
975+
root,
976+
RParseEvalOptions {
977+
forbid_function_calls: true,
978+
},
979+
)?;
947980

948981
// Try to retrieve names from the resulting item
949982
let names = RFunction::new("base", "names")
@@ -987,14 +1020,20 @@ unsafe fn append_argument_completions(
9871020
}
9881021

9891022
// Otherwise, try to retrieve completion names from the object itself.
990-
let r_callable = r_parse_eval(callable, RParseEvalOptions {
991-
forbid_function_calls: true,
992-
})?;
1023+
let r_callable = r_parse_eval(
1024+
callable,
1025+
RParseEvalOptions {
1026+
forbid_function_calls: true,
1027+
},
1028+
)?;
9931029

9941030
let r_object = if let Some(object) = object {
995-
r_parse_eval(object, RParseEvalOptions {
996-
forbid_function_calls: true,
997-
})?
1031+
r_parse_eval(
1032+
object,
1033+
RParseEvalOptions {
1034+
forbid_function_calls: true,
1035+
},
1036+
)?
9981037
} else {
9991038
RObject::null()
10001039
};
@@ -1098,9 +1137,12 @@ fn append_keyword_completions(completions: &mut Vec<CompletionItem>) -> anyhow::
10981137

10991138
for snippet in snippets {
11001139
let label = snippet.0.to_string();
1101-
let mut item = completion_item(label.to_string(), CompletionData::Snippet {
1102-
text: label.clone(),
1103-
})?;
1140+
let mut item = completion_item(
1141+
label.to_string(),
1142+
CompletionData::Snippet {
1143+
text: label.clone(),
1144+
},
1145+
)?;
11041146

11051147
item.detail = Some("[keyword]".to_string());
11061148
item.insert_text_format = Some(InsertTextFormat::SNIPPET);
@@ -1247,9 +1289,10 @@ unsafe fn append_roxygen_completions(
12471289
});
12481290

12491291
let label = name.to_string();
1250-
let mut item = completion_item(label.clone(), CompletionData::RoxygenTag {
1251-
tag: label.clone(),
1252-
})?;
1292+
let mut item = completion_item(
1293+
label.clone(),
1294+
CompletionData::RoxygenTag { tag: label.clone() },
1295+
)?;
12531296

12541297
// TODO: What is the appropriate icon for us to use here?
12551298
let template = entry["template"].as_str();

0 commit comments

Comments
 (0)