This is only a draft, any ideas are welcome.
Motivation
Seems that lots of people are expecting web integrations in vim.js, indeed it might be a good combination for lots of different services, but they might not be necessary for all the users.
A better solution might be to expose enough interface such that people can write and enable only the extensions they need. somewhat like vundle.
Run JavaScript inside Vim.js
Vim script is powerful and widely used, but may be it's too large/slow on vim.js. But sometimes Vim script does not make sense as we have a native JS engine behind it, and javascript is more powerful.
The easiest way of implementation is to hijack :!
, it makes sense, easy to use and implement. It's my preferred way, but maybe it will be conflict with existing plugins (suppose that vim script is supported in the future) due to the semantic meaning. But anyway there's no shell (so far) in emscripten and :!
won't work anyway...
Otherwise we need to define a new command other than :!
, which requires further modification to the original Vim, and I'm kind of against it.
Common functions can be defined inside the vimjs JS Object.
Load external JavaScript
:!vimjs.load_js(url)
looks like a good choice
Interaction with Vim.js through JS
To actually access the buffer and other internal structures.
Need lots of work to do, or maybe to enable Vim script instead ... Not sure right now.
File System Extensions
Seems to be popularly demanded, which are fortunately not hard to implement. As long as js can be executed inside vim.js, people can mount different FS using emscripten FS API
Relative libraries:
Async Function Calls
Sometimes only async functions are available (e.g. setTimeout
), such that you cannot block the current execution until some condition is met.
Fortunately Vim.js allows you suspend and resume it, such that you can simulate a blocking operation, which actually blocks Vim.js but does not freeze your browser. An extra callback will be provided to resume Vim.js.
Need to work out a new syntax other than :!
, as :!
should be reserved as a handy to for sync calls.