]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(rust): use shiftwidth() in indent script
authornovenary <novenary@kwak.zip>
Thu, 4 Jul 2024 17:11:16 +0000 (19:11 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 4 Jul 2024 17:11:16 +0000 (19:11 +0200)
closes: #15138

Signed-off-by: novenary <novenary@kwak.zip>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/indent/rust.vim

index 7c055ec73942ea5251cd9b2b24103cf3bba58126..a96650d41955311c0c95aee00ff24b578d032830 100644 (file)
@@ -2,7 +2,10 @@
 " Language:         Rust
 " Author:           Chris Morgan <me@chrismorgan.info>
 " Last Change:      2023-09-11
+" 2024 Jul 04 by Vim Project: use shiftwidth() instead of hard-coding shifted values (#15138)
+
 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim
+" Note: upstream seems umaintained: https://github.com/rust-lang/rust.vim/issues/502
 
 " Only load this indent file when no other was loaded.
 if exists("b:did_indent")
@@ -179,7 +182,7 @@ function GetRustIndent(lnum)
     " A standalone 'where' adds a shift.
     let l:standalone_prevline_where = prevline =~# '\V\^\s\*where\s\*\$'
     if l:standalone_prevline_where
-        return indent(prevlinenum) + 4
+        return indent(prevlinenum) + shiftwidth()
     endif
 
     " Handle where clauses nicely: subsequent values should line up nicely.
@@ -197,7 +200,7 @@ function GetRustIndent(lnum)
         let l:scope_start = searchpair('{\|(', '', '}\|)', 'nbW',
                     \ 's:is_string_comment(line("."), col("."))')
         if l:scope_start != 0 && l:scope_start < a:lnum
-            return indent(l:scope_start) + 4
+            return indent(l:scope_start) + shiftwidth()
         endif
     endif
 
@@ -268,7 +271,7 @@ function GetRustIndent(lnum)
                     " It's the closing line, dedent it
                     return 0
                 else
-                    return &shiftwidth
+                    return shiftwidth()
                 endif
             endif
         endif