rust-lang / rust-lang/rust-analyzer
No completion results while inserting trait method names while inside a proc_macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Completion inside a macro appears to not work. I was working on a language server using tower-lsp, which looks like this:
#[tower_lsp::async_trait]
impl LanguageServer for Backend {
async fn did_change_configuration(&self, _: DidChangeConfigurationParams) {}
async fn did_open(&self, _: DidOpenTextDocumentParams) {}
async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> {
Ok(InitializeResult {
capabilities: ServerCapabilities {
hover_provider: Some(HoverProviderCapability::Simple(true)),
completion_provider: Some(CompletionOptions::default()),
..Default::default()
},
..Default::default()
})
}
async fn initialized(&self, _: InitializedParams) {
self.client
.log_message(MessageType::INFO, "server initialized!")
.await;
}
async fn shutdown(&self) -> Result<()> {
Ok(())
}
async fn completion(&self, _: CompletionParams) -> Result<Option<CompletionResponse>> {
Ok(Some(CompletionResponse::Array(vec![
CompletionItem::new_simple("Hello".to_string(), "Some detail".to_string()),
CompletionItem::new_simple("Bye".to_string(), "More detail".to_string()),
])))
}
async fn hover(&self, _: HoverParams) -> Result<Option<Hover>> {
Ok(Some(Hover {
contents: HoverContents::Scalar(MarkedString::String("You're hovering!".to_string())),
range: None,
}))
}
}
Autocompletion for the new methods at the top, did_change_configuration and did_open, did not return any results. Expected behavior would be the traits of the method.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the supplied tower-lsp LanguageServer example, focusing on completion for the trait methods inside the proc_macro. Compare completion behavior for the existing methods with the expected trait methods, and consider the issue done when those methods produce completion results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100