Skip to content

How to use configuration found in .rustfmt.toml when running Rust format? #503

@MitchTurner

Description

@MitchTurner
  • rust.vim version: Whatever comes automatically by including "rust-lang/rust.vim" in my plugins.lua file
  • nvchad distro of Neovim.

Steps to reproduce:

In my plugin directory I currently have:

  {
    "rust-lang/rust.vim",
    ft = "rust",
    init = function ()
      vim.rustfmt_options = "+nightly"
      vim.g.rustfmt_autosave = 1
    end
  },

This is working inasmuch as it's reformatting my code on save.

However, it's ignoring the configurations I have set in the .rustfmt.toml in the parent directory.

For example:

imports_layout = "Vertical"

should result in the imports being stacked, but the formatting from rust.vim is undoing that.

Expected vs. actual behavior:

This isn't a bug as much as a gap in my knowledge. I'd hope to find a solution that recognizes my .rustfmt.toml and includes the configuration. Perhaps I could include a lua script that checks if it exists and includes it in the rustfmt_options?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions