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

Offen
#503 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
35/100
Issue-Typ
Dokumentation
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
vim

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
Vim Script
Sterne
4.2k
Forks
323
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus rust-lang/rust.vim

Alle Issues in rust-lang/rust.vim

Ähnliche Issues

Weitere Issues zu DevTools

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.