3 ms·
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. Unfortu
by ggreer 13y ago
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().