Stream: t-compiler/rust-analyzer

Topic: Auto-imports and coc.nvim

Marcus Buffett (May 21 2020 at 01:21, on Zulip):

Just trying to use rust-analyzer in vim, specifically for the auto-importing functionality. It seems like according to the assists documentation, if I have an unresolved name, then I should be able to get a prompt from rust-analyzer to add an import. So I type something like let x = Transform::new(), then bring up the language server actions, but I only see "Extract into variable" and "Implement default members", when I would hope to get a suggestion to import from amethyst::core::Transform. Any help would be much appreciated! Also hopefully creating a topic is the way to go for this, first time zulip-er

Laurențiu (May 21 2020 at 04:46, on Zulip):

Can you try in an empty project, just to make sure it's not related to Amethyst? Importing something like HashMap should work fine.

simulacrum (May 21 2020 at 13:09, on Zulip):

I was unable to get this to work (none of the import-related functionality works for me) in vim and coc.nvim. I haven't had the time to investigate...

Laurențiu (May 21 2020 at 13:11, on Zulip):

I only tested it in LanguageClient-neovim

Timo Freiberg (May 23 2020 at 09:04, on Zulip):

Autoimport works when using coc.nvim and coc-rust-analyzer, but the default behaviour of coc-codeaction was changed recently to apply to the whole buffer, and rust-analyzer only offers assists if the selection is specific enough.
See and
If you have a binding to <Plug>(coc-codeaction), you probably want to change it to call v<Plug>(coc-codeaction-selected) for now

simulacrum (May 23 2020 at 11:52, on Zulip):

will try that, thanks!

Last update: Jul 28 2021 at 05:00UTC