Fix: Indentation broken within lists (Issue #991)

Side effect, formatoption+=c in order to also keep the joining behavior
with lists
This commit is contained in:
Tinmarino 2020-08-23 01:59:12 -04:00
parent d1b3fe34c9
commit 817641e551
2 changed files with 52 additions and 6 deletions

View File

@ -144,20 +144,25 @@ for bullet in vimwiki#vars#get_syntaxlocal('bullet_types')
" task list
for point in vimwiki#vars#get_wikilocal('listsyms_list')
\ + [vimwiki#vars#get_wikilocal('listsym_rejected')]
let comments .= ',b:' . bullet . ' [' . point . ']'
let comments .= ',fb:' . bullet . ' [' . point . ']'
endfor
" list
let comments .= ',b:' . bullet
let comments .= ',fb:' . bullet
endfor
let &l:comments = comments
" Set format options (:h fo-table)
" Disable autocomment because, vimwiki does it better
setlocal formatoptions-=c
setlocal formatoptions-=r
setlocal formatoptions-=o
setlocal formatoptions-=2
" Autowrap with leading comment
setlocal formatoptions+=c
" Do not wrap if line was already long
setlocal formatoptions+=l
" AutoWrap inteligent with lists
setlocal formatoptions+=n
let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem')
" Used to join 'commented' lines (blockquote, list) (see: #915)
if v:version > 703
setlocal formatoptions+=j
@ -167,9 +172,6 @@ endif
let &l:commentstring = vimwiki#vars#get_wikilocal('commentstring')
let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem')
" ------------------------------------------------
" Folding stuff
" ------------------------------------------------

View File

@ -4,6 +4,50 @@
# better read this file with `set list`
Given vimwiki (List will hard wrap (Issue #991):
- one two three four five six seven
Execute (Change textwith):
let textwidth = &textwidth
let linebreak = &linebreak
Log 'Textwidth, Linebreak was: ' . textwidth . ', ' . linebreak
set textwidth=40
set linebreak
Do (Insert more than tw and press return):
A indented line 1
\<Cr>
indented line 2
Expect (Indentation after autowrap and <CR>):
- one two three four five six seven
indented line 1
indented line 2
Do (o new item):
A indented line 1
\<Esc>o
new item
Expect (New item created):
- one two three four five six seven
indented line 1
- new item
Do (VimwikiReturn 3 5):
A indented line 1\<Esc>
:VimwikiReturn 3 5\<Cr>
new item
Expect (New item created):
- one two three four five six seven
indented line 1
- new item
Execute (Restore textwith):
let &textwidth = textwidth
let &linebreak = linebreak
Given vimwiki (List with hard wraps):
- Item 1
- Item 2