Open dialtone opened 3 years ago
I'm not very familiar with rust and rust-analyer though. It'd be great if you can provide an example that works in vscode but not here. Further more, this kind of server dependence feature is kind of a pain to maintain, probably we should have a easier way to customize completion behavior.
Hey, you can see the auto import completion in action here: https://github.com/rust-analyzer/rust-analyzer/pull/6553 and I think the primary way to enable it is to use textDocument/completion
with additional properties like seen here: https://github.com/microsoft/vscode-languageserver-node/blob/fde994bb4e29518a1988d0070e3f160146135021/client/src/common/client.ts#L1514 and in particular I think it needs additionalTextEdits
enabled and then to apply those returned.
Hmm actually completion-nvim DOES support addtionalyTextEdits
, at least it works fine on ccls
on my side. I'm not sure why this doesn't work in rust-analyzer. I'll take a closer look to it.
Hmm I guess the behavior is quite weird comparing to the link you show, it's activate with codeActions so I tried using codeActions when my cursor is at
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
fn main() {
let map = HashMap|;
}
and it does auto import it. But when I type HashMap no completion was available so I can't triggered it with complete an items.
rust-analyzer only provides auto-importing completions when the textDocument.completion.resolveSupport
client capability includes additionalTextEdits
, indicating that the client supports lazily resolving the additional edit required to do the import
Is your feature request related to a problem? Please describe. It would be nice to be able to auto import libraries in rust if they are standard library or dependencies, upon completion, it would make the completion logic a lot more useful as well.
Describe the solution you'd like Behave like VSCode does with rust autocomplete