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

Format-on-save no longer functioning for rustfmt. No configuration change was made #4897

Open
ssokolow opened this issue Jan 21, 2025 · 0 comments
Labels

Comments

@ssokolow
Copy link

ssokolow commented Jan 21, 2025

Information

VIM version

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 10 2022 08:40:37)
Included patches: 1-749

Operating System:

% lsb_release -a                                                               
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy

NOTE: LSP support is disabled because I'm also running coc.nvim for languages where a suitably performant, suitably licensed LSP is available... which does include Rust, though adding that predates format-on-save breaking by a long time and I have coc.nvim's format-on-save support disabled because it's much more laissez-faire than cargo fmt and I can't find docs for changing that.

What went wrong

Somewhere along the way, rustfmt-on-save stopped working and :ALEFix also has no effect.

I'm guessing it happened as a result of a :PlugUpdate bumping ALE somewhere along the way (I use vim-plug) though I suppose it could also have come as a result of a rustup update.

Running cargo fmt manually still has the expected effect, meaning that my test input is testing what I want it to test, given the context of my rustfmt.toml.

I couldn't find any issues that appeared to be describing the same problem and the ALEInfo command history says that rustfmt is getting run and returning an exit code of 1, which, if this list is still valid, basically means "anything but the code being too malformed to format".

Reproducing the bug

  1. Open a Rust source file
  2. >> (indent) a statement that's currently properly indented. (eg. println!(...);)
  3. :ALEFix
  4. Nothing happens
  5. :w
  6. Nothing happens
  7. !cargo fmt
  8. Line gets popped back to the correct indent level

:ALEInfo

Expand
 Current Filetype: rust
Available Linters: ['analyzer', 'cargo', 'cspell', 'rls', 'rustc']
   Linter Aliases:
'analyzer' -> ['rust_analyzer']
  Enabled Linters: ['analyzer']
  Ignored Linters: ['analyzer']
 Suggested Fixers:
  'remove_trailing_lines' - Remove all blank lines at the end of a file.
  'rustfmt' - Fix Rust files with Rustfmt.
  'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.
 
 Linter Variables:
let g:ale_rust_analyzer_config = {'diagnostics': {'disabled': ['inactive-code', 'macro-error', 'unresolved-import', 'unresolved-proc-macro']}, 'procMacro': {'enable': v:true}}
let g:ale_rust_analyzer_executable = 'rust-analyzer'
let g:ale_rust_rustfmt_executable = 'rustfmt'
let g:ale_rust_rustfmt_options = ''
 
 Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = v:null
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 1
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = v:null
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 1
let g:ale_fixers = {'xml': ['xmllint'], '*': ['remove_trailing_lines', 'trim_whitespace'], 'javascript': ['eslint'], 'css': ['stylelint'], 'make': ['remove_trailing_lines']}
let b:ale_fixers = ['rustfmt', 'trim_whitespace', 'remove_trailing_lines']
let g:ale_history_enabled = 1
let g:ale_info_default_mode = 'preview'
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = v:null
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let b:ale_lint_on_save = 0
let g:ale_lint_on_text_changed = 'never'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let b:ale_linters = ['analyzer']
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {}
let g:ale_list_vertical = v:null
let g:ale_list_window_size = v:null
let g:ale_loclist_msg_format = v:null
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = v:null
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 1
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 1
let g:ale_set_highlights = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_set_signs = 1
let g:ale_sign_column_always = 1
let g:ale_sign_error = '✗'
let g:ale_sign_info = v:null
let g:ale_sign_offset = v:null
let g:ale_sign_style_error = v:null
let g:ale_sign_style_warning = v:null
let g:ale_sign_warning = '‼'
let g:ale_sign_highlight_linenrs = v:null
let g:ale_type_map = v:null
let g:ale_use_neovim_diagnostics_api = 0
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 'all'
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
 
  Command History:

(finished - exit code 1) ['/usr/bin/zsh', '-c', '''rustfmt'' < ''/tmp/vpQIziD/3/main.rs''']
(finished - exit code 1) ['/usr/bin/zsh', '-c', '''rustfmt'' < ''/tmp/vpQIziD/8/main.rs''']
@ssokolow ssokolow added the bug label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant