fix(lists): skip own indent in smart_return when auto-indent is active
nvim defaults autoindent=on, so the indent inserted by Vim/Nvim after the <CR> we return was being doubled by our own indent prefix — pressing Enter on a sub-item produced a deeper-nested item instead of a same-level one. Detect any auto-indent mechanism (autoindent, smartindent, cindent, indentexpr) and let it own the indentation; otherwise add it ourselves so vim's noautoindent default still works. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -881,7 +881,12 @@ function! nuwiki#commands#smart_return() abort
|
||||
" newline. Indent gets dropped (matches vimwiki's break-out).
|
||||
return "\<Esc>0DA\<CR>"
|
||||
endif
|
||||
let l:cont = l:indent . l:marker . ' '
|
||||
" If any auto-indent mechanism is active (autoindent, smartindent,
|
||||
" cindent, or indentexpr), Vim already inserts the previous line's
|
||||
" indent after `<CR>`. Skipping our own indent in that case avoids
|
||||
" doubling it and pushing the new bullet one level deeper.
|
||||
let l:auto = &autoindent || &smartindent || &cindent || !empty(&indentexpr)
|
||||
let l:cont = (l:auto ? '' : l:indent) . l:marker . ' '
|
||||
if l:has_cb
|
||||
let l:cont .= '[ ] '
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user