diff options
-rw-r--r-- | crates/completion/src/completions/attribute.rs | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/crates/completion/src/completions/attribute.rs b/crates/completion/src/completions/attribute.rs index 10739750c..3a29b5203 100644 --- a/crates/completion/src/completions/attribute.rs +++ b/crates/completion/src/completions/attribute.rs | |||
@@ -21,20 +21,15 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) | |||
21 | 21 | ||
22 | let attribute = ctx.attribute_under_caret.as_ref()?; | 22 | let attribute = ctx.attribute_under_caret.as_ref()?; |
23 | match (attribute.path(), attribute.token_tree()) { | 23 | match (attribute.path(), attribute.token_tree()) { |
24 | (Some(path), Some(token_tree)) if path.to_string() == "derive" => { | 24 | (Some(path), Some(token_tree)) => match path.to_string().as_str() { |
25 | complete_derive(acc, ctx, token_tree) | 25 | "derive" => complete_derive(acc, ctx, token_tree), |
26 | } | 26 | "feature" => complete_lint(acc, ctx, token_tree, FEATURES), |
27 | (Some(path), Some(token_tree)) if path.to_string() == "feature" => { | 27 | "allow" | "warn" | "deny" | "forbid" => { |
28 | complete_lint(acc, ctx, token_tree, FEATURES); | 28 | complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS); |
29 | } | 29 | complete_lint(acc, ctx, token_tree, CLIPPY_LINTS); |
30 | (Some(path), Some(token_tree)) | 30 | } |
31 | if ["allow", "warn", "deny", "forbid"] | 31 | _ => {} |
32 | .iter() | 32 | }, |
33 | .any(|lint_level| lint_level == &path.to_string()) => | ||
34 | { | ||
35 | complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS); | ||
36 | complete_lint(acc, ctx, token_tree, CLIPPY_LINTS); | ||
37 | } | ||
38 | (_, Some(_token_tree)) => {} | 33 | (_, Some(_token_tree)) => {} |
39 | _ => complete_attribute_start(acc, ctx, attribute), | 34 | _ => complete_attribute_start(acc, ctx, attribute), |
40 | } | 35 | } |
@@ -54,11 +49,8 @@ fn complete_attribute_start(acc: &mut Completions, ctx: &CompletionContext, attr | |||
54 | item = item.lookup_by(lookup); | 49 | item = item.lookup_by(lookup); |
55 | } | 50 | } |
56 | 51 | ||
57 | match (attr_completion.snippet, ctx.config.snippet_cap) { | 52 | if let Some((snippet, cap)) = attr_completion.snippet.zip(ctx.config.snippet_cap) { |
58 | (Some(snippet), Some(cap)) => { | 53 | item = item.insert_snippet(cap, snippet); |
59 | item = item.insert_snippet(cap, snippet); | ||
60 | } | ||
61 | _ => {} | ||
62 | } | 54 | } |
63 | 55 | ||
64 | if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner { | 56 | if attribute.kind() == ast::AttrKind::Inner || !attr_completion.prefer_inner { |