aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-08-21 09:51:47 +0900
committerChristian Clason <c.clason@uni-graz.at>2023-08-21 20:32:28 +0900
commitabc3721e4fce2ddacc7fc51f729637f87819efbd (patch)
tree092db998336751ea965be0daf3cacaebff35fe89
parent4a36ecd23898e8b4ccbe8fce9bd9300aa69aa834 (diff)
downloadrneovim-abc3721e4fce2ddacc7fc51f729637f87819efbd.tar.gz
rneovim-abc3721e4fce2ddacc7fc51f729637f87819efbd.tar.bz2
rneovim-abc3721e4fce2ddacc7fc51f729637f87819efbd.zip
vim-patch:478668013f06
runtime(rust): fix rust indent (vim/vim#12542) https://github.com/vim/vim/commit/478668013f060a75b8cd8cc6ca2cf2abb3bcc4a5 Co-authored-by: Raphael <glephunter@gmail.com>
-rw-r--r--runtime/indent/rust.vim16
1 files changed, 16 insertions, 0 deletions
diff --git a/runtime/indent/rust.vim b/runtime/indent/rust.vim
index d30629b64e..2b544f4a67 100644
--- a/runtime/indent/rust.vim
+++ b/runtime/indent/rust.vim
@@ -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'