Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The rustfmt.toml file is not taken into account when saving #572

Open
wusticality opened this issue Jul 25, 2024 · 0 comments
Open

The rustfmt.toml file is not taken into account when saving #572

wusticality opened this issue Jul 25, 2024 · 0 comments

Comments

@wusticality
Copy link

wusticality commented Jul 25, 2024

I'm on the latest version of the rustic package and have things setup to run rustfmt on save. I'm passing the +nightly flag. Unfortunately, none of the settings in my repository's rustfmt.toml file are ever taken into account when saving through rustic. The package is formatting my code though with rustfmt, it just doesn't use my settings. Here's my configuration:

(use-package rustic
  :hook (rustic-mode . yas-minor-mode)
  :bind
  (:map
   rustic-mode-map
   ("M-j" . lsp-ui-imenu)
   ("M-?" . lsp-find-references)
   ("C-c C-c l" . flycheck-list-errors)
   ("C-c C-c a" . lsp-execute-code-action)
   ("C-c C-c r" . lsp-rename)
   ("C-c C-c q" . lsp-workspace-restart)
   ("C-c C-c Q" . lsp-workspace-shutdown)
   ("C-c C-c s" . lsp-rust-analyzer-status))
  :init
  (progn
    ;; Use nightly rust for formatting.
    (setq rustic-rustfmt-args "+nightly")

    ;; Use rustfmt on save.
    (setq rustic-format-on-save t))
  :config
  (progn
    ;; Use electric pair mode.
    (electric-pair-mode 1)

    ;; This fixes a bug, see below.
    (add-hook 'rustic-mode-hook 'rk/rustic-mode-hook)))

(defun rk/rustic-mode-hook ()
  ;; Do this so that running C-c C-c C-r works without having to
  ;; confirm, but don't try to save rust buffers that are not file
  ;; visiting. Once https://github.com/brotzeit/rustic/issues/253
  ;; has been resolved this should no longer be necessary.
  (when buffer-file-name
    (setq-local buffer-save-without-query t)))

This shouldn't matter as I use it everywhere, but here's my rustfmt.toml file as well:

version = "Two"
edition = "2021"
newline_style = "Unix"
trailing_comma = "Never"
merge_derives = false
struct_field_align_threshold = 32
chain_width = 36
imports_granularity = "Crate"
match_block_trailing_comma = true

Sadly this has rendered the package unusable for me at present, perhaps this is a bug?

@wusticality wusticality changed the title The rustfmt.toml file is not taken into account The rustfmt.toml file is not taken into account when saving. Jul 25, 2024
@wusticality wusticality changed the title The rustfmt.toml file is not taken into account when saving. The rustfmt.toml file is not taken into account when formatting / saving Jul 25, 2024
@wusticality wusticality changed the title The rustfmt.toml file is not taken into account when formatting / saving The rustfmt.toml file is not taken into account when formatting Jul 25, 2024
@wusticality wusticality changed the title The rustfmt.toml file is not taken into account when formatting The rustfmt.toml file is not taken into account when saving Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant