Open madox2 opened 7 years ago
+1 same issue here
I've got
function render() {
return (
|
)
}
expected:
function render() {
return (
|
)
}
The issue happens only for parens, for braces everything is ok
+1 same here
+1 same here. Anybody has solution????
+1 same here
Is there a solution for this?
Lunarwatcher/auto-pairs#26 Lunarwatcher/auto-pairs#27 (tl;dr: fix your indent config)
Thanks @LunarWatcher , I forgot to mention that this only happens when writing javascript in a file that contains JSX (it can be a .js or .jsx) and inside a function or class method. Here's a screenshot. If I use something different than vim polyglot then it works fine.
The second TL;DR: on this topic is that auto-pairs doesn't actually do what the docs promise, in terms of:
Input: (|) <cr> at |
Output: (
|
)
Because it has to respect a number of systems. In practice, all it does is <CR>=ko
(or enter, format one up, create and jump into insert mode on the line under).
As a consequence, bad indent functions does make auto-pairs "misbehave" in the sense that it doesn't do what the docs promise, but it does respect how Vim was configured. And to be clear, polyglot isn't the only way out. It too can have bugs - use whatever plugin works for your use, or write an indentexpr
if you know how and have some time to kill (or just because you want to). Having a language-portable way to do what the docs promise without relying on the indentexpr for the language to work like it should, though, is a lot harder to implement than it is to use indentexprs. (in theory, anyway. I've tried and failed to do that in a way that just works regardless of the indentexpr and other style options - and that was even prior to accounting for spaces and tabs)
When using this plugin together with vim-javascript, indentation of parentheses is wrong after new line. I have following js code:
After pressing ENTER:
Notice that last parenthesis is not indented.
Also see https://github.com/pangloss/vim-javascript/issues/663