Skip to content

Document how to use #[rust_analyzer::completions(...)] #19472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BD103 opened this issue Mar 28, 2025 · 2 comments
Closed

Document how to use #[rust_analyzer::completions(...)] #19472

BD103 opened this issue Mar 28, 2025 · 2 comments
Labels
A-documentation docs for rust-analyzer usage/inner working

Comments

@BD103
Copy link

BD103 commented Mar 28, 2025

I just saw #19375 was merged, but I couldn't find any user-facing documentation on how to use #[rust_analyzer::completions(...)]. I did find these comments, but they're within the code:

// Feature: Completions Attribute
// Crate authors can opt their type out of completions in some cases.
// This is done with the `#[rust_analyzer::completions(...)]` attribute.
//
// All completeable things support `#[rust_analyzer::completions(ignore_flyimport)]`,
// which causes the thing to get excluded from flyimport completion. It will still
// be completed when in scope. This is analogous to the setting `rust-analyzer.completion.autoimport.exclude`
// with `"type": "always"`.
//
// In addition, traits support two more modes: `#[rust_analyzer::completions(ignore_flyimport_methods)]`,
// which means the trait itself may still be flyimported but its methods won't, and
// `#[rust_analyzer::completions(ignore_methods)]`, which means the methods won't be completed even when
// the trait is in scope (but the trait itself may still be completed). The methods will still be completed
// on `dyn Trait`, `impl Trait` or where the trait is specified in bounds. These modes correspond to
// the settings `rust-analyzer.completion.autoimport.exclude` with `"type": "methods"` and
// `rust-analyzer.completion.excludeTraits`, respectively.
//
// Malformed attributes will be ignored without warnings.
//
// Note that users have no way to override this attribute, so be careful and only include things
// users definitely do not want to be completed!

Is there a place this can be documented so it is easier to discover and learn about? (I would be willing to open a PR for this, though I may have a few extra questions.) Thank you!

@ShoyuVanilla ShoyuVanilla added the A-documentation docs for rust-analyzer usage/inner working label Mar 29, 2025
@ChayimFriedman2
Copy link
Contributor

ChayimFriedman2 commented Mar 29, 2025

We have a task that extracts // Feature: comments within the code to docs in the manual. Not sure why it's not working here.

@BD103
Copy link
Author

BD103 commented Mar 29, 2025

We have a task that extracts // Feature: comments within the code to docs in the manual. Not sure why it's not working here.

No it's working, I looked again and found it here! Sorry, I didn't look hard enough :)

@BD103 BD103 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documentation docs for rust-analyzer usage/inner working
Projects
None yet
Development

No branches or pull requests

3 participants