I've been having trouble understanding the behavior defined in GetRSTIndent()
in indent/rst.vim
. I'm specifically using Neovim v0.2.2, but I believe this file has not changed between Vim/Neovim.
Background and Behavior
The specific indent file I'm referring to is on the Neovim GitHub repo at this location.
The effect is as follows:
If I'm typing a list (numbered or bullet point), my indentation always carries over from the previous line, causing too much indentation. For example:
- First item<Enter>
| <-- Cursor here.
- Item one<Enter>
- Item two<Enter>
- Item three
1. This is list item one<Enter>
2. This is list item two<Enter>
3. This is three<Enter>
4. This is four<Enter>
5. This is five
In other words, for me to continue with my list with a new bullet point, I have to press <Backspace>
or <C-D>
to get back to the correct indentation level before typing my next item. (The situation is even more strange with numbered lists; I expect this is a bug.)
I checked on the "markdown"
filetype and it does not have any of this strange indent behavior. In my opinion, the handling of the Markdown is as I would expect, but the handling of reStructuredText is counterintuitive (and, at least for me, a hassle).
Question
My question is two part:
- Why might this behavior be explicitly hardcoded for the
rst
filetype? - Can anyone see a reason why I shouldn't submit this as a GitHub issue for the
indent/rst.vim
file?
If this is this simply undesired/counterintuitive behavior, I'd like to open an issue on the GitHub repo. I just want to make sure I understand the issue clearly. At this point, I know "what" the indent file is doing, but I don't understand "why." The code seems redundant to features (i.e. ':set formatoptions+=n'
) already present in Vim.
Workarounds for Present
For anyone who stumbles on this simply trying to fix the issue, here is how I have been able to do so at present:
Use :set indentexpr=""
to avoid the behavior when editing reStructuredText (or edit the indent/rst.vim
file directly to avoid using GetRSTIndent()
)
If desired, the same affect can be obtained using :set formatoptions+=n
. This also has the benefit of only wrapping when the line wraps automatically according to 'textwidth'
(Instead, the GetRSTIndent()
increases indent every time you press <Enter>
to start a new item--almost certainly not what you want!)
For further ideas on how to handle RST indentation, please also see this question: How to avoid indenting after a line that starts with a number?