simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.17k stars 159 forks source link

Can not format when use async funtion #356

Closed DefectingCat closed 1 year ago

DefectingCat commented 1 year ago
#[tokio::main]
async fn main() -> Result<()> {
    // need format this line.
      let running = Arc::new(AtomicBool::new(true));
    let r = Arc::clone(&running);
    // ..
}

If it is not a async funcion,it can be fromatted as expected. but it's can be formatted with cargo fmt

My config (lazyvim):

  -- rust-tools.nvim
  {
    "simrat39/rust-tools.nvim",
    config = function()
      local rt = require("rust-tools")
      rt.setup({
        dap = {
          -- adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
        },
        server = {
          settings = {
            ["rust-analyzer"] = {
              cargo = {
                features = "all",
              },
              -- Add clippy lints for Rust.
              checkOnSave = true,
              check = {
                command = "clippy",
                features = "all",
              },
              procMacro = {
                enable = true,
              },
            },
          },
          on_attach = function(_, bufnr)
            -- Hover actions
            vim.keymap.set("n", "gh", rt.hover_actions.hover_actions, { buffer = bufnr })
            -- Code action groups
            vim.keymap.set("n", "<leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
          end,
        },
      })
    end,
  },

version:

stable-aarch64-apple-darwin unchanged - rustc 1.68.1 (8460ca823 2023-03-20)
shot-codes commented 1 year ago

I'm experiencing this currently. version: 0cc8ada Auto generate docs (6 weeks ago)

shot-codes commented 1 year ago

Resolved by adding rustfmt.toml to the project root with the contents edition = "2021"