I'm trying to get the new AstroNvim-based Practicalli Vim set up nicely. it's mostly working well, but there's one serious pain point that I haven't been able to sort out.
what I want: to write explicit parens and have them always be balanced. I use structural editing with vim-sexp and vim-sexp-mappings-for-regular-people to wrap, unwrap, slurp and barf while editing; that part works. while typing new code I want typing a ( [ or { to always add the closing counterpart, with the cursor in between them.
what I'm getting: usually the closing paren is added nicely, but sometimes (🧵) it doesn't happen. I've been messing with the autopairs setup, but either my config isn't really being applied or I'm messing with the wrong setting.
I delete all parinfer stuff and use only vim-sexp & the enhancing plugin whatever thats called things and that works fine for me
the problem seems to be if there's closing parens of the same kind on this line, and their opening counterparts are farther up:
{:some :map
:cursor |}
;; cursor at the | above.
;; now if I type a { I want this:
{:some :map
:cursor {|}}
;; but I get this:
{:some :map
:cursor {|}
;; and my parens are unbalanced!I hesitate to speak too soon, but I think I sorted this out. I was looking at a disabled plugin file and trying to set opts.features there. when I finally fixed that up and started setting it in a running file, setting opts = { features = { autopairs = false } } on astrocore there got things working with vim-sexp's insert mode mappings.
I think what you're describing is paredit. I used an older paredit plugin a long time ago and it worked like that - it ensured that your parens were always balanced, but you still typed them explicitly. I haven't used paredit in years (at some point, I switched to the parinfer camp), but nowadays, you could give a plugin like https://github.com/julienvincent/nvim-paredit a try.
Paredit also gives you structural editing, although I'm not sure whether or not it can be used together with vim-sexp.
I think paredit and vim-sexp provide very similar functionality. the vim-sexp README actually mentions "always balanced, like paredit.el."
anyway this is working now.
Good to hear!
If I disable nvim-parinfer but keep nvim-treesitter-sexp enabled, when inserting an { for the :cursor value, there has to be a space before the outer } of the hash-map. If not, then the closing } is not added and the hash-map is unbalanced.
It does seems that vim-sexp hs the most complete set of commands for structural editing. I assume that it could be used without the other plugins. I wouldn't know what if any commands would be missed. It seems unusual to use 3 plugins, but if it makes for a better workflow then it sounds worth it.
Not sure what was changed but your example works correctly with the Practicalli Astro config when I tried this morning.
Practicalli Astro includes https://github.com/PaterJason/nvim-treesitter-sexp plugin for paredit style structural editing, via the Astro Community Clojure pack (its also its own Astro Community pack in editing-support)
There is also nvim-parinfer, which can be configured to a paredit mode rarher than an indent mode.
I havent used the vim-sexp plugins myself.
For nvim-paredit, example config is in the lua/plugins/clojure.lua file (inactive by default)
yeah, this was self-inflicted for sure. I've tried several times to like parinfer in paren mode, but there's a few things that just don't work for my tastes. maybe I should try it again, but with the vim-sexp style element and form navigation for [wbeWBE].
I appreciate existing tool use is hard to change. especially if there isn't a percieved need. If there is useful config or example config to add to Practicalli Astro, let me know.
is https://clojurians.slack.com/archives/C0DF8R51A/p1719093590753249?thread_ts=1719093368.579399&cid=C0DF8R51A supposed to Just Work if I (1) setup the default Practicalli Vim, and (2) comment parinfer for paredit? nobody seems to provide the insert mode mappings from vim-sexp. nvim-autopairs has got Java brain - who would open new parens/brackets/braces right before a closing one of the same type? I keep unbalancing my parens if it just happens to be before a closing paren of the same type and the opening mate isn't on this line. it's infuriating.
I've resorting to loading vim-sexp along with nvim-paredit and nvim-treesitter-sexp (which work great for everything else but insert mode) and then disabling the regular mappings of vim-sexp with vim.g.sexp_mappings = {}. then it only installs the insert mode ones.
this all strikes me as really braindead, but it seems to be working how I want.