" Last Change: 2022 Jun 17
" 2024 Feb 29 by Vim project: disable mulitline indent by default
" 2024 Aug 14 by Vim project: fix re-indenting when commenting out lines
+" 2026 Jan 08 by Vim project: fix object indentation in array
" Only load this indent file when no other was loaded.
if exists('b:did_indent')
"
" - |-
" Block scalar without indentation indicator
- return previndent+shiftwidth()
+ if prevline =~# '^\s*-\s.*:$'
+ " Special case: list item with mapping key (- key:)
+ " Need to account for the "- " prefix
+ return previndent + 2 + shiftwidth()
+ else
+ return previndent+shiftwidth()
+ endif
elseif prevline =~# '\v[:-]\ [|>]%(\d+[+\-]?|[+\-]?\d+)%(\#.*|\s*)$'
" - |+2
" block scalar with indentation indicator
let prevmapline = s:FindPrevLEIndentedLineMatchingRegex(a:lnum,
\ s:mapkeyregex)
if getline(prevmapline) =~# '^\s*- '
- return indent(prevmapline) + 2
+ " Previous mapping key is in a list item (- key:)
+ " The key effectively starts at indent + 2 (after "- ")
+ " Content under it should be indented relative to the key position
+ return indent(prevmapline) + 2 + shiftwidth()
else
return indent(prevmapline)
endif