11" Author: Stephen Sugden <stephen@stephensugden.com>
22" Last Modified: 2023-09-11
33" Last Change:
4- " 2025 Mar 31 by Vim project (rename s:RustfmtConfigOptions())
5- " 2025 Jul 14 by Vim project (don't parse rustfmt version automatically #17745)
4+ " 2025 Oct 27 by Vim project don't use rustfmt as 'formatprg' by default
5+ "
66"
77" Adapted from https://github.com/fatih/vim-go
88" For bugs, patches and license go to https://github.com/rust-lang/rust.vim
@@ -68,13 +68,7 @@ function! s:RustfmtWriteMode()
6868 endif
6969endfunction
7070
71- function ! rustfmt#RustfmtConfigOptions ()
72- let default = ' --edition 2018'
73-
74- if ! get (g: , ' rustfmt_find_toml' , 0 )
75- return default
76- endif
77-
71+ function ! s: RustfmtConfigOptions ()
7872 let l: rustfmt_toml = findfile (' rustfmt.toml' , expand (' %:p:h' ) . ' ;' )
7973 if l: rustfmt_toml !=# ' '
8074 return ' --config-path ' .shellescape (fnamemodify (l: rustfmt_toml , " :p" ))
@@ -97,7 +91,7 @@ function! s:RustfmtCommandRange(filename, line1, line2)
9791
9892 let l: arg = {" file" : shellescape (a: filename ), " range" : [a: line1 , a: line2 ]}
9993 let l: write_mode = s: RustfmtWriteMode ()
100- let l: rustfmt_config = rustfmt# RustfmtConfigOptions ()
94+ let l: rustfmt_config = s: RustfmtConfigOptions ()
10195
10296 " FIXME: When --file-lines gets to be stable, add version range checking
10397 " accordingly.
@@ -112,7 +106,7 @@ endfunction
112106
113107function ! s: RustfmtCommand ()
114108 let write_mode = g: rustfmt_emit_files ? ' --emit=stdout' : ' --write-mode=display'
115- let config = rustfmt# RustfmtConfigOptions ()
109+ let config = s: RustfmtConfigOptions ()
116110 return join ([g: rustfmt_command , write_mode, config, g: rustfmt_options ])
117111endfunction
118112
0 commit comments