Tell me if this is a good idea:
I really like how you can try coffee on the fly on the coffeescript website, where coffeescript is compiled to js on every keystroke. I would like that in vim as well. You wouldn't have to wait to compile the source just to see that there is a syntax error.
Is this possible at all with vim?
I think it would be possible with a InsertLeave autocmd, which would fire every time you hit escape in insert mode. To get an idea, you can do something similar now by running
:au InsertLeave <buffer> CoffeeCompile | wincmd w
in a coffee buffer.
I guess the differences from this would be a vertical split and smarter buffer handling?
edit: afaict, the only event that fires on each keystroke is InsertCharPre, but it fires before the character is added to the buffer and seems to be more for changing input
BIKESHEDDING: I needs a command name: CoffeeSplit, CoffeeView, CoffeePlay, CoffeePreview, other?
I'd rather see it stay on InsertLeave. The per-keystroke compiling works for short snippets but not so well for larger files. I'm on a relatively low end machine (2010 MBAir) and I start getting distracting delays in the 50-100 line range for the in-page preview.
Well now after getting into the code, the commands would be so similar that I'm just going to make "watch mode" and vertical splitting arguments of CoffeeCompile, Then you can use it like:
CoffeeCompile watch vert
This should be on a branch soon to play around with. I'll definitely stick with InsertLeave. The only bad thing is that changing the text outside of insert mode doesn't fire that event.
edit: it's up on the feat-39 branch.
Add watch and vertical modes to CoffeeCompile (#39)
Watch mode emulates the live preview on the coffee homepage. Use it like:
:CoffeeCompile watch vert
This is up on master now. Give it a try. Thanks for this idea!