patricoferris / try-eio

Try OCaml Effects and Eio in your browser
ISC License
20 stars 0 forks source link

codemirror vim integration #1

Closed zeroexcuses closed 1 year ago

zeroexcuses commented 1 year ago

Hi,

Can you show me how to integrate https://github.com/replit/codemirror-vim into try-eio ?

For plain JS/TS, it's just

import { basicSetup, EditorView } from 'codemirror';
import { vim } from "@replit/codemirror-vim"

let view = new EditorView({
  doc: "",
  extensions: [
    // make sure vim is included before other keymaps
    vim(), 
    // include the default keymap and all other keymaps you want to use in insert mode
    basicSetup, 
  ],
  parent: document.querySelector('#editor'),
})

but in this case, it seems https://github.com/patricoferris/jsoo-code-mirror/blob/bd1d3c68a23655cd667986aef48c05a6514fd194/includes/includes.js is exporting a few functions to OCaml, and hands control over to OCaml.

patricoferris commented 1 year ago

Perhaps the code for another little code mirror project I did might help. See here: https://github.com/patricoferris/okra-web/blob/main/js/common/edit.ml I added the markdown extension to the editor and bound it here: https://github.com/patricoferris/okra-web/blob/main/js/basic.js

zeroexcuses commented 1 year ago

Thanks, I think I have it figured out now. Main problem was unfamiliarity with jsoo/js-bindings, and constant fear that any change would break the build.