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.I use parinfer-rust myself
that along with Plug 'guns/vim-sexp', {'for': 'clojure'}
and Plug 'tpope/vim-sexp-mappings-for-regular-people', {'for': 'clojure'}
Hey Dave, stop copying me π
Can I copy you?
oh, okay then π
π
My vimrc in all it's magnificant glory(*) can be found here: <https://github.com/dharrigan/vimconfig>
(*) == or maybe not π
I'll read the docs, try it and might come later with questions π I'm trying to use vscode + vscode-neovim
oh, no guarantees then. I have never used vscode with neovim
Me neither π
I think vscode + calva (the clojure plugin) does the balancing
have you tried calva?
Calva's paredit and vim don't get along well
you can mess everything up in normal mode
I usually use emacs with evil and my parens are under control there π
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
:help i_CTRL-V
: The characters typed right after CTRL-V are not considered for mapping.
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
.
yeah thatβs another good method, especially if you need to paste multiple parens
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 π
love that solution, lol
Other strategies Iβve used for a quick fix.
; )
then delete the ;
g/vim -u NONE
will load vim with no plugins
oh thatβs a good one too
Or ")"
then remove the quotes.
I think it's been well over 1 year since I had to do my trick
once you get into the flow of how parinfer-rust, etc., work, then you sorta just forget about the parens etc..
it just works(tm)
You've all effectively demonstrated why paredit can't really guarantee balanced parens π
lol if you count just adding as many parens as necessary to the last line of a file, it def can π₯΄
haha I would yank 1 char from another closing paren and paste it
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 : (
https://github.com/jiangmiao/auto-pairs has served me well. I haven't looked into any of the alternatives, though.
i somehow have autopairs but have no idea what makes them happen lmao
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
Which makes sense, because Parinfer does this for you.
autopairs works great for other languages, though!
vim-sexp comes with insert mapping to autoclose parens https://github.com/guns/vim-sexp/blob/master/README.markdown#insert-mode-mappings-insert
surely it's easier to type in 8 a Ctrl-V )
Idk how to count, I gotta go one at a time
oh, you mean a Ctrl-V )
followed by .
until you are done? π
Haha yeah, or v y followed by p until Iβm done
:ParinferOff
is another possibility π
I use AutoPairs and not parinfer, but had to tweak it a bit for Clojure:
" Don't automatically insert closing ' or `
let b:AutoPairs = {'(':')', '[':']', '{':'}','"':'"'}
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!