You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor indentexpr() to fix noindent indentation for lists.
Closesnvim-orgmode#473.
I tried doing small fixes to this code, but kept running into edge
cases. Hence, this complete rewrite. :) The important points:
- The queries in `indent.scm` no longer match on top-level (i.e
un-nested) lists, but instead on list items of all levels.
- List item indentation no longer relies on the previous non-empty line.
Each list item stores whether it's in a top-level or a nested list and
calculates its indent based on that.
- The check whether we are in bulleted line or not no longer uses
`str.match()`, since its pattern was buggy and forgot a few kinds of
bullets. (namely, indented `*` bullets and `a.` ordered bullets)
Instead, we compare the current line number to `match.line_nr`. We can
do that because we query list items instead of lists now.
There is an edge case when the user is appending to a list. We want that
next line to be indented (see nvim-orgmode#472), but it's technically outside of the
list. At the same time, if an unindented line follows a list, it should
not become part of the list.
The best solution I found for this was to make the behavior of
`indentexpr()` depend on whether we are in insert mode. If yes, the line
after a list is part of the list. If not, it isn't.
The new code also correctly takes into account that two consecutive
empty lines always end a preceding list.
0 commit comments