Stream: t-compiler/wg-rls-2.0

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 Nicola (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 Nicola (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 https://github.com/fannheyward/coc-rust-analyzer/pull/252#issuecomment-632427338 and https://github.com/neoclide/coc.nvim/issues/1981
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: May 29 2020 at 16:55UTC