Fork me on GitHub
#vim
<
2019-04-29
>
dharrigan11:04:50

I'm having a little problem getting to grips with vim(-fireplace) and vim-sexp and vim-sexp-mappings-for-regular-people. I can't seem to get slurpage to work as I thought it might. Here's a simple example:

dharrigan11:04:07

(defn foo
  ([] (foo nil))
  ([config])
  (println config))

dharrigan11:04:35

I'm trying to slurp (println config) into the ([config]) expression to end up with ([config] (println config)))

dharrigan11:04:27

Using vim-sexp-mappings...., I place my cursor on the ) at the end of ([config])

dharrigan11:04:22

and I tried <) and <( etc..

dharrigan11:04:45

but nothing I type ends up with the result I want.

dharrigan11:04:52

Anyone got any ideas?

tvirolai11:04:56

>) should do it

dharrigan11:04:42

doesn't appear to. If I try that, the form remains the same, but the cursor jumps to the ( at (defn foo

dominicm11:04:12

Check :nmap to see what it's mapped to

dharrigan11:04:14

(sorry, it jumps to the end of the entire form

dharrigan11:04:59

n  <(           @<Plug>(sexp_capture_prev_element)                                                                                        
n  <)           @<Plug>(sexp_emit_tail_element)

dharrigan11:04:45

n  >)           @<Plug>(sexp_capture_next_element)                                                                                        
n  >(           @<Plug>(sexp_emit_head_element)  

dharrigan11:04:05

Something is getting in the way I suspect. I think what I'll need to do is disable, then re-enable plugins one at a time to narrow this down.

tvirolai11:04:26

Those mappings look fine, strange.

dharrigan11:04:34

Yup. I'll try to figure it out by stripping vim down, then re-enabling plugins one-at-a-time

dharrigan11:04:38

until something breaks πŸ™‚

dharrigan11:04:27

so far, enabling vim-sexp and vim-sexp-mappings..., with the suggestion of >) works, so something else in my plugins is doing something naughty...

dharrigan12:04:32

eraserhd/parinfer-rust

πŸ‘Œ 8
dharrigan12:04:05

with that enabled, the mapping doesn't work, or rather, I suspect it does work, but then parinfer-rust is doing something to rebalance the parens

dharrigan12:04:36

yup, retested, confirmed. It's that. What do people use then to rebalance the parens?

dominicm12:04:32

That makes sense

dharrigan12:04:40

If I set let g:parinfer_mode='paren' it works

dominicm12:04:14

So, I don't use parinfer at all. It takes a slightly different approach to this though, because of indentation. So you would need to do >> on the println

dharrigan12:04:17

Paren Mode gives you full control of parens, while Parinfer corrects indentation

dominicm12:04:42

Yeah, you would be in the realm of manually switching then. Usually smart mode can just do the job.

dharrigan12:04:07

Let me try something...

dharrigan12:04:48

Unfortunately, if I try ">>" on the println, it ends broken, i.e.,

dharrigan12:04:57

(defn foo
  ([] (foo nil))
  ([config
    (println config)]))

dharrigan12:04:00

the [ has moved....

dominicm12:04:12

Too much indent. I guess parinfer-rust doesn't implement the dynamic tabstops. Pressing "i<space>" is the resort then :)

dominicm12:04:51

I don't think that's necessarily a bad thing, because it's how parinfer works.

dharrigan12:04:19

Do you use something different for managing your parens?

dominicm12:04:36

I only use sexp

dominicm12:04:54

I have learned not to press dd by this point, so it isn't a problem.

dominicm12:04:18

I'd say both are good, but with different trade offs.

dharrigan12:04:39

Yeah, I'm quite new to the setup, so I'm trying to find out what is comfortable. I think I'll ditch parinfer and do it like you

dharrigan12:04:43

too many things in the way

dharrigan12:04:56

I want an easy life πŸ™‚

dharrigan12:04:34

slurp and barf working as I expect them to now...ah...nice.

dharrigan12:04:11

thanks! πŸ™‚

dominicm13:04:24

Great! πŸ™‚

dominicm13:04:32

Bother me any time if you need help πŸ™‚

Aleksander13:04:27

I am quite happy with https://github.com/vim-scripts/paredit.vim balances parenthesis for you but doesn’t mess/deal with intentation

dharrigan13:04:03

Will give it a go! Thanks !

dominicm13:04:44

I found paredit a bit heavy handed, with overriding dd and such.

dharrigan14:04:10

I actually (inclined to) think, having a human, i.e., moi, manage the parens isn't too much of a burden πŸ™‚

dave14:04:45

i realize this is subjective, but i'm totally sold on the parinfer approach. i've been using it for a good long while now, and i've found that i much prefer to manage indentation over managing parens

dharrigan14:04:24

So you use it just to mange indentation?

dave14:04:45

no, i use it to manage my parens

dave14:04:50

i'm in charge of indentation

dave14:04:13

as long as i line up my code correctly, i can be confident that my parens are correct