Skip to content

vim.lsp.formatOnSave doesn't work when rust has an async functionΒ #589

@JamyGolden

Description

@JamyGolden

⚠️ Please verify that this bug has NOT been reported before.

  • I checked all existing issues and didn't find a similar issue

Description

vim.lsp.formatOnSave doesn't work when there is an async function in the file.

πŸ‘Ÿ Reproduction steps

  1. Create example.rs

    pub(crate) async fn example_fn(
    ) -> Result<(), Box<(dyn std::error::Error + 'static)>> {
    println!("hello world");
    
        Ok(())
    }

    Saving this file doesn't run vim.lsp.buf.format() (lua). When i run that manually :lua vim.lsp.buf.format() it formats correctly.

  2. Removing the async keyword enables the formatting:

    pub(crate) fn example_fn(
    ) -> Result<(), Box<(dyn std::error::Error + 'static)>> {
    println!("hello world");
    
        Ok(())
    }

    Saving this file formats correctly indenting the println!("hello world"); line.

πŸ‘€ Expected behavior

Format correctly with async keyword present in file.

πŸ˜“ Actual Behavior

Only formats when async keyword doesn't exist in file.

πŸ’» Metadata

  • system: "x86_64-linux" - host os: Linux 6.9.3-76060903-generic, Pop!_OS, 22.04 LTS, nobuild - multi-user?: no - sandbox: yes - version: nix-env (Nix) 2.25.2 - nixpkgs: /home/user/.nix-defexpr/channels/nixpkgs

πŸ“ Relevant log output

n/a

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions