]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(rust): use textwidth=100 for the Rust recommended style
authorAaron Jacobs <jacobsa@google.com>
Tue, 9 Dec 2025 11:43:39 +0000 (12:43 +0100)
committerChristian Brabandt <cb@256bit.org>
Tue, 9 Dec 2025 11:43:39 +0000 (12:43 +0100)
The help text here said 99 was the recommended style for the standard
library, but I can't find a citation for this anywhere. In contrast the
Rust Style Guide hosted on rust-lang.org
[says](https://doc.rust-lang.org/stable/style-guide/#indentation-and-line-width)
the maximum line width is 100, and rustfmt
[agrees](https://github.com/rust-lang/rust/blob/37aa2135b5d0936bd13aa699d941aaa94fbaa645/src/tools/rustfmt/src/config/options.rs#L570).

Having the two disagree causes an annoying off-by-one error in vim: if
you configure vim to highlight too-long lines then it will occasionally
complain about a line that rustfmt refuses to fix.

closes: #18892

Signed-off-by: Aaron Jacobs <jacobsa@google.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/ft_rust.txt
runtime/ftplugin/rust.vim

index 4f4e3a85e721ad482b4ea32cb10069465071f9e6..b1789b8141bb4c064a450a4b830251d59d0061cb 100644 (file)
@@ -60,8 +60,8 @@ g:rust_conceal_pub~
                                                      *g:rust_recommended_style*
 g:rust_recommended_style~
         Set this option to enable vim indentation and textwidth settings to
-        conform to style conventions of the rust standard library (i.e. use 4
-        spaces for indents and sets 'textwidth' to 99). This option is enabled
+        conform to style conventions of the Rust style guide (i.e. use 4
+        spaces for indents and set 'textwidth' to 100). This option is enabled
        by default. To disable it: >
            let g:rust_recommended_style = 0
 <
index 3e2741f919cc5e01bce7d85e9ffe0c79d9a572c4..4765f81704b2a677482b523d41074d511a437e59 100644 (file)
@@ -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 Dec 09 update 'textwidth# to 100 #18892
 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim
 
 if exists("b:did_ftplugin")
@@ -49,7 +50,7 @@ setlocal smartindent nocindent
 if get(g:, 'rust_recommended_style', 1)
     let b:rust_set_style = 1
     setlocal shiftwidth=4 softtabstop=4 expandtab
-    setlocal textwidth=99
+    setlocal textwidth=100
 endif
 
 setlocal include=\\v^\\s*(pub\\s+)?use\\s+\\zs(\\f\|:)+