comparison runtime/indent/cdl.vim @ 25773:11b656e74444

Update runtime files Commit: https://github.com/vim/vim/commit/6c391a74fe90190796ca0b0c010112948a6e75d7 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Sep 9 21:55:11 2021 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Thu, 09 Sep 2021 22:00:10 +0200
parents 4ab4ef0c48b1
children 9c221ad9634a
comparison
equal deleted inserted replaced
25772:55753c17b73d 25773:11b656e74444
14 " Only define the function once. 14 " Only define the function once.
15 if exists("*CdlGetIndent") 15 if exists("*CdlGetIndent")
16 "finish 16 "finish
17 endif 17 endif
18 18
19 " find out if an "...=..." expresion is an assignment (or a conditional) 19 " find out if an "...=..." expression is an assignment (or a conditional)
20 " it scans 'line' first, and then the previos lines 20 " it scans 'line' first, and then the previous lines
21 fun! CdlAsignment(lnum, line) 21 fun! CdlAsignment(lnum, line)
22 let f = -1 22 let f = -1
23 let lnum = a:lnum 23 let lnum = a:lnum
24 let line = a:line 24 let line = a:line
25 while lnum > 0 && f == -1 25 while lnum > 0 && f == -1
31 if inicio < 0 31 if inicio < 0
32 break 32 break
33 endif 33 endif
34 " it's formula if there's a ';', 'elsE', 'theN', 'enDif' or 'expr' 34 " it's formula if there's a ';', 'elsE', 'theN', 'enDif' or 'expr'
35 " conditional if there's a '<', '>', 'elseif', 'if', 'and', 'or', 'not', 35 " conditional if there's a '<', '>', 'elseif', 'if', 'and', 'or', 'not',
36 " 'memberis', 'childrenof' and other \k\+of funcions 36 " 'memberis', 'childrenof' and other \k\+of functions
37 let f = line[inicio-1] =~? '[en;]' || strpart(line, inicio-4, 4) =~? 'ndif\|expr' 37 let f = line[inicio-1] =~? '[en;]' || strpart(line, inicio-4, 4) =~? 'ndif\|expr'
38 endw 38 endw
39 let lnum = prevnonblank(lnum-1) 39 let lnum = prevnonblank(lnum-1)
40 let line = substitute(getline(lnum), '\c\(\[[^]]*]\(\s*of\s*\|:\)*\)\+', ' ', 'g') 40 let line = substitute(getline(lnum), '\c\(\[[^]]*]\(\s*of\s*\|:\)*\)\+', ' ', 'g')
41 endw 41 endw
104 elseif c == ')' || c== ';' || strpart(line, inicio-5, 5) ==? 'endif' 104 elseif c == ')' || c== ';' || strpart(line, inicio-5, 5) ==? 'endif'
105 let ind = ind - shiftwidth() 105 let ind = ind - shiftwidth()
106 elseif c == '(' || c ==? 'f' " '(' or 'if' 106 elseif c == '(' || c ==? 'f' " '(' or 'if'
107 let ind = ind + shiftwidth() 107 let ind = ind + shiftwidth()
108 else " c == '=' 108 else " c == '='
109 " if it is an asignment increase indent 109 " if it is an assignment increase indent
110 if f == -1 " we don't know yet, find out 110 if f == -1 " we don't know yet, find out
111 let f = CdlAsignment(lnum, strpart(line, 0, inicio)) 111 let f = CdlAsignment(lnum, strpart(line, 0, inicio))
112 end 112 end
113 if f == 1 " formula increase it 113 if f == 1 " formula increase it
114 let ind = ind + shiftwidth() 114 let ind = ind + shiftwidth()
115 end 115 end
116 end 116 end
117 endw 117 endw
118 118
119 " CURRENT LINE, if it starts with a closing element, decrease indent 119 " CURRENT LINE, if it starts with a closing element, decrease indent
120 " or if it starts with '=' (asignment), increase indent 120 " or if it starts with '=' (assignment), increase indent
121 if match(thisline, '^\c\s*\(else\|then\|endif\|[);]\)') >= 0 121 if match(thisline, '^\c\s*\(else\|then\|endif\|[);]\)') >= 0
122 let ind = ind - shiftwidth() 122 let ind = ind - shiftwidth()
123 elseif match(thisline, '^\s*=') >= 0 123 elseif match(thisline, '^\s*=') >= 0
124 if f == -1 " we don't know yet if is an asignment, find out 124 if f == -1 " we don't know yet if is an assignment, find out
125 let f = CdlAsignment(lnum, "") 125 let f = CdlAsignment(lnum, "")
126 end 126 end
127 if f == 1 " formula increase it 127 if f == 1 " formula increase it
128 let ind = ind + shiftwidth() 128 let ind = ind + shiftwidth()
129 end 129 end