better breakindent for numbered/bulleted lists#8564
better breakindent for numbered/bulleted lists#8564chrisbra wants to merge 3 commits intovim:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8564 +/- ##
==========================================
- Coverage 90.03% 89.68% -0.35%
==========================================
Files 150 150
Lines 168219 167582 -637
==========================================
- Hits 151462 150302 -1160
- Misses 16757 17280 +523
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
Hm, it might be possible. If you use the formatlistpat on such a line using |
|
lol we have used wrong position of the args |
|
|
I was more thinking, that when using |
|
To be clear, yes, using indent of the matched |
| if (regmatch.regprog != NULL && vim_regexec(®match, line, 0)) | ||
| { | ||
| vim_regfree(regmatch.regprog); | ||
| bri += wp->w_briopt_list; |
There was a problem hiding this comment.
Should it be smth like
› › bri += wp->w_briopt_list > 0 ? wp->w_briopt_list : len(regmatch???);
provided there is another condition in the outer if (wp->w_briopt_list > 0 || wp->w_briopt_list == -1)
For the formatlistpat indentation?
There was a problem hiding this comment.
having formatlistpat and set briopt+=list:-1 +
// add additional indent for numbered lists
if (wp->w_briopt_list > 0 || wp->w_briopt_list == -1)
{
regmatch_T regmatch;
regmatch.regprog = vim_regcomp(curbuf->b_p_flp,
RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT);
if (regmatch.regprog != NULL)
{
if (vim_regexec(®match, line, 0))
if (wp->w_briopt_list > 0)
bri += wp->w_briopt_list;
else
bri += (*regmatch.endp - *regmatch.startp);
vim_regfree(regmatch.regprog);
}
}
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a
Problem: 'breakindent' does not work well for bulleted and numbered lists.
Solution: Add the "list" entry to 'breakindentopt'. (Christian Brabandt,
closes vim/vim#8564, closes vim/vim#1661)
vim/vim@4a0b85a




Detecting bulleted or numbered lists and applying an additional indentation for soft-wrapping is a bit of a popular request (see #1661). So here is a PR, that implements this. It makes use of the 'formatlistpat' option setting to detect such lines and if they match, Vim applies an additional indent, that can be specified using
:set breakindentopt+=list:{n}. By default this is not set. This works currently best in combination with the 'linebreak' setting.It also adds some tests to make sure it works correctly and also adds some documentation.