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

未关闭
#503 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
vim

调研方向

Read the rust.vim configuration and formatting documentation to determine how rustfmt options are passed and whether .rustfmt.toml is discovered from a parent directory. The issue gives no file or test entry point, so first locate the documentation or code that handles rustfmt_options. Done means documenting a working setup that applies the stated imports_layout configuration.

由索引模型根据 Issue 内容生成。

描述

  • 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?

主要语言
Vim Script
星标
4.2k
派生
323
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

rust-lang/rust.vim 的其他 Issue

查看 rust-lang/rust.vim 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。