-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pressing enter inside brackets destroys indentation #372
Comments
Nope, blame Vim (or whatever formatter it is you're using). Auto-pairs uses
This is why auto-pairs relies on a formatter. I use a non-standard (but by no means uncommon) formatter. You can basically shove in any formatter you want in Vim (with at least a little vimscript anyway), which means any static system relying on the default formatter is going to fail. If you don't like the format output, you need to configure your formatter, vim, or find a new formatter. In my case, or if you're using Vim's built-in formatter, use let g:html_indent_style1 = "inc" and you get
Other valid options (see vim/vim#3205 (comment)) appear to be auto (which aligns it with the start of the Auto-pairs does auto-format, but it isn't a formatter. The bug (or in this case, misconfiguration) is therefore usually elsewhere. Would be great if the formatting options were in a standardised format so it isn't necessary to have individual options for things in different languages, but it is what it is right now. |
That feels needlessly complicated. Without the plugin, the motion that one does is: Can I (user) disable that? Pressing enter after an open bracket should do something as simple as |
I've found the issue. On line 416 of
has to be be replaced with
for anyone else experiencing this issue. Perhaps someone out there prefers the current behavior, so I suggest a configurable option, e.g. |
Pressing enter inside brackets often messes up indentation.
Example
I created an example and reproduced the problem, even upon opening Vim with no other plugins and no vimrc.
Open an HTML file and type the following. The █ character represents the position of the cursor in insert mode.
Next, in insert mode, type enter (
<CR>
).Expected result
I'd expect indentation to be preserved.
Actual result
The indentation is completely reset to 0.
If this is intended behavior, then there must be a way to turn this off. Perhaps the plugin is trying to "intelligently" recognize that I am not inside any curly braces, so it tries to establish the braces as being at root-level indentation. This is far too crude to be useful in most situations. In this situation, I think most people would much prefer the plugin to just blindly type
<CR><BS><c-o>O
instead of this sort of "smart" indentation.The text was updated successfully, but these errors were encountered: