Fork me on GitHub
#vim
<
2021-06-02
>
nmkip13:06:00

Hi! I'm looking for a nvim plugin to manage sexps. I tried https://github.com/vim-scripts/paredit.vim it's super useful but I found a problem (not sure if I'm using it wrong or if it's a bug) When I delete until the end of line inside of a string inside of a vector I end up with unbalanced brackets.

[:p "If I press D here | paredit will do this"] -> [:p "If I press D here"
Are you using another plugin? I'm new to nvim plugins so any other useful plugins are welcomed.

dharrigan13:06:57

I use parinfer-rust myself

βž• 3
dharrigan13:06:34

that along with Plug 'guns/vim-sexp', {'for': 'clojure'} and Plug 'tpope/vim-sexp-mappings-for-regular-people', {'for': 'clojure'}

βž• 3
dharrigan13:06:59

Hey Dave, stop copying me πŸ˜›

πŸ™ƒ 6
nmkip13:06:10

Can I copy you?

dharrigan13:06:16

oh, okay then πŸ˜„

dharrigan13:06:47

My vimrc in all it's magnificant glory(*) can be found here:

πŸ‘ 3
dharrigan13:06:54

(*) == or maybe not πŸ™‚

nmkip13:06:22

I'll read the docs, try it and might come later with questions πŸ˜„ I'm trying to use vscode + vscode-neovim

dharrigan13:06:43

oh, no guarantees then. I have never used vscode with neovim

nmkip13:06:56

Me neither πŸ˜›

dharrigan13:06:06

I think vscode + calva (the clojure plugin) does the balancing

dharrigan13:06:11

have you tried calva?

nmkip13:06:45

Calva's paredit and vim don't get along well

nmkip13:06:57

you can mess everything up in normal mode

nmkip13:06:02

I usually use emacs with evil and my parens are under control there πŸ˜„

Noah Bogart13:06:11

if you ever have unbalanced parens but your plugins won’t let you input them (this happens to me sometimes with vim-sexp and vim-sexp-mappings), CTRL-V in insert mode will β€œforce” input of the character without triggering/respecting mappings

Noah Bogart13:06:33

:help i_CTRL-V: The characters typed right after CTRL-V are not considered for mapping.

πŸ‘€ 6
dave14:06:09

Good to know! Another little trick I use in a situation like that is to go to another instance of the character I want to insert but can't (e.g. a close paren), go into visual mode to copy it (`vy`), and the paste it wherever I want it to go with p.

Noah Bogart14:06:46

yeah that’s another good method, especially if you need to paste multiple parens

noisesmith18:06:12

surely it's easier to type in 8 a Ctrl-V )

Noah Bogart18:06:14

Idk how to count, I gotta go one at a time

noisesmith18:06:10

oh, you mean a Ctrl-V ) followed by . until you are done? πŸ˜„

Noah Bogart19:06:01

Haha yeah, or v y followed by p until I’m done

dharrigan14:06:29

If ever I find myself in that situation (which is rarer now since I've got used to how parinfer-rust works), I just exit, load up vi, without any plugins, do a bit of editing, save and open again in vim πŸ™‚

πŸ˜‚ 3
emilaasa19:06:26

:ParinferOff is another possibility πŸ™‚

Noah Bogart14:06:05

love that solution, lol

defndaines14:06:17

Other strategies I’ve used for a quick fix.

defndaines14:06:29

; ) then delete the ;

Noah Bogart14:06:40

g/vim -u NONE will load vim with no plugins

3
3
Noah Bogart14:06:45

oh that’s a good one too

defndaines14:06:47

Or ")" then remove the quotes.

dharrigan14:06:27

I think it's been well over 1 year since I had to do my trick

dharrigan14:06:44

once you get into the flow of how parinfer-rust, etc., work, then you sorta just forget about the parens etc..

dharrigan14:06:51

it just works(tm)

walterl14:06:23

You've all effectively demonstrated why paredit can't really guarantee balanced parens 😜

πŸ˜‚ 6
πŸ˜† 3
Noah Bogart14:06:16

lol if you count just adding as many parens as necessary to the last line of a file, it def can πŸ₯΄

grazfather14:06:35

haha I would yank 1 char from another closing paren and paste it

πŸ’― 3
mamapitufo15:06:17

while we are talking about balanced parens... what is the best choice these days for auto-closing parenthesis/braces/strings? I've tried a couple recently, and they are broken in different but pretty bad ways : (

dave15:06:20

https://github.com/jiangmiao/auto-pairs has served me well. I haven't looked into any of the alternatives, though.

βž• 2
Noah Bogart16:06:24

i somehow have autopairs but have no idea what makes them happen lmao

dave16:06:44

I just realized that I have autopairs disabled for Clojure and other Lisps:

augroup autopairs_config
  " disable auto-pairs for lisp -- it interferes with parinfer
  autocmd Filetype lisp,scheme,clojure,lfe let b:AutoPairs = {}
augroup END

dave16:06:51

Which makes sense, because Parinfer does this for you.

dave16:06:09

autopairs works great for other languages, though!

walterl19:06:06

I use AutoPairs and not parinfer, but had to tweak it a bit for Clojure:

" Don't automatically insert closing ' or `
let b:AutoPairs = {'(':')', '[':']', '{':'}','"':'"'}

mamapitufo20:06:34

hm, auto-pairs was the last one I had enabled, and I can't remember why exactly, but I removed it. Will give it a spin again, thanks!