]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(rust): fix rust indent (#12542)
authorRaphael <glephunter@gmail.com>
Sun, 20 Aug 2023 18:42:39 +0000 (02:42 +0800)
committerGitHub <noreply@github.com>
Sun, 20 Aug 2023 18:42:39 +0000 (20:42 +0200)
runtime/indent/rust.vim

index d30629b64e56c795f3d1118d3df2389e017f605d..2b544f4a67718fbb1d8219eeb70ae2ae8717798f 100644 (file)
@@ -132,6 +132,22 @@ function GetRustIndent(lnum)
                return indent(prevlinenum) + 6
        endif
 
+       "match newline after struct with generic bound like
+       "struct SomeThing<T>
+       "| <-- newline indent should same as prevline
+       if prevline[len(prevline) - 1] == ">"
+                               \ && prevline =~# "\s*struct.*>$"
+               return indent(prevlinenum)
+       endif
+
+       "match newline after where like:
+       "struct SomeThing<T>
+       "where
+       "     T: Display,
+       if prevline =~# '^\s*where$'
+               return indent(prevlinenum) + 4
+       endif
+
        if prevline[len(prevline) - 1] == ","
                                \ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
                                \ && prevline !~ '^\s*fn\s'