diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2025-04-01 17:20:11 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-01 17:20:11 +0800 |
| commit | 2322ae403b24699a432a1744e502310e252cb1d3 (patch) | |
| tree | f1484650b112d6a104831e418d0d502c9a653827 /runtime/ftplugin | |
| parent | 7e8b7bba21cfb0a35e442c27aec0ced1b32ce14d (diff) | |
| download | rneovim-2322ae403b24699a432a1744e502310e252cb1d3.tar.gz rneovim-2322ae403b24699a432a1744e502310e252cb1d3.tar.bz2 rneovim-2322ae403b24699a432a1744e502310e252cb1d3.zip | |
vim-patch:4ac995b: runtime(rust): set formatprg to rustfmt (#33245)
closes: vim/vim#16967
https://github.com/vim/vim/commit/4ac995bf9366c6624a0724d19b2226f4c95694b3
Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
Diffstat (limited to 'runtime/ftplugin')
| -rw-r--r-- | runtime/ftplugin/rust.vim | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/runtime/ftplugin/rust.vim b/runtime/ftplugin/rust.vim index 3e2741f919..53f7f83363 100644 --- a/runtime/ftplugin/rust.vim +++ b/runtime/ftplugin/rust.vim @@ -3,6 +3,7 @@ " Maintainer: Chris Morgan <me@chrismorgan.info> " Last Change: 2024 Mar 17 " 2024 May 23 by Riley Bruins <ribru17@gmail.com ('commentstring') +" 2025 Mar 31 by Vim project (set 'formatprg' option) " For bugs, patches and license go to https://github.com/rust-lang/rust.vim if exists("b:did_ftplugin") @@ -57,6 +58,19 @@ setlocal includeexpr=rust#IncludeExpr(v:fname) setlocal suffixesadd=.rs +if executable(get(g:, 'rustfmt_command', 'rustfmt')) + if get(g:, "rustfmt_fail_silently", 0) + augroup rust.vim.FailSilently + autocmd! * <buffer> + autocmd ShellFilterPost <buffer> if v:shell_error | execute 'echom "shell filter returned error " . v:shell_error . ", undoing changes"' | undo | endif + augroup END + endif + + let &l:formatprg = get(g:, 'rustfmt_command', 'rustfmt') . ' ' . + \ get(g:, 'rustfmt_options', '') . ' ' . + \ rustfmt#RustfmtConfigOptions() +endif + if exists("g:ftplugin_rust_source_path") let &l:path=g:ftplugin_rust_source_path . ',' . &l:path endif @@ -149,7 +163,7 @@ endif let b:undo_ftplugin = " \ compiler make | - \ setlocal formatoptions< comments< commentstring< include< includeexpr< suffixesadd< + \ setlocal formatoptions< comments< commentstring< include< includeexpr< suffixesadd< formatprg< \|if exists('b:rust_set_style') \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth< \|endif |