Mercurial > vim
annotate runtime/indent/rust.vim @ 34190:4f8b57f8b07a v9.1.0046
patch 9.1.0046: :drop does not re-use empty buffer
Commit: https://github.com/vim/vim/commit/f96dc8d07f752ddd96d1447d85278a85255a1462
Author: Rocco Mao <dapeng.mao@qq.com>
Date: Tue Jan 23 21:27:19 2024 +0100
patch 9.1.0046: :drop does not re-use empty buffer
Problem: :drop does not re-use empty buffer
(Rocco Mao)
Solution: Make :drop re-use an empty buffer
(Rocco Mao)
fixes: #13851
closes: #13881
Signed-off-by: Rocco Mao <dapeng.mao@qq.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 23 Jan 2024 21:30:05 +0100 |
parents | 555fede66c30 |
children | 37fbf37e11ff |
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: |