bhurlow / vim-parinfer

vim plugin to balance your parenthesis
MIT License
182 stars 18 forks source link

Trigger parinfer in Insert mode #46

Closed spinningarrow closed 6 years ago

spinningarrow commented 6 years ago

This seems to be working for me. Can you give it a spin?

eraserhd commented 6 years ago

The exists test that you copied was broken, see #47 .

bhurlow commented 6 years ago

@spinningarrow #47 fixed a check for TextChanged (which works awesome btw). Can you resolve and try again? Curios how the insert mode will fell

eraserhd commented 6 years ago

I suspect that this will be much too slow, given how long it takes for me on TextChanged.

I'm hoping to speed up the parinfer library a bunch based on advice I just read on the Vim list. (Namely, avoid for and while loops in favor of map, since the former makes Vim reparse every command for every iteration.)

bhurlow commented 6 years ago

@eraserhd re: performance, I think the next easy step is to use the python binding in place of the VimL binding for the Parinfer algorithm. That's something we had wanted to do a while back

bhurlow commented 6 years ago

I'd love to use the js version, but I'm not a neovim user

bhurlow commented 6 years ago

see https://github.com/bhurlow/vim-parinfer/issues/35 https://github.com/bhurlow/vim-parinfer/issues/43

spinningarrow commented 6 years ago

@eraserhd fixed the exists check; thanks!

I've also pushed a small fix that prevents unnecessary redrawing. Can you check and tell me if the performance feels any better?

Btw if we want to use the JS binding, would Vim8's channels/jobs feature be something that could help in that regard? https://github.com/vim/vim/blob/master/runtime/doc/version8.txt#L41

bhurlow commented 6 years ago

@spinningarrow cool thnx I'll this out. We could certainly use vim8's channels to send forms to a separate process running the parinfer js implementation. This would require users to have node.js installed and run an npm install to use – not a deal breaker for me but potentially for others. Ideally we could embded v8 into vim, but that's a whole other can of works 🙃 .

I can start a branch with this idea. Would adding dependency to node.js be any issue for others?

spinningarrow commented 6 years ago

I suppose another way is to use the JS implementation if Node is available, the Python implementation otherwise (if Vim is compiled with Python support), and if all fails fallback to the vimscript version!

bhurlow commented 6 years ago

trying this out...