vim

2024-06-22T21:56:08.579399Z

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.

emilaasa 2024-08-01T13:38:22.217289Z

I delete all parinfer stuff and use only vim-sexp & the enhancing plugin whatever thats called things and that works fine for me

2024-06-22T21:59:50.753249Z

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!

2024-06-22T22:43:59.049149Z

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.

dave 2024-06-23T00:01:08.810549Z

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.

dave 2024-06-23T00:02:33.541719Z

Paredit also gives you structural editing, although I'm not sure whether or not it can be used together with vim-sexp.

2024-06-23T00:04:07.249029Z

I think paredit and vim-sexp provide very similar functionality. the vim-sexp README actually mentions "always balanced, like paredit.el."

2024-06-23T00:04:14.757089Z

anyway this is working now.

dave 2024-06-23T00:04:56.563719Z

Good to hear!

practicalli-johnny 2024-06-24T17:01:25.208549Z

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.

practicalli-johnny 2024-06-24T17:12:30.069659Z

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.

practicalli-johnny 2024-06-23T08:34:00.871369Z

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)

2024-06-23T11:33:38.166019Z

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].

practicalli-johnny 2024-06-23T14:10:56.279839Z

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.

2024-06-23T22:29:30.661659Z

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.

2024-06-23T22:54:38.771339Z

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.