vim

For discussion on all things (neo)vim.
Aron 2021-05-17T00:21:52.170800Z

Trying to use vim sexp and for 10 minutes continuously every time I did something to the code, something completely surprising happened that I didn't understand even after undoing and retrying. It creates errors in the code and then doesn't let me fix them.

Aron 2021-05-17T08:52:47.171800Z

Bunch of demos on what the different motions do, but when the form doesn't fit the screen, and there are errors in the code, it's really hard to see what happens

orestis 2021-05-17T09:40:01.173Z

I'm using the "vim-sexp-mappings-for-regular-people" or whatever the name is, but in the end I've mapped ctrl-<left> and ctrl-<right> in insert mode and use only those. Everything more advanced (even in paredit) confuses me to no end 🙂

grazfather 2021-05-17T12:38:36.174600Z

I find most of the sexp libs infuriating for the same reason. I don’t like being surprised by that. For example, if i want to close a parens and accidentally type a square bracket, I can’t delete the square bracket and then type a close paren because deleting the close bracket deletes the opening paren!

grazfather 2021-05-17T12:39:17.175300Z

I use emacs mostly for lisp now, and similar to orestis I have disabled most everything except for ‘move sexp within sexp’ and ‘barf/spit’

orestis 2021-05-17T13:26:22.176300Z

Thankfully vim allows me to drop out of insert mode and delete whatever I damn please 🙂 Please the generic dab or with vim-surround dsb work nicely with lisps.

NoahTheDuke 2021-05-17T13:37:04.176600Z

vim-sexp is tough, but sexp-for-regular-people is nice

NoahTheDuke 2021-05-17T13:37:27.177100Z

&gt;) and &lt;) are very helpful for moving enclosing brackets

Aron 2021-05-17T18:03:54.181300Z

can someone who uses vim-sexp with or without the tpope mappings tell me how to have the same effect that parinfer has on indentation? move the block left or right, changing only indentation and moving the parens such that they are balanced? What is weird that everyone talks about structural editing that it's about never getting the code into an incorrect state, but it's actually very easy to achieve that

dominicm 2021-05-18T20:17:54.003900Z

&gt;)=ie with tpope &lt;M-S-l&gt;=ie without tpope. Alternatively use &gt;ie instead of =ie dependent on what you're after.

(ns foo)
(:require)
From cursor anywhere in (ns foo)

dominicm 2021-05-18T20:18:14.004100Z

I never get the code into a correct state when using vim-sexp.

Aron 2021-05-18T20:54:12.004300Z

you mean incorrect I guess?

Aron 2021-05-18T20:54:53.004500Z

I have incorrect when I move code around, especially when I move it into some temporary place, or when I copy it from github, same repo, but doing a git checkout --patch is not always the easiest

Aron 2021-05-18T21:08:33.005100Z

I need to try these shortcuts, but first read them again from scratch how they are composed. On an unrelated note, it does seem everything got a bit more complicated, like adding a new line in a list was just pressing o at the end of the previous list and the parens were moved automatically, but now I have to &gt;I and <enter>

Aron 2021-05-18T21:09:06.005400Z

so five keys instead of one

dominicm 2021-05-19T15:07:14.006200Z

Oops, I did mean incorrect yes 😄

dominicm 2021-05-19T15:08:17.006400Z

Parinfer is great for certain kinds of operation 🙂 I really like the vim-sexp model as it gives me more re-use & power though. There's just different properties to each of them really.

Aron 2021-05-19T15:16:25.006600Z

What I started to realize is just how many steps I have to step back before I can use these mappings, lots of things that I just do automatically relied on the editor formatting my code from incorrect to correct, or giving me an error where it was incorrect. Before cljs I wrote mostly js and I used to just copy paste code and data between files, often commenting out several lines and only after a bunch of these changes to a file started I fixing up the syntax errors.

Aron 2021-05-19T15:17:42.006800Z

Now I have to think first about how to format the stuff before I move it into the file. I can see the benefits, but ultimately I like the relaxed paradigm more.

dominicm 2021-05-22T15:21:06.010500Z

I don't have these problems because I copy using vim-sexp, which means my copies are perfectly valid syntax too. e.g. yaf is a common operation for me.

Aron 2021-05-22T15:52:51.010700Z

Sure, that is the case when the place you copy from is well formatted. I am working on the frontend, and no one else uses clojure around me. So the places I copy from atm. are rarely well formatted S-expressions or opened in vim at all. : )

dominicm 2021-05-22T20:04:50.010900Z

I don't really understand your use case, it sounds like you're not copying clojure code.

Aron 2021-05-22T20:45:43.011100Z

that's what I said

NoahTheDuke 2021-05-17T18:09:46.182300Z

i don't think either handles indentation like that. i usually use the keybinds i mentioned to push the surrouding parenthesis to sexp before or after a given block, and then =iP to reindent the whole paragraph

Aron 2021-05-17T18:23:37.182700Z

I see, that would be a nice thing to not lose

dave 2021-05-17T19:43:01.183800Z

FWIW, I use parinfer AND vim-sexp with the tpope mappings, and it works well 🙂

dave 2021-05-17T19:43:15.184100Z

The 3 plugins are complementary.

dave 2021-05-19T18:51:55.008300Z

I had that problem a long time ago, but haven't noticed it anytime recently. I think (and have read that) they've fixed it. I'm also in the habit of leaning heavily on git when trying experiments, e.g. I'll make a branch to try out an idea, and if it doesn't work out I just switch back to the branch I was on before. I rarely need to undo more than a few times in a row.

Aron 2021-05-19T19:04:06.008600Z

They haven't fixed it for me, this is why I am learning these other mappings. Every couple of hours at least I had to turn parinfer off, do the undo/redo i wanted, then turn it back on. Otherwise it just kept repeating a no-op.

Sigve 2021-05-24T10:12:13.011700Z

I also encounter the undo-bug often. Which is keeping me from using parinfer at the moment

Aron 2021-05-24T10:43:28.011900Z

same, I would use it happily, but I suspect something I do is very unexpected, or maybe some conflict with another plugin

2021-05-17T20:06:37.184700Z

btw =- will reindent the entire top level form, saves some clicks / shift key chording

2021-05-18T12:11:58.000600Z

I've never gotten the order wrong, strangely

2021-05-18T12:12:51.000800Z

wait - do you mean that you don't like the rules auto-indent uses?

2021-05-18T12:14:07.001Z

my solution is to just use code layouts that auto indent agrees with (all -= does is move one line up, then wait for a movement command for indentation scope, so I misunderstood you at first) anyway, this was a reply to the comment above about using =iP which does the same thing with more awkward keypresses

2021-05-18T12:14:19.001200Z

should have put it in that thread actually

2021-05-18T12:16:27.001400Z

I have a hard grudge against parinfer after a work scenario where one coworker would check in badly indented code, and another would let intellij move all the parens to match the bad indentation and check that in

2021-05-18T12:17:21.001600Z

anyway, it sounds like you don't want text objects for sexps etc. and you just want parinfer, I'm surprised if nobody ever made parinfer for vim

Aron 2021-05-18T17:05:04.002600Z

> wait - do you mean that you don't like the rules auto-indent uses? definitely not that, no, what I mean is that no one would like the result, lines get indented incorrectly, this never happens to you? My setup must be faulty then.

2021-05-19T14:38:28.005600Z

as long as I indent the whole form, I've never had an issue (though my preferences might be different from others and I'm sure there's corner cases I avoid by restricting where I put line breaks)

Aron 2021-05-19T14:54:43.005800Z

I think I found the culprit, and it was my setup, I had another extension enabled that auto-changed shiftwidth, because I used to edit js files, and for some reason in certain cljs files it set it to 10... so when I was indenting, it ended up all weird and unreasonable. Sorry for faulting sexp for this, clearly it had nothing to do with it.

Aron 2021-05-19T14:55:36.006Z

I removed the plugin and now I started using == because easy to remember, I have no idea how indentation works yet, but it makes the code follow the current parens, so I can change the parens then run == again and it kinda works.

2021-05-19T15:21:36.007Z

I don't know your setup, but for me == only looks at the line directly above, and when I'm doing things like renesting forms I need =- which fixes the entire top level form

Aron 2021-05-19T15:53:27.007800Z

I think it was just easier to remember ==, I will try to use =i