Hi all! I'm looking into moving over from Emacs (+Evil +Cider) to VS Code (+Vim mode +Calva), but I can't find the solution to a problem I have. On Emacs, using Cleverparens I'm able to achieve a setup where I have to fight really hard to end up in a structurally unbalanced state, while whatever combination of Parinfer + Paredit versions and settings I use, the experience is pretty bad. In these recordings I delete lines (dd), undo changes (u) and then add some content to an expression. While it's pretty nice in Emacs, in VS Code I end up having really weird stuff happening, such as unbalanced states, especially with undo, non-paren characters disappearing, pairs disappearing and all kinds of other weirdness. This is Parinfer's Smart mode (from https://marketplace.visualstudio.com/items?itemName=kress95.vscode-parinfer-kress95 ) with Calva's Paredit in Strict mode. I've tried all kinds of other combinations, but no luck. What am I missing here? Is there a recommended way of setting up VS Code for vim-ish editing and strict structural balance? Thanks!
What happens without Parinfer?
Both in paredit original and strict mode whenever I do "dd" on the last line, the line is fully deleted, without any parens remaining either on that line or above - structural balance is gone immediately. Same happens if I do the "Delete Line" command from the palette, so it's not a vim mode thing.
(This is with parinfer disabled on the extension level)
Yeah, without parinfer nothing is going to attempt to restore the structure. What happens with Calva disabled and Paredit enabled?
Same as with Calva enabled
Cleverparens actually does a https://github.com/emacs-evil/evil-cleverparens/blob/6637717af0bdac55f97eef98433d53a10395cf77/evil-cleverparens.el#L654 to make this happen on Emacs, so maybe that's something that was just not implemented anywhere for VSC?
Seems like that Parinfer extension is trying to do the work. Afaik no one had succeeded. I don’t think many people using VS Code for lispy things use Parinfer. We use paredit instead.
And I think the number of folks using VS Code + Vim mode with a Lisp is pretty small too which is why this hasn't come up much before?
It’s not really about Vim, @seancorfield. It’s about the less stellar Parinfer experience. There are quite a few people who have tried solve it, me included: • https://x.com/pappapez/status/1461018167002734592 • https://x.com/pappapez/status/1457646079961440259 I think it may get extra accentuated among Vim users, since many popular Vim commands operate on lines, maybe due to its ed heritage.
Yeah, I was thinking more about the line-oriented nature of several vi commands...
I used Parinfer for a hot minute and just got annoyed with it doing weird stuff on paste so I gave up and went back to plain ol' Paredit (strict).
(I have enough hassles with Copilot inserting mismatched closing brackets!)
Cleverparens' approach is different from Parinfer though (indentation doesn't play any role here) - what it does is more rooted in paredit.
https://github.com/emacs-evil/evil-cleverparens?tab=readme-ov-file#romanevil-paredit, talking about evil-paredit:
> evil-cleverparens originally started out as a fork of this project, with the goal of doing something useful instead of throwing an error in situations where it would make sense.
For my personal workflow and muscle memory this is extremely useful - I very rarely think of balancing pairs even when doing relative coarse-grained changes, such as line or multi-line deletion. My code stays balanced and - in most cases - meaningful.
But yes, I also see that this is not the typical editing method in the VS Code community.