···11(rule
22- (deps (source_tree %{project_root}/node_modules))
22+ (deps
33+ (source_tree %{project_root}/node_modules))
34 (target bundle-es6.js)
44- (enabled_if (= %{profile} "with-bundle"))
55+ (enabled_if
66+ (= %{profile} "with-bundle"))
57 (action
66- (run %{project_root}/node_modules/esbuild/bin/esbuild
88+ (run
99+ %{project_root}/node_modules/esbuild/bin/esbuild
710 %{dep:includes.js}
811 --bundle
912 --outfile=%{target})))
10131114; warning: node modules are not managed by dune
1215; to generate a new bundle one should run `npm install` before the first build
1616+1317(rule
1418 (deps
1519 %{project_root}/package.json
···1721 (source_tree %{project_root}/node_modules))
1822 (target bundle.js)
1923 (mode promote)
2020- (enabled_if (= %{profile} "with-bundle"))
2424+ (enabled_if
2525+ (= %{profile} "with-bundle"))
2126 (action
2222- (run %{project_root}/node_modules/@babel/cli/bin/babel.js
2727+ (run
2828+ %{project_root}/node_modules/@babel/cli/bin/babel.js
2329 %{dep:bundle-es6.js}
2424- --config-file %{project_root}/babel.config.js
2525- -o %{target})))
3030+ --config-file
3131+ %{project_root}/babel.config.js
3232+ -o
3333+ %{target})))
26342735; The bundle is only re-generated if the profile is `with-bundle`
2836; If you add new javascript dependency or update the package.json
+23-39
src/autocomplete/autocomplete.ml
···11open Code_mirror
22-32module RegExp = RegExp
33+44let autocomplete = Jv.get Jv.global "__CM__autocomplete"
5566module Completion = struct
···8899 include (Jv.Id : Jv.CONV with type t := t)
10101111- let set_if_some_string t s v =
1212- Jv.Jstr.set_if_some t s (Option.map Jstr.v v)
1313-1414- let set_string t s v =
1515- Jv.Jstr.set t s (Jstr.v v)
1111+ let set_if_some_string t s v = Jv.Jstr.set_if_some t s (Option.map Jstr.v v)
1212+ let set_string t s v = Jv.Jstr.set t s (Jstr.v v)
16131714 let create ~label ?detail ?info ?apply ?type_ ?boost () =
1815 let o = Jv.obj [||] in
···2320 set_if_some_string o "type" type_;
2421 Jv.Int.set_if_some o "boost" boost;
2522 o
2626-2723end
28242925module Context = struct
···3329 include (Jv.Id : Jv.CONV with type t := t)
34303531 let state t = Jv.get t "state" |> Editor.State.of_jv
3636-3732 let pos t = Jv.Int.get t "pos"
3838-3933 let explicit t = Jv.Bool.get t "explicit"
40344135 let token_before t types =
···7367 let create (src : Context.t -> Result.t option Fut.t) =
7468 let f ctx =
7569 let fut = Fut.map (fun v -> Ok v) @@ src (Context.of_jv ctx) in
7676- Fut.to_promise fut
7777- ~ok:(fun t ->
7070+ Fut.to_promise fut ~ok:(fun t ->
7871 Option.value ~default:Jv.null (Option.map Result.to_jv t))
7972 in
8073 Jv.repr f
···85788679type config = Jv.t
87808888-let config
8989- ?activate_on_typing
9090- ?override
9191- ?max_rendered_options
9292- ?default_key_map
9393- ?above_cursor
9494- ?option_class
9595- ?icons
9696- ?add_to_options
9797- () =
8181+let config ?activate_on_typing ?override ?max_rendered_options ?default_key_map
8282+ ?above_cursor ?option_class ?icons ?add_to_options () =
9883 let o = Jv.obj [||] in
9999- Jv.Bool.set_if_some o "activateOnTyping" activate_on_typing;
100100- Jv.set_if_some o "override" (Option.map (fun v -> Jv.of_jv_list v) override);
101101- Jv.Int.set_if_some o "maxRenderedOptions" max_rendered_options;
102102- Jv.Bool.set_if_some o "defaultKeyMap" default_key_map;
103103- Jv.Bool.set_if_some o "aboveCursor" above_cursor;
104104- Jv.set_if_some o "optionClass" option_class;
105105- Jv.Bool.set_if_some o "icons" icons;
106106- Jv.set_if_some o "addToOptions" add_to_options;
107107- o
8484+ Jv.Bool.set_if_some o "activateOnTyping" activate_on_typing;
8585+ Jv.set_if_some o "override" (Option.map (fun v -> Jv.of_jv_list v) override);
8686+ Jv.Int.set_if_some o "maxRenderedOptions" max_rendered_options;
8787+ Jv.Bool.set_if_some o "defaultKeyMap" default_key_map;
8888+ Jv.Bool.set_if_some o "aboveCursor" above_cursor;
8989+ Jv.set_if_some o "optionClass" option_class;
9090+ Jv.Bool.set_if_some o "icons" icons;
9191+ Jv.set_if_some o "addToOptions" add_to_options;
9292+ o
1089310994let create ?(config = Jv.null) () =
110110- Extension.of_jv @@
111111- Jv.call autocomplete "autocompletion" [| config |]
9595+ Extension.of_jv @@ Jv.call autocomplete "autocompletion" [| config |]
1129611397(* type status = Active | Pending
11498115115-let status state =
9999+ let status state =
116100117117-val status : Editor.State.t -> status option
118118-(** Gets the current completion status *)
101101+ val status : Editor.State.t -> status option
102102+ (** Gets the current completion status *)
119103120120-val current_completions : Editor.State.t -> Completion.t list
121121-(** Returns the current available completions *)
104104+ val current_completions : Editor.State.t -> Completion.t list
105105+ (** Returns the current available completions *)
122106123123-val selected_completion : Editor.State.t -> Completion.t option
124124-* Returh the currently selected completion if any *)
107107+ val selected_completion : Editor.State.t -> Completion.t option
108108+ * Returh the currently selected completion if any *)
+7-7
src/autocomplete/autocomplete.mli
···2525 ?apply:t ->
2626 ?type_:string ->
2727 ?boost:int ->
2828- unit -> t
2828+ unit ->
2929+ t
2930 (** Creates a completion.
30313132 @param label The label to show in the completion picker.
···8788 options:Completion.t list ->
8889 ?span:RegExp.t ->
8990 ?filter:bool ->
9090- unit -> t
9191+ unit ->
9292+ t
9193 (** Creating a new completion result (see {{: https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult} the docs}).
9294 @param from The start of the range that is being completed.
9395 @param to_ The end of the range that is being completed. Defaults to the
···128130 ?add_to_options:Jv.t ->
129131 unit ->
130132 config
131131- (** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*)
133133+(** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*)
132134133133-val create :
134134- ?config:config -> unit ->
135135- Code_mirror.Extension.t
136136- (** Autocompleter *)
135135+val create : ?config:config -> unit -> Code_mirror.Extension.t
136136+(** Autocompleter *)
+21-38
src/autocomplete/regExp.ml
···6677let regexp = Jv.get (Window.to_jv G.window) "RegExp"
8899-type opts =
1010- | Indices
1111- | Global
1212- | Ignore
1313- | Multiline
1414- | DotAll
1515- | Unicode
1616- | Sticky
99+type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky
17101811let opts_to_string = function
1919- | Indices ->
2020- "d"
2121- | Global ->
2222- "g"
2323- | Ignore ->
2424- "i"
2525- | Multiline ->
2626- "m"
2727- | DotAll ->
2828- "s"
2929- | Unicode ->
3030- "u"
3131- | Sticky ->
3232- "y"
1212+ | Indices -> "d"
1313+ | Global -> "g"
1414+ | Ignore -> "i"
1515+ | Multiline -> "m"
1616+ | DotAll -> "s"
1717+ | Unicode -> "u"
1818+ | Sticky -> "y"
33193420let create ?(opts = []) s =
3521 let opts =
3622 match List.length opts with
3737- | 0 ->
3838- Jv.undefined
2323+ | 0 -> Jv.undefined
3924 | _ ->
4040- let options = List.sort_uniq Stdlib.compare opts in
4141- let opt_string =
4242- List.fold_left (fun acc t -> acc ^ opts_to_string t) "" options
4343- in
4444- Jv.of_string opt_string
2525+ let options = List.sort_uniq Stdlib.compare opts in
2626+ let opt_string =
2727+ List.fold_left (fun acc t -> acc ^ opts_to_string t) "" options
2828+ in
2929+ Jv.of_string opt_string
4530 in
4631 Jv.new' regexp [| Jv.of_string s; opts |]
4732···5641let get_indices res =
5742 let jv = Jv.get res "indices" in
5843 match Jv.is_null jv with
5959- | true ->
6060- []
4444+ | true -> []
6145 | false ->
6262- let conv arr =
6363- let indices = Jv.to_array Jv.to_int arr in
6464- indices.(0), indices.(1)
6565- in
6666- Jv.to_list conv jv
4646+ let conv arr =
4747+ let indices = Jv.to_array Jv.to_int arr in
4848+ (indices.(0), indices.(1))
4949+ in
5050+ Jv.to_list conv jv
67516852let get_substring_matches res =
6953 let arr = Jv.to_jv_array res in
···7155 Array.sub arr 1 length |> Array.to_list |> List.map Jv.to_string
72567357let exec' t s = Jv.to_option Jv.Id.to_jv @@ Jv.call t "exec" [| Jv.of_jstr s |]
7474-7575-let exec t s = exec' t @@ Jstr.v s5858+let exec t s = exec' t @@ Jstr.v s
+4-11
src/autocomplete/regExp.mli
···11-(** A regular expression *)
21type t
22+(** A regular expression *)
3344include Jv.CONV with type t := t
5566-type opts =
77- | Indices
88- | Global
99- | Ignore
1010- | Multiline
1111- | DotAll
1212- | Unicode
1313- | Sticky
66+type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky
147158val create : ?opts:opts list -> string -> t
169(** Create a regular expression from a string. Internally this uses
···1811 {{:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp}
1912 has it's own documentation}. Note we pass noo flags at the moment. *)
20132121-(** The result of executing a regular expression search on a string *)
2214type result
1515+(** The result of executing a regular expression search on a string *)
23162417val get_full_string_match : result -> string
2518(** The matched text *)
···3831 in a specified string [s]. *)
39324033val exec' : t -> Jstr.t -> result option
4141-(** Same as {!exec} only you can pass a {!Jstr.t} instead. *)3434+(** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
+26-14
src/editor.ml
···13131414 module type Facet = sig
1515 type t
1616+1617 include Jv.CONV with type t := t
1717- type input
1818+1919+ type input
1820 type output
19212022 val of_ : t -> input -> Extension.t
2123 end
22242323- module FacetMaker (I : sig type t val to_jv : t -> Jv.t end) : (Facet with type input = I.t and type output = Jv.t) = struct
2525+ module FacetMaker (I : sig
2626+ type t
2727+2828+ val to_jv : t -> Jv.t
2929+ end) : Facet with type input = I.t and type output = Jv.t = struct
2430 type t = Jv.t
25312632 include (Jv.Id : Jv.CONV with type t := t)
···2834 type input = I.t
2935 type output = Jv.t
30363131- let of_ t i =
3232- Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv
3737+ let of_ t i = Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv
3338 end
34393535- type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet
4040+ type ('i, 'o) facet =
4141+ | Facet :
4242+ (module Facet with type input = 'i and type output = 'o and type t = 'a)
4343+ * 'a
4444+ -> ('i, 'o) facet
36453746 type t = Jv.t
3847···4655end
47564857(* Helper for function *)
4949-module Func (I : sig type t include Jv.CONV with type t := t end) = struct
5858+module Func (I : sig
5959+ type t
6060+6161+ include Jv.CONV with type t := t
6262+end) =
6363+struct
5064 type t = I.t -> unit
6565+5166 let to_jv f = Jv.repr f
5267end
5368···6782 o
68836984 let g = Jv.get Jv.global "__CM__view"
7070-7171- let create ?(opts = Jv.undefined) () =
7272- Jv.new' g [| opts |]
7373-8585+ let create ?(opts = Jv.undefined) () = Jv.new' g [| opts |]
7486 let state t = Jv.get t "state" |> State.of_jv
7575-7687 let set_state t v = Jv.call t "setState" [| State.to_jv v |] |> ignore
8888+7789 module Update = struct
7890 type t = Jv.t
7991···8597 let dom t = Jv.get t "dom" |> Brr.El.of_jv
86988799 let update_listener _ : (Update.t -> unit, Jv.t) State.facet =
8888- let module F = State.FacetMaker (Func(Update)) in
8989- let jv = Jv.get g "updateListener" in
9090- Facet ((module F), F.of_jv jv)
100100+ let module F = State.FacetMaker (Func (Update)) in
101101+ let jv = Jv.get g "updateListener" in
102102+ Facet ((module F), F.of_jv jv)
9110392104 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
93105end
+15-6
src/editor.mli
···17171818 module type Facet = sig
1919 type t
2020+2021 include Jv.CONV with type t := t
2121- type input
2222+2323+ type input
2224 type output
23252426 val of_ : t -> input -> Extension.t
2527 end
26282727- module FacetMaker : functor (I : sig type t include Jv.CONV with type t := t end) -> Facet with type input = I.t
2929+ module FacetMaker : functor
3030+ (I : sig
3131+ type t
3232+3333+ include Jv.CONV with type t := t
3434+ end)
3535+ -> Facet with type input = I.t
28362929- type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet
3737+ type ('i, 'o) facet =
3838+ | Facet :
3939+ (module Facet with type input = 'i and type output = 'o and type t = 'a)
4040+ * 'a
4141+ -> ('i, 'o) facet
30423143 val create : ?config:Config.t -> unit -> t
3232-3344 val doc : t -> Text.t
3445end
3546···6879 end
69807081 val dom : t -> Brr.El.t
7171-7282 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
7373-7483 val line_wrapping : unit -> Extension.t
7584end
-3
src/lint/lint.ml
···2424 type t = Jv.t
25252626 let from t = Jv.Int.get t "from"
2727-2827 let to_ t = Jv.Int.get t "to"
29283029 type severity = Info | Warning | Error
···5453 o
55545655 let source t = Jv.Jstr.find t "source"
5757-5856 let message t = Jv.Jstr.get t "message"
5959-6057 let actions t = Option.map (Jv.to_array Action.to_jv) (Jv.find t "actions")
61586259 include (Jv.Id : Jv.CONV with type t := t)
-7
src/lint/lint.mli
···14141515module Diagnostic : sig
1616 type t
1717-1817 type severity = Info | Warning | Error
19182019 val severity_of_string : string -> severity
2121-2220 val severity_to_string : severity -> string
23212422 val create :
···3230 t
33313432 val severity : t -> severity
3535-3633 val from : t -> int
3737-3834 val to_ : t -> int
3939-4035 val source : t -> Jstr.t option
4141-4236 val actions : t -> Action.t array option
4343-4437 val message : t -> Jstr.t
4538end
4639
+1
src/stream/stream.ml
···44 type t
5566 include (Jv.Id : Jv.CONV with type t := t)
77+78 let g = Jv.get g "StreamLanguage"
89910 let define (l : t) =
-6
src/text.ml
···66 type t = Jv.t
7788 let from t = Jv.Int.get t "from"
99-109 let to_ t = Jv.Int.get t "to"
1111-1210 let number t = Jv.Int.get t "number"
1313-1411 let text t = Jv.Jstr.get t "text"
1515-1612 let length t = Jv.Int.get t "length"
1713end
18141915let length t = Jv.Int.get t "length"
2020-2116let line n t = Jv.call t "line" [| Jv.of_int n |]
2222-2317let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
-1
src/text.mli
···2626(** Length of the text *)
27272828val line : int -> t -> Line.t
2929-3029val to_jstr_array : t -> Jstr.t array