vim

sheluchin 2022-09-15T13:11:04.206329Z

Does anyone know how to fix this issue? If I'm in a form and use <LocalLeader>i (vim-sexp's wrap compound form with ()), I get misaligned sub-forms. I'm using vim-sexp with rust-parinfer.

sheluchin 2022-09-17T10:44:19.400299Z

@leafgarland yeah, I've tried that. Okay, you guys have convinced me, I guess it's time I rebuild my config.

Martynas Maciulevičius 2022-09-17T13:37:39.385899Z

You don't need to rebuild, you only need to do a binary search šŸ¤”

sheluchin 2022-09-17T16:48:14.267579Z

I think it all basically comes down to let g:parinfer_mode = 'smart' not behaving how I expect. If I change it to paren, it's much better in most cases, but doesn't seem to auto-balance parenthesis anymore.

sheluchin 2022-09-16T12:32:46.422449Z

(list
 1
 2)

() (list)
 1
 2
What the heck is up with my setup?

šŸ‘€ 1
2022-09-16T13:03:44.006219Z

hah I don't know but something is definitely happening here

Martynas Maciulevičius 2022-09-16T18:00:49.177039Z

Your config is very smart. That's what's happening šŸ˜„ It's smarter than you even though you're the author šŸ˜„ We're doomed.

šŸ˜… 1
Leaf Garland 2022-09-16T18:30:55.454069Z

Have you turned off vim-sexp insert mode maps? Parinfer docs say it works better without them.

reborg 2022-09-15T13:14:55.189379Z

I normally realign after the changes with =ip

āž• 1
sheluchin 2022-09-15T13:21:24.413099Z

@reborg doesn't work with less trivial forms where the indents cross over after getting disbalanced

reborg 2022-09-15T13:28:14.084869Z

Not sure, could be different env? If I copy the above and insert set hit esc and then =ip I get:

(set (vec
      (list 
       1 
       2)))

Martynas Maciulevičius 2022-09-15T13:40:59.783059Z

I auto-format on save šŸ¤” So I don't even need to do = šŸ¤”

2022-09-15T14:28:17.364599Z

i don't think vim-sexp works with parinfer for that reason. vim-sexp doesn't move any other forms when wrapping forms, and parinfer works immediately to "balance" things

2022-09-15T14:28:56.191249Z

is there a command parinfer has that mirrors the vim-sexp wrap-and-enter-insert commands?

sheluchin 2022-09-15T14:30:58.128789Z

https://github.com/eraserhd/parinfer-rust/blob/9e41222b7bc8930e24c411c1b4bc48715975ed17/doc/parinfer.txt#L21-L23 Hmm, this would lead me to believe that it does/should work with parinfer.

sheluchin 2022-09-15T14:51:48.521149Z

> is there a command parinfer has that mirrors the vim-sexp wrap-and-enter-insert commands? I don't believe so.

Martynas Maciulevičius 2022-09-15T14:55:25.418599Z

Well if somebody has been pressing <localleader>i and then after that pressing =ip then you could make a function that would insert your text and then call =p automatically. Then you would be typing in the command window but it would be immediately formatted once all of the motions happen šŸ¤”

sheluchin 2022-09-15T14:58:05.182589Z

Yeah, but the =ip doesn't work for me anyway, not in cases like I showed above, which are common in real code. I actually have autoformat on save too, but nothing will really work if the indents get misaligned badly enough. It's that initial misalignment I'm trying to prevent. If, like @reborg, others are unable to reproduce the behaviour I'm seeing, I guess the only thing left is to binary search my config until I get to the bottom of it.

Martynas Maciulevičius 2022-09-15T15:15:51.615559Z

So does the formatting format in a bad way then? Or is it only during <localleader>i and after that the file saving fixes it? If I understand correctly you say that after you use this binding the formatting plugin doesn't even format the code correctly anymore šŸ¤”

sheluchin 2022-09-15T15:22:33.376069Z

I think if you have the code really misaligned, the autoformatting can't make a good guess anymore. e.g. I don't think any autoformatting tool can guess that the 2 here belongs to the list:

(identity (list 1)
          2)

Martynas Maciulevičius 2022-09-15T15:25:59.073379Z

I don't understand why 2 could belong to a list in your example either. Maybe the outer () but not (list 1) but then why do you call the outer call a list. It is a list because it's a list language but why would your next item belong to a list that you close yourself? Maybe you wanted to write this:

(identity (list 1
          2))
But then it's formatted this way:
(identity (list 1
                2))
For me I can write this:
(list 1
      2)
Then press <localleader>i and type identity to get this:
(identity (list 1
      2))
Then exit insertion mode and save the file to get this:
(identity (list 1
                2))

sheluchin 2022-09-15T15:32:35.113199Z

I'm saying that if I start with this form:

(list 1
      2)
that's all well and good. But when I try to wrap it in another function call by doing <LocalLeader>iidentity, I end up with something that can't be autoformatted like:
(identity (list 1)
          2)
because of the typing lag bug in parinfer. It happens inconsistently depending on typing speed and I guess system latency or something... the longer the wrapping function name, the worse it gets.

sheluchin 2022-09-15T15:33:25.666229Z

ie. parinfer lags behind and closes the bracket when the alignment of the 2 gets behind the opening ( of list.

Martynas Maciulevičius 2022-09-15T15:50:35.894079Z

I don't use parinfer or similar plugins because they interfere with the parens that I like to destroy in the middle of my expression. And I want to delete and add new parens. This is the same reason why I don't like auto paren inference balancing. It's nice but it prevents me from deleting parens that I want to delete. And this is limiting because I sometimes want to destroy forms.

Leaf Garland 2022-09-15T22:23:09.950109Z

I use parinfer, and achieve the same edit by adding the start paren and letting parinfer add the end one.

Martynas Maciulevičius 2022-09-16T05:50:28.152199Z

So i(identity ? And not via vim-sexp?

Leaf Garland 2022-09-16T05:55:51.217769Z

Yes

šŸ‘ 1