comparison runtime/indent/vim.vim @ 23931:5b37a0bf7e3a

Update runtime files Commit: https://github.com/vim/vim/commit/942db23c9cb7532d68048530d749eb84ca94d0cd Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 13 18:14:48 2021 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Feb 2021 18:15:04 +0100
parents 34b4eb3a8458
children ef454a7f485d
comparison
equal deleted inserted replaced
23930:4997281ea56c 23931:5b37a0bf7e3a
1 " Vim indent file 1 " Vim indent file
2 " Language: Vim script 2 " Language: Vim script
3 " Maintainer: Bram Moolenaar <Bram@vim.org> 3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last Change: 2021 Jan 21 4 " Last Change: 2021 Feb 13
5 5
6 " Only load this indent file when no other was loaded. 6 " Only load this indent file when no other was loaded.
7 if exists("b:did_indent") 7 if exists("b:did_indent")
8 finish 8 finish
9 endif 9 endif
97 endif 97 endif
98 elseif prev_text =~ '^\s*aug\%[roup]\s\+' && prev_text !~ '^\s*aug\%[roup]\s\+[eE][nN][dD]\>' 98 elseif prev_text =~ '^\s*aug\%[roup]\s\+' && prev_text !~ '^\s*aug\%[roup]\s\+[eE][nN][dD]\>'
99 let ind = ind + shiftwidth() 99 let ind = ind + shiftwidth()
100 else 100 else
101 " A line starting with :au does not increment/decrement indent. 101 " A line starting with :au does not increment/decrement indent.
102 if prev_text !~ '^\s*au\%[tocmd]' 102 " A { may start a block or a dict. Assume that when a } follows it's a
103 " terminated dict.
104 if prev_text !~ '^\s*au\%[tocmd]' && prev_text !~ '^\s*{.*}'
103 let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|fu\%[nction]\|def\|el\%[seif]\)\>\)') 105 let i = match(prev_text, '\(^\||\)\s*\(export\s\+\)\?\({\|\(if\|wh\%[ile]\|for\|try\|cat\%[ch]\|fina\|finall\%[y]\|fu\%[nction]\|def\|el\%[seif]\)\>\)')
104 if i >= 0 106 if i >= 0
105 let ind += shiftwidth() 107 let ind += shiftwidth()
106 if strpart(prev_text, i, 1) == '|' && has('syntax_items') 108 if strpart(prev_text, i, 1) == '|' && has('syntax_items')
107 \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\)$' 109 \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\)$'
150 " todo: use searchpair() to find a match 152 " todo: use searchpair() to find a match
151 endif 153 endif
152 endif 154 endif
153 155
154 " Below a line starting with "]" we must be below the end of a list. 156 " Below a line starting with "]" we must be below the end of a list.
155 if prev_text_end =~ '^\s*]' 157 " Include a "}" and "},} in case a dictionary ends too.
158 if prev_text_end =~ '^\s*\(},\=\s*\)\=]'
156 let ind = ind - shiftwidth() 159 let ind = ind - shiftwidth()
157 endif 160 endif
158 161
162 let ends_in_comment = has('syntax_items')
163 \ && synIDattr(synID(lnum, col('$'), 1), "name") =~ '\(Comment\|String\)$'
164
159 " A line ending in "{"/"[} is most likely the start of a dict/list literal, 165 " A line ending in "{"/"[} is most likely the start of a dict/list literal,
160 " indent the next line more. Not for a continuation line. 166 " indent the next line more. Not for a continuation line or {{{.
161 if prev_text_end =~ '[{[]\s*$' && !found_cont 167 if !ends_in_comment && prev_text_end =~ '\s[{[]\s*$' && !found_cont
162 let ind = ind + shiftwidth() 168 let ind = ind + shiftwidth()
163 endif 169 endif
164 170
165 " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry, 171 " Subtract a 'shiftwidth' on a :endif, :endwhile, :catch, :finally, :endtry,
166 " :endfun, :enddef, :else and :augroup END. 172 " :endfun, :enddef, :else and :augroup END.