Writing this plugin has been quite the learning experience. Vim strives to be a text editor foremost, and its plugin API discourages terminals or REPLs. Unfortunately, similar API functionality is needed if one wants to create a collaboration plugin.
Matt (kansface) and I have figured out two ways to get this working:
1. Set updatetime to a low value and call feedkeys with a key combo that is effectively a no-op. Then you can have an autocmd for CursorHold that calls select(). Unfortunately, since K_IGNORE was removed from Vim a few years ago, there is no key combo that is truly a no-op. This method breaks some keyboard shortcuts.
2. Start Vim as a server and spawn a subprocess that sleeps for 200ms, then runs another Vim as a client. This client Vim calls a tick function in the server Vim, which select()s and repeats the spawn-a-subprocess trick. This has fewer side-effects but is crazy inefficient.
This would have been so much easier if Vim's plugin API had a setTimeout().
ggreer and I have been working on adding vim to floobits for a few months now. Presently, we support communication between Sublime, Vim, and our web editor. We are working on Emacs right now and I expect it will be ready for an alpha release in about a week.
When someone else posted their vim collaborative plugin, the Floobits people were all over the thread promoting their commercial product over it.
I will also note that the Floobits people seem incapable of posting about their vim plugin without downing vim, as if doing this were equally or more important than their product.
I will note that neither ggreer nor myself commented in the other thread (ie, the Floobits team). For that matter, we don't have any ill will towards CoVim or the Etherpad Vim plugin; I personally hope they succeed and the number of people who pair program on a daily basis increases.
Floobits is also currently free and the plugins at least are open sourced. It takes a significant amount of time to develop this software- hopefully users will find the value we add commensurate with the investment on our part and we can make a business out of it.
Finally, we are left in a strange position with users on why the Vim plugin behaves so strangely. Ideally, users wouldn't have to change their behavior at all; everything would just magically work. Unfortunately, Vim is purposefully designed to make things like collaborative editing impossible (it has no event loop and async actions are impossible). Vim is by design a text editor and not an IDE. We should probably communicate the limitations of the platform better to end users.
It was I who posted in the HN CoVim comments about Floobits, and I am not affiliated with Floobits. I just like it. It's better than CoVim for a number of reasons whether or not it's commercial.
Screen and tmux are great for sharing terminals, but they're not the best for editor collaboration. For one, all users sharing the terminal have to have the same buffer open, scrolled to the same position. Also, they have to use the same editor with the same configuration. If two people prefer different editors or different sets of Vim plugins, they have to compromise.
Flootty is also accessible from our web based editor which has an embedded pty. Its actually possible to run a vim inside flootty that itself is running floobits.
When reading the post about CoVim I tried getting it to run, but it gave me ugly errors about my python version which (I really did try to fix) but took a bit more time than expected and I gave up.
When coming to the vim-support, it works great! Even better than in Sublime since in Sublime there is this marking of what has been added the last few seconds which I personally don't like.
Installing was very easy both for vim and sublime, though I had to manually install it for Sublime text and restart (the settings menu was disabled, not sure why).
Also there was no default config so I had to copy/paste from the site and add my username/secret.
Something I'd love to see: The ability to see which user is editing where (using colors, I believe like CoVim does?).
12 comments
[ 5.0 ms ] story [ 32.5 ms ] threadMatt (kansface) and I have figured out two ways to get this working:
1. Set updatetime to a low value and call feedkeys with a key combo that is effectively a no-op. Then you can have an autocmd for CursorHold that calls select(). Unfortunately, since K_IGNORE was removed from Vim a few years ago, there is no key combo that is truly a no-op. This method breaks some keyboard shortcuts.
2. Start Vim as a server and spawn a subprocess that sleeps for 200ms, then runs another Vim as a client. This client Vim calls a tick function in the server Vim, which select()s and repeats the spawn-a-subprocess trick. This has fewer side-effects but is crazy inefficient.
This would have been so much easier if Vim's plugin API had a setTimeout().
I will also note that the Floobits people seem incapable of posting about their vim plugin without downing vim, as if doing this were equally or more important than their product.
Floobits is also currently free and the plugins at least are open sourced. It takes a significant amount of time to develop this software- hopefully users will find the value we add commensurate with the investment on our part and we can make a business out of it.
Finally, we are left in a strange position with users on why the Vim plugin behaves so strangely. Ideally, users wouldn't have to change their behavior at all; everything would just magically work. Unfortunately, Vim is purposefully designed to make things like collaborative editing impossible (it has no event loop and async actions are impossible). Vim is by design a text editor and not an IDE. We should probably communicate the limitations of the platform better to end users.
Does this offer anything that other more widely used pieces of software don't already provide (and provide well)?
Edit: Ahhh, I didn't realize from the git page that it would let you use different editors on different ends of the shared session.
Flootty is also accessible from our web based editor which has an embedded pty. Its actually possible to run a vim inside flootty that itself is running floobits.
When reading the post about CoVim I tried getting it to run, but it gave me ugly errors about my python version which (I really did try to fix) but took a bit more time than expected and I gave up.
When coming to the vim-support, it works great! Even better than in Sublime since in Sublime there is this marking of what has been added the last few seconds which I personally don't like.
Installing was very easy both for vim and sublime, though I had to manually install it for Sublime text and restart (the settings menu was disabled, not sure why).
Also there was no default config so I had to copy/paste from the site and add my username/secret.
Something I'd love to see: The ability to see which user is editing where (using colors, I believe like CoVim does?).
But anyway, great work!