annotate runtime/indent/rust.vim @ 33566:e1e3805fcd96 v9.0.2028

patch 9.0.2028: confusing build dependencies Commit: https://github.com/vim/vim/commit/5d03525cdef5db1b1cedfa26c6f8a21aaa207ec0 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Sun Oct 15 09:50:53 2023 +0200 patch 9.0.2028: confusing build dependencies Problem: confusing build dependencies Solution: clean them up, make them parallelizable Separate vim binary and unittest dependencies, make them parallelizable Clean up make dependencies so Vim and unit test binaries only depend on the object files they need. This fixes an existing issue where after running unit tests, the Vim binary would be invalidated, which results in it having to be linked again when running script tests, even though Vim was already previously built. Make link.sh (script we use to link those binaries) generate namespaced temporary files for each app to avoid them colliding with each other. This allows `unittesttargets` to be built in parallel. These fixes are useful when using link-time-optimization as the link phase could now take minutes rather than a few seconds. closes: #13344 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 15 Oct 2023 10:00:03 +0200
parents 555fede66c30
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim indent file
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Language: Rust
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Author: Chris Morgan <me@chrismorgan.info>
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
4 " Last Change: 2023-09-11
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " For bugs, patches and license go to https://github.com/rust-lang/rust.vim
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " Only load this indent file when no other was loaded.
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 if exists("b:did_indent")
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
9 finish
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 endif
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let b:did_indent = 1
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 setlocal cindent
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
14 setlocal cinoptions=L0,(s,Ws,J1,j1,m1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
15 setlocal cinkeys=0{,0},!^F,o,O,0[,0],0(,0)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " Don't think cinwords will actually do anything at all... never mind
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
17 setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern,macro
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 " Some preliminary settings
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 setlocal nolisp " Make sure lisp indenting doesn't supersede us
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 setlocal autoindent " indentexpr isn't much help otherwise
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " Also do indentkeys, otherwise # gets shoved to column 0 :-/
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
23 setlocal indentkeys=0{,0},!^F,o,O,0[,0],0(,0)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 setlocal indentexpr=GetRustIndent(v:lnum)
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
33052
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 32930
diff changeset
27 let b:undo_indent = "setlocal cindent< cinoptions< cinkeys< cinwords< lisp< autoindent< indentkeys< indentexpr<"
5c220cf30f1f runtime: Set b:undo_indent where missing (#12944)
Christian Brabandt <cb@256bit.org>
parents: 32930
diff changeset
28
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 " Only define the function once.
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 if exists("*GetRustIndent")
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
31 finish
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 endif
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
34 " vint: -ProhibitAbbreviationOption
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 let s:save_cpo = &cpo
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 set cpo&vim
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
37 " vint: +ProhibitAbbreviationOption
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 " Come here when loading the script the first time.
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 function! s:get_line_trimmed(lnum)
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
42 " Get the line and remove a trailing comment.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
43 " Use syntax highlighting attributes when possible.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
44 " NOTE: this is not accurate; /* */ or a line continuation could trick it
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
45 let line = getline(a:lnum)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
46 let line_len = strlen(line)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
47 if has('syntax_items')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
48 " If the last character in the line is a comment, do a binary search for
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
49 " the start of the comment. synID() is slow, a linear search would take
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
50 " too long on a long line.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
51 if synIDattr(synID(a:lnum, line_len, 1), "name") =~? 'Comment\|Todo'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
52 let min = 1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
53 let max = line_len
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
54 while min < max
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
55 let col = (min + max) / 2
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
56 if synIDattr(synID(a:lnum, col, 1), "name") =~? 'Comment\|Todo'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
57 let max = col
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
58 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
59 let min = col + 1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
60 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
61 endwhile
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
62 let line = strpart(line, 0, min - 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
63 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
64 return substitute(line, "\s*$", "", "")
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
65 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
66 " Sorry, this is not complete, nor fully correct (e.g. string "//").
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
67 " Such is life.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
68 return substitute(line, "\s*//.*$", "", "")
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
69 endif
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 endfunction
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 function! s:is_string_comment(lnum, col)
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
73 if has('syntax_items')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
74 for id in synstack(a:lnum, a:col)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
75 let synname = synIDattr(id, "name")
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
76 if synname ==# "rustString" || synname =~# "^rustComment"
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
77 return 1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
78 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
79 endfor
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
80 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
81 " without syntax, let's not even try
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
82 return 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
83 endif
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 endfunction
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
86 if exists('*shiftwidth')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
87 function! s:shiftwidth()
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
88 return shiftwidth()
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
89 endfunc
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
90 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
91 function! s:shiftwidth()
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
92 return &shiftwidth
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
93 endfunc
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
94 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
95
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 function GetRustIndent(lnum)
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
97 " Starting assumption: cindent (called at the end) will do it right
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
98 " normally. We just want to fix up a few cases.
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
100 let line = getline(a:lnum)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
102 if has('syntax_items')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
103 let synname = synIDattr(synID(a:lnum, 1, 1), "name")
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
104 if synname ==# "rustString"
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
105 " If the start of the line is in a string, don't change the indent
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
106 return -1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
107 elseif synname =~? '\(Comment\|Todo\)'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
108 \ && line !~# '^\s*/\*' " not /* opening line
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
109 if synname =~? "CommentML" " multi-line
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
110 if line !~# '^\s*\*' && getline(a:lnum - 1) =~# '^\s*/\*'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
111 " This is (hopefully) the line after a /*, and it has no
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
112 " leader, so the correct indentation is that of the
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
113 " previous line.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
114 return GetRustIndent(a:lnum - 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
115 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
116 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
117 " If it's in a comment, let cindent take care of it now. This is
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
118 " for cases like "/*" where the next line should start " * ", not
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
119 " "* " as the code below would otherwise cause for module scope
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
120 " Fun fact: " /*\n*\n*/" takes two calls to get right!
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
121 return cindent(a:lnum)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
122 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
123 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
124
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
125 " cindent gets second and subsequent match patterns/struct members wrong,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
126 " as it treats the comma as indicating an unfinished statement::
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
127 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
128 " match a {
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
129 " b => c,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
130 " d => e,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
131 " f => g,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
132 " };
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
134 " Search backwards for the previous non-empty line.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
135 let prevlinenum = prevnonblank(a:lnum - 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
136 let prevline = s:get_line_trimmed(prevlinenum)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
137 while prevlinenum > 1 && prevline !~# '[^[:blank:]]'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
138 let prevlinenum = prevnonblank(prevlinenum - 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
139 let prevline = s:get_line_trimmed(prevlinenum)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
140 endwhile
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
142 " A standalone '{', '}', or 'where'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
143 let l:standalone_open = line =~# '\V\^\s\*{\s\*\$'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
144 let l:standalone_close = line =~# '\V\^\s\*}\s\*\$'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
145 let l:standalone_where = line =~# '\V\^\s\*where\s\*\$'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
146 if l:standalone_open || l:standalone_close || l:standalone_where
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
147 " ToDo: we can search for more items than 'fn' and 'if'.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
148 let [l:found_line, l:col, l:submatch] =
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
149 \ searchpos('\<\(fn\)\|\(if\)\>', 'bnWp')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
150 if l:found_line !=# 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
151 " Now we count the number of '{' and '}' in between the match
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
152 " locations and the current line (there is probably a better
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
153 " way to compute this).
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
154 let l:i = l:found_line
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
155 let l:search_line = strpart(getline(l:i), l:col - 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
156 let l:opens = 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
157 let l:closes = 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
158 while l:i < a:lnum
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
159 let l:search_line2 = substitute(l:search_line, '\V{', '', 'g')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
160 let l:opens += strlen(l:search_line) - strlen(l:search_line2)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
161 let l:search_line3 = substitute(l:search_line2, '\V}', '', 'g')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
162 let l:closes += strlen(l:search_line2) - strlen(l:search_line3)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
163 let l:i += 1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
164 let l:search_line = getline(l:i)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
165 endwhile
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
166 if l:standalone_open || l:standalone_where
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
167 if l:opens ==# l:closes
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
168 return indent(l:found_line)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
169 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
170 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
171 " Expect to find just one more close than an open
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
172 if l:opens ==# l:closes + 1
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
173 return indent(l:found_line)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
174 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
175 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
176 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
177 endif
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
179 " A standalone 'where' adds a shift.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
180 let l:standalone_prevline_where = prevline =~# '\V\^\s\*where\s\*\$'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
181 if l:standalone_prevline_where
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
182 return indent(prevlinenum) + 4
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
183 endif
32930
2ff007677dba runtime(rust): fix rust indent (#12542)
Christian Brabandt <cb@256bit.org>
parents: 11518
diff changeset
184
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
185 " Handle where clauses nicely: subsequent values should line up nicely.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
186 if prevline[len(prevline) - 1] ==# ","
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
187 \ && prevline =~# '^\s*where\s'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
188 return indent(prevlinenum) + 6
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
189 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
190
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
191 let l:last_prevline_character = prevline[len(prevline) - 1]
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
193 " A line that ends with '.<expr>;' is probably an end of a long list
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
194 " of method operations.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
195 if prevline =~# '\V\^\s\*.' && l:last_prevline_character ==# ';'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
196 call cursor(a:lnum - 1, 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
197 let l:scope_start = searchpair('{\|(', '', '}\|)', 'nbW',
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
198 \ 's:is_string_comment(line("."), col("."))')
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
199 if l:scope_start != 0 && l:scope_start < a:lnum
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
200 return indent(l:scope_start) + 4
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
201 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
202 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
203
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
204 if l:last_prevline_character ==# ","
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
205 \ && s:get_line_trimmed(a:lnum) !~# '^\s*[\[\]{})]'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
206 \ && prevline !~# '^\s*fn\s'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
207 \ && prevline !~# '([^()]\+,$'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
208 \ && s:get_line_trimmed(a:lnum) !~# '^\s*\S\+\s*=>'
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
209 " Oh ho! The previous line ended in a comma! I bet cindent will try to
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
210 " take this too far... For now, let's normally use the previous line's
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
211 " indent.
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
213 " One case where this doesn't work out is where *this* line contains
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
214 " square or curly brackets; then we normally *do* want to be indenting
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
215 " further.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
216 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
217 " Another case where we don't want to is one like a function
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
218 " definition with arguments spread over multiple lines:
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
219 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
220 " fn foo(baz: Baz,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
221 " baz: Baz) // <-- cindent gets this right by itself
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
222 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
223 " Another case is similar to the previous, except calling a function
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
224 " instead of defining it, or any conditional expression that leaves
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
225 " an open paren:
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
226 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
227 " foo(baz,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
228 " baz);
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
229 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
230 " if baz && (foo ||
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
231 " bar) {
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
232 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
233 " Another case is when the current line is a new match arm.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
234 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
235 " There are probably other cases where we don't want to do this as
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
236 " well. Add them as needed.
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
237 return indent(prevlinenum)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
238 endif
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
240 if !has("patch-7.4.355")
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
241 " cindent before 7.4.355 doesn't do the module scope well at all; e.g.::
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
242 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
243 " static FOO : &'static [bool] = [
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
244 " true,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
245 " false,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
246 " false,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
247 " true,
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
248 " ];
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
249 "
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
250 " uh oh, next statement is indented further!
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
251
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
252 " Note that this does *not* apply the line continuation pattern properly;
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
253 " that's too hard to do correctly for my liking at present, so I'll just
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
254 " start with these two main cases (square brackets and not returning to
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
255 " column zero)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
257 call cursor(a:lnum, 1)
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
258 if searchpair('{\|(', '', '}\|)', 'nbW',
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
259 \ 's:is_string_comment(line("."), col("."))') == 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
260 if searchpair('\[', '', '\]', 'nbW',
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
261 \ 's:is_string_comment(line("."), col("."))') == 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
262 " Global scope, should be zero
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
263 return 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
264 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
265 " At the module scope, inside square brackets only
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
266 "if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
267 if line =~# "^\\s*]"
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
268 " It's the closing line, dedent it
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
269 return 0
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
270 else
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
271 return &shiftwidth
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
272 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
273 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
274 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
275 endif
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
276
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
277 " Fall back on cindent, which does it mostly right
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
278 return cindent(a:lnum)
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 endfunction
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
281 " vint: -ProhibitAbbreviationOption
11229
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 let &cpo = s:save_cpo
146a1e213b60 Update runtime files. Add Rust support.
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 unlet s:save_cpo
33255
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
284 " vint: +ProhibitAbbreviationOption
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
285
555fede66c30 runtime(rust): sync rust runtime files with upstream (#13075)
Christian Brabandt <cb@256bit.org>
parents: 33052
diff changeset
286 " vim: set et sw=4 sts=4 ts=8: