[vim/vim] Feature Request: Emscripten/Web Target (#1593)

144 views
Skip to first unread message

Immortalin

unread,
Mar 25, 2017, 8:50:49 PM3/25/17
to vim/vim, Subscribed

With web assembly on the horizon, can a build target for emscripten be added?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Christian Brabandt

unread,
Mar 26, 2017, 12:40:08 PM3/26/17
to vim/vim, Subscribed

Need more context. What is that for and what has this to do with an editor?

Sara Lara

unread,
Apr 13, 2017, 1:05:19 PM4/13/17
to vim/vim, Subscribed

@chrisbra Not OP, but I also want this. Also a disclaimer: I don't know much about this codebase other than the fact that it seems to consists mainly of C and VimScript. I assume the VimScript uses a runtime compiled from some of the C source. Anyway, if built for WebAssembly, it would be a much more performant way to use Vim in the browser than what has been done up until now, i.e. JavaScript ports of Vim.

There are plenty of use cases for running Vim in a browser "natively", but I'll limit this list to the ones that I personally want:

  • An extension for developer tools (e.g. a Chrome Dev Tools extension) that replaces (or at least adds) source editor/viewer that uses Vim.
  • An extension like Wasavi, which can potentially turn any text field in the browser into a Vim buffer
  • Easier integration of Vim into desktop apps built using things like Electron (e.g. an IDE with additional functionality outside of the scope of Vim, but which uses Vim as the text editor component)

Sara Lara

unread,
Apr 13, 2017, 1:34:42 PM4/13/17
to vim/vim, Subscribed

@Immortalin I my previous comment, I was going use Vim.js as an example of a port of Vim to JavaScript because, well, that's what the author says it is. However, I then noticed that the repo looked pretty familiar—it's basically a fork of Vim that builds it using Emscripten, but I'm assuming it targets asm.js (based on the fact that it was last updated in 2015).

Basically Vim.js targets asm.js via Emscripten, and is rendering to a <canvas/> element.

I'm betting that repo presents the easiest path to having a POC of building Vim for WebAssembly.

Christian Brabandt

unread,
Apr 20, 2017, 11:32:42 AM4/20/17
to vim/vim, Subscribed

is this simply a way of "cross-compiling" or do we actually need changes to the codebase? I am sure, PRs for the first one will be welcomed, while actually changing the codebase will probably be a big task.

Immortalin

unread,
Apr 21, 2017, 3:09:36 PM4/21/17
to vim/vim, Subscribed

It is a way of cross-compiling by some simple wrapper code might have to be written to allow interop with other browser entities e.g. textboxes

Caleb Foust

unread,
Jun 8, 2017, 11:51:13 AM6/8/17
to vim/vim, Subscribed

IIRC the problem with Vim.js is that keyboard input in Javascript is non-blocking. From my understanding, coolwanglu had to make significant changes to get input working properly. It wasn't as simple as only compiling with Emscripten.

It would be cool to target wasm in the future. That would be a lot more performant than asm.js.

Thomas Yeun

unread,
Jun 12, 2018, 2:52:32 AM6/12/18
to vim/vim, Subscribed

Any latest news regarding to compile WASM (from Clang) using emscripten inside Vim?

Christian Brabandt

unread,
Jun 12, 2018, 3:09:20 AM6/12/18
to vim/vim, Subscribed

I don't think this is currently being actively being developed or even researched. So unless somebody steps up and provides some PRs, you should not expect any progress here in the foreseeable future.

Thomas Yeun

unread,
Jun 12, 2018, 10:31:25 AM6/12/18
to vim/vim, Subscribed

@chrisbra running :!emcc xy.c -s WASM=1 -O3 -o xy.js inside Vim, it is possible to compile, just need more "easy way" to done that, and seeing the outcome result with emrun --no_browser --no_emrun_detect --port 8080 . `` need to be like preview markdown to have an external trigger to handle the viewhtml , once the emrun ``` command are executed .

Christian Brabandt

unread,
Jun 12, 2018, 10:35:55 AM6/12/18
to vim/vim, Subscribed

wait a second, I understood the ticket to be to have an emscript target for Vim, e.g. provide a make target to have vim compiled as webscript. Now you seem to be talking about providing a general way to compile some C file as webscript? That would be better by delegated to a plugin. That should already be possible today without any changes.

Thomas Yeun

unread,
Jun 12, 2018, 10:59:57 AM6/12/18
to vim/vim, Subscribed

@chrisbra my bad, i need to explain further, the "easy way" i mean is using Vim to compiled it as webscript.

sorry, didn explain that. =.=

Christian Brabandt

unread,
Jun 12, 2018, 11:04:56 AM6/12/18
to vim/vim, Subscribed

So you want Vim to be compiled as WebScript? You already seem to know how this works in general.

Now it's your chance to step up, contribute something to a well known open source project and create a PR with the required changes :)

Thomas Yeun

unread,
Jun 12, 2018, 11:13:35 AM6/12/18
to vim/vim, Subscribed

@chrisbra, i'm trying it now =.= but still hanging here and there, still need a initial file from WASM, so that Vim will know, this C are for webscript, instead that Vim will treat it as normal C.

Christian Brabandt

unread,
Jul 13, 2018, 4:44:07 PM7/13/18
to vim/vim, Subscribed
Reply all
Reply to author
Forward
0 new messages