Skip to content

Auto import has broken for rust-analyzer 1.85.x #1595

@only14vic

Description

@only14vic

Original issue: rust-lang/rust-analyzer#19401

rust-analyzer version: 1.85.1 (4eb1612 2025-03-15)

rustc version: 1.85.1 (4eb161250 2025-03-15)

editor or extension: vim 9.1.1198-1 + vim-lsp

After updating Rust from the old version 1.84.1 to the new 1.85.x autoimport has stopped adding the module path to the use section of file. At the same time, completion works fine.

If I switch to the old version of Rust 1.84.1 sh# rustup default 1.84 then autoimport works perfectly with the same vim-lsp settings.

I tried different values ​​in granularity.group and granularity.enforce but autoimport did not work.

vim-lsp settings:

au User lsp_setup call lsp#register_server({
    \   'name': 'rust-analyzer',
    \   'cmd': ['rust-analyzer'],
    \   'allowlist': ['rust'],
    \   'initialization_options': {
    \       'lens': { 'enable': v:false, 'debug': { 'enable': v:false } },
    \       'imports': {
    \           'preferPrelude': v:true,
    \           'preferNoStd': v:true,
    \           'granularity': {
    \               'group': 'one',
    \               'enforce': v:true
    \           }
    \       },
    \       'completion': {
    \           'autoimport': { 'enable': v:true },
    \           'callable': { 'snippets': 'add_parentheses' },
    \           'fullFunctionSignatures': { 'enable': v:true },
    \           'snippets': { 'custom': {} },
    \           'postfix': { 'enable': v:false },
    \           'termSearch': { 'enable': v:true, 'fuel': 10000 }
    \       }
    \   }
    \ })

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions