···1(rule
2- (deps (source_tree %{project_root}/node_modules))
03 (target bundle-es6.js)
4- (enabled_if (= %{profile} "with-bundle"))
05 (action
6- (run %{project_root}/node_modules/esbuild/bin/esbuild
07 %{dep:includes.js}
8 --bundle
9 --outfile=%{target})))
1011; warning: node modules are not managed by dune
12; to generate a new bundle one should run `npm install` before the first build
013(rule
14 (deps
15 %{project_root}/package.json
···17 (source_tree %{project_root}/node_modules))
18 (target bundle.js)
19 (mode promote)
20- (enabled_if (= %{profile} "with-bundle"))
021 (action
22- (run %{project_root}/node_modules/@babel/cli/bin/babel.js
023 %{dep:bundle-es6.js}
24- --config-file %{project_root}/babel.config.js
25- -o %{target})))
002627; The bundle is only re-generated if the profile is `with-bundle`
28; If you add new javascript dependency or update the package.json
···1(rule
2+ (deps
3+ (source_tree %{project_root}/node_modules))
4 (target bundle-es6.js)
5+ (enabled_if
6+ (= %{profile} "with-bundle"))
7 (action
8+ (run
9+ %{project_root}/node_modules/esbuild/bin/esbuild
10 %{dep:includes.js}
11 --bundle
12 --outfile=%{target})))
1314; warning: node modules are not managed by dune
15; to generate a new bundle one should run `npm install` before the first build
16+17(rule
18 (deps
19 %{project_root}/package.json
···21 (source_tree %{project_root}/node_modules))
22 (target bundle.js)
23 (mode promote)
24+ (enabled_if
25+ (= %{profile} "with-bundle"))
26 (action
27+ (run
28+ %{project_root}/node_modules/@babel/cli/bin/babel.js
29 %{dep:bundle-es6.js}
30+ --config-file
31+ %{project_root}/babel.config.js
32+ -o
33+ %{target})))
3435; The bundle is only re-generated if the profile is `with-bundle`
36; If you add new javascript dependency or update the package.json
+23-39
src/autocomplete/autocomplete.ml
···1open Code_mirror
2-3module RegExp = RegExp
04let autocomplete = Jv.get Jv.global "__CM__autocomplete"
56module Completion = struct
···89 include (Jv.Id : Jv.CONV with type t := t)
1011- let set_if_some_string t s v =
12- Jv.Jstr.set_if_some t s (Option.map Jstr.v v)
13-14- let set_string t s v =
15- Jv.Jstr.set t s (Jstr.v v)
1617 let create ~label ?detail ?info ?apply ?type_ ?boost () =
18 let o = Jv.obj [||] in
···23 set_if_some_string o "type" type_;
24 Jv.Int.set_if_some o "boost" boost;
25 o
26-27end
2829module Context = struct
···33 include (Jv.Id : Jv.CONV with type t := t)
3435 let state t = Jv.get t "state" |> Editor.State.of_jv
36-37 let pos t = Jv.Int.get t "pos"
38-39 let explicit t = Jv.Bool.get t "explicit"
4041 let token_before t types =
···73 let create (src : Context.t -> Result.t option Fut.t) =
74 let f ctx =
75 let fut = Fut.map (fun v -> Ok v) @@ src (Context.of_jv ctx) in
76- Fut.to_promise fut
77- ~ok:(fun t ->
78 Option.value ~default:Jv.null (Option.map Result.to_jv t))
79 in
80 Jv.repr f
···8586type config = Jv.t
8788-let config
89- ?activate_on_typing
90- ?override
91- ?max_rendered_options
92- ?default_key_map
93- ?above_cursor
94- ?option_class
95- ?icons
96- ?add_to_options
97- () =
98 let o = Jv.obj [||] in
99- Jv.Bool.set_if_some o "activateOnTyping" activate_on_typing;
100- Jv.set_if_some o "override" (Option.map (fun v -> Jv.of_jv_list v) override);
101- Jv.Int.set_if_some o "maxRenderedOptions" max_rendered_options;
102- Jv.Bool.set_if_some o "defaultKeyMap" default_key_map;
103- Jv.Bool.set_if_some o "aboveCursor" above_cursor;
104- Jv.set_if_some o "optionClass" option_class;
105- Jv.Bool.set_if_some o "icons" icons;
106- Jv.set_if_some o "addToOptions" add_to_options;
107- o
108109let create ?(config = Jv.null) () =
110- Extension.of_jv @@
111- Jv.call autocomplete "autocompletion" [| config |]
112113(* type status = Active | Pending
114115-let status state =
116117-val status : Editor.State.t -> status option
118-(** Gets the current completion status *)
119120-val current_completions : Editor.State.t -> Completion.t list
121-(** Returns the current available completions *)
122123-val selected_completion : Editor.State.t -> Completion.t option
124-* Returh the currently selected completion if any *)
···1open Code_mirror
02module RegExp = RegExp
3+4let autocomplete = Jv.get Jv.global "__CM__autocomplete"
56module Completion = struct
···89 include (Jv.Id : Jv.CONV with type t := t)
1011+ let set_if_some_string t s v = Jv.Jstr.set_if_some t s (Option.map Jstr.v v)
12+ let set_string t s v = Jv.Jstr.set t s (Jstr.v v)
0001314 let create ~label ?detail ?info ?apply ?type_ ?boost () =
15 let o = Jv.obj [||] in
···20 set_if_some_string o "type" type_;
21 Jv.Int.set_if_some o "boost" boost;
22 o
023end
2425module Context = struct
···29 include (Jv.Id : Jv.CONV with type t := t)
3031 let state t = Jv.get t "state" |> Editor.State.of_jv
032 let pos t = Jv.Int.get t "pos"
033 let explicit t = Jv.Bool.get t "explicit"
3435 let token_before t types =
···67 let create (src : Context.t -> Result.t option Fut.t) =
68 let f ctx =
69 let fut = Fut.map (fun v -> Ok v) @@ src (Context.of_jv ctx) in
70+ Fut.to_promise fut ~ok:(fun t ->
071 Option.value ~default:Jv.null (Option.map Result.to_jv t))
72 in
73 Jv.repr f
···7879type config = Jv.t
8081+let config ?activate_on_typing ?override ?max_rendered_options ?default_key_map
82+ ?above_cursor ?option_class ?icons ?add_to_options () =
0000000083 let o = Jv.obj [||] in
84+ Jv.Bool.set_if_some o "activateOnTyping" activate_on_typing;
85+ Jv.set_if_some o "override" (Option.map (fun v -> Jv.of_jv_list v) override);
86+ Jv.Int.set_if_some o "maxRenderedOptions" max_rendered_options;
87+ Jv.Bool.set_if_some o "defaultKeyMap" default_key_map;
88+ Jv.Bool.set_if_some o "aboveCursor" above_cursor;
89+ Jv.set_if_some o "optionClass" option_class;
90+ Jv.Bool.set_if_some o "icons" icons;
91+ Jv.set_if_some o "addToOptions" add_to_options;
92+ o
9394let create ?(config = Jv.null) () =
95+ Extension.of_jv @@ Jv.call autocomplete "autocompletion" [| config |]
09697(* type status = Active | Pending
9899+ let status state =
100101+ val status : Editor.State.t -> status option
102+ (** Gets the current completion status *)
103104+ val current_completions : Editor.State.t -> Completion.t list
105+ (** Returns the current available completions *)
106107+ val selected_completion : Editor.State.t -> Completion.t option
108+ * Returh the currently selected completion if any *)
+7-7
src/autocomplete/autocomplete.mli
···25 ?apply:t ->
26 ?type_:string ->
27 ?boost:int ->
28- unit -> t
029 (** Creates a completion.
3031 @param label The label to show in the completion picker.
···87 options:Completion.t list ->
88 ?span:RegExp.t ->
89 ?filter:bool ->
90- unit -> t
091 (** Creating a new completion result (see {{: https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult} the docs}).
92 @param from The start of the range that is being completed.
93 @param to_ The end of the range that is being completed. Defaults to the
···128 ?add_to_options:Jv.t ->
129 unit ->
130 config
131- (** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*)
132133-val create :
134- ?config:config -> unit ->
135- Code_mirror.Extension.t
136- (** Autocompleter *)
···25 ?apply:t ->
26 ?type_:string ->
27 ?boost:int ->
28+ unit ->
29+ t
30 (** Creates a completion.
3132 @param label The label to show in the completion picker.
···88 options:Completion.t list ->
89 ?span:RegExp.t ->
90 ?filter:bool ->
91+ unit ->
92+ t
93 (** Creating a new completion result (see {{: https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult} the docs}).
94 @param from The start of the range that is being completed.
95 @param to_ The end of the range that is being completed. Defaults to the
···130 ?add_to_options:Jv.t ->
131 unit ->
132 config
133+(** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*)
134135+val create : ?config:config -> unit -> Code_mirror.Extension.t
136+(** Autocompleter *)
00
+21-38
src/autocomplete/regExp.ml
···67let regexp = Jv.get (Window.to_jv G.window) "RegExp"
89-type opts =
10- | Indices
11- | Global
12- | Ignore
13- | Multiline
14- | DotAll
15- | Unicode
16- | Sticky
1718let opts_to_string = function
19- | Indices ->
20- "d"
21- | Global ->
22- "g"
23- | Ignore ->
24- "i"
25- | Multiline ->
26- "m"
27- | DotAll ->
28- "s"
29- | Unicode ->
30- "u"
31- | Sticky ->
32- "y"
3334let create ?(opts = []) s =
35 let opts =
36 match List.length opts with
37- | 0 ->
38- Jv.undefined
39 | _ ->
40- let options = List.sort_uniq Stdlib.compare opts in
41- let opt_string =
42- List.fold_left (fun acc t -> acc ^ opts_to_string t) "" options
43- in
44- Jv.of_string opt_string
45 in
46 Jv.new' regexp [| Jv.of_string s; opts |]
47···56let get_indices res =
57 let jv = Jv.get res "indices" in
58 match Jv.is_null jv with
59- | true ->
60- []
61 | false ->
62- let conv arr =
63- let indices = Jv.to_array Jv.to_int arr in
64- indices.(0), indices.(1)
65- in
66- Jv.to_list conv jv
6768let get_substring_matches res =
69 let arr = Jv.to_jv_array res in
···71 Array.sub arr 1 length |> Array.to_list |> List.map Jv.to_string
7273let exec' t s = Jv.to_option Jv.Id.to_jv @@ Jv.call t "exec" [| Jv.of_jstr s |]
74-75-let exec t s = exec' t @@ Jstr.v s
···67let regexp = Jv.get (Window.to_jv G.window) "RegExp"
89+type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky
00000001011let opts_to_string = function
12+ | Indices -> "d"
13+ | Global -> "g"
14+ | Ignore -> "i"
15+ | Multiline -> "m"
16+ | DotAll -> "s"
17+ | Unicode -> "u"
18+ | Sticky -> "y"
00000001920let create ?(opts = []) s =
21 let opts =
22 match List.length opts with
23+ | 0 -> Jv.undefined
024 | _ ->
25+ let options = List.sort_uniq Stdlib.compare opts in
26+ let opt_string =
27+ List.fold_left (fun acc t -> acc ^ opts_to_string t) "" options
28+ in
29+ Jv.of_string opt_string
30 in
31 Jv.new' regexp [| Jv.of_string s; opts |]
32···41let get_indices res =
42 let jv = Jv.get res "indices" in
43 match Jv.is_null jv with
44+ | true -> []
045 | false ->
46+ let conv arr =
47+ let indices = Jv.to_array Jv.to_int arr in
48+ (indices.(0), indices.(1))
49+ in
50+ Jv.to_list conv jv
5152let get_substring_matches res =
53 let arr = Jv.to_jv_array res in
···55 Array.sub arr 1 length |> Array.to_list |> List.map Jv.to_string
5657let exec' t s = Jv.to_option Jv.Id.to_jv @@ Jv.call t "exec" [| Jv.of_jstr s |]
58+let exec t s = exec' t @@ Jstr.v s
0
+4-11
src/autocomplete/regExp.mli
···1-(** A regular expression *)
2type t
034include Jv.CONV with type t := t
56-type opts =
7- | Indices
8- | Global
9- | Ignore
10- | Multiline
11- | DotAll
12- | Unicode
13- | Sticky
1415val create : ?opts:opts list -> string -> t
16(** Create a regular expression from a string. Internally this uses
···18 {{:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp}
19 has it's own documentation}. Note we pass noo flags at the moment. *)
2021-(** The result of executing a regular expression search on a string *)
22type result
02324val get_full_string_match : result -> string
25(** The matched text *)
···38 in a specified string [s]. *)
3940val exec' : t -> Jstr.t -> result option
41-(** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
···01type t
2+(** A regular expression *)
34include Jv.CONV with type t := t
56+type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky
000000078val create : ?opts:opts list -> string -> t
9(** Create a regular expression from a string. Internally this uses
···11 {{:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp}
12 has it's own documentation}. Note we pass noo flags at the moment. *)
13014type result
15+(** The result of executing a regular expression search on a string *)
1617val get_full_string_match : result -> string
18(** The matched text *)
···31 in a specified string [s]. *)
3233val exec' : t -> Jstr.t -> result option
34+(** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
+26-14
src/editor.ml
···1314 module type Facet = sig
15 type t
016 include Jv.CONV with type t := t
17- type input
018 type output
1920 val of_ : t -> input -> Extension.t
21 end
2223- 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
000024 type t = Jv.t
2526 include (Jv.Id : Jv.CONV with type t := t)
···28 type input = I.t
29 type output = Jv.t
3031- let of_ t i =
32- Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv
33 end
3435- type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet
00003637 type t = Jv.t
38···46end
4748(* Helper for function *)
49-module Func (I : sig type t include Jv.CONV with type t := t end) = struct
0000050 type t = I.t -> unit
051 let to_jv f = Jv.repr f
52end
53···67 o
6869 let g = Jv.get Jv.global "__CM__view"
70-71- let create ?(opts = Jv.undefined) () =
72- Jv.new' g [| opts |]
73-74 let state t = Jv.get t "state" |> State.of_jv
75-76 let set_state t v = Jv.call t "setState" [| State.to_jv v |] |> ignore
077 module Update = struct
78 type t = Jv.t
79···85 let dom t = Jv.get t "dom" |> Brr.El.of_jv
8687 let update_listener _ : (Update.t -> unit, Jv.t) State.facet =
88- let module F = State.FacetMaker (Func(Update)) in
89- let jv = Jv.get g "updateListener" in
90- Facet ((module F), F.of_jv jv)
9192 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
93end
···1314 module type Facet = sig
15 type t
16+17 include Jv.CONV with type t := t
18+19+ type input
20 type output
2122 val of_ : t -> input -> Extension.t
23 end
2425+ module FacetMaker (I : sig
26+ type t
27+28+ val to_jv : t -> Jv.t
29+ end) : Facet with type input = I.t and type output = Jv.t = struct
30 type t = Jv.t
3132 include (Jv.Id : Jv.CONV with type t := t)
···34 type input = I.t
35 type output = Jv.t
3637+ let of_ t i = Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv
038 end
3940+ type ('i, 'o) facet =
41+ | Facet :
42+ (module Facet with type input = 'i and type output = 'o and type t = 'a)
43+ * 'a
44+ -> ('i, 'o) facet
4546 type t = Jv.t
47···55end
5657(* Helper for function *)
58+module Func (I : sig
59+ type t
60+61+ include Jv.CONV with type t := t
62+end) =
63+struct
64 type t = I.t -> unit
65+66 let to_jv f = Jv.repr f
67end
68···82 o
8384 let g = Jv.get Jv.global "__CM__view"
85+ let create ?(opts = Jv.undefined) () = Jv.new' g [| opts |]
00086 let state t = Jv.get t "state" |> State.of_jv
087 let set_state t v = Jv.call t "setState" [| State.to_jv v |] |> ignore
88+89 module Update = struct
90 type t = Jv.t
91···97 let dom t = Jv.get t "dom" |> Brr.El.of_jv
9899 let update_listener _ : (Update.t -> unit, Jv.t) State.facet =
100+ let module F = State.FacetMaker (Func (Update)) in
101+ let jv = Jv.get g "updateListener" in
102+ Facet ((module F), F.of_jv jv)
103104 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv
105end
+15-6
src/editor.mli
···1718 module type Facet = sig
19 type t
020 include Jv.CONV with type t := t
21- type input
022 type output
2324 val of_ : t -> input -> Extension.t
25 end
2627- module FacetMaker : functor (I : sig type t include Jv.CONV with type t := t end) -> Facet with type input = I.t
0000002829- type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet
00003031 val create : ?config:Config.t -> unit -> t
32-33 val doc : t -> Text.t
34end
35···68 end
6970 val dom : t -> Brr.El.t
71-72 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
73-74 val line_wrapping : unit -> Extension.t
75end
···1718 module type Facet = sig
19 type t
20+21 include Jv.CONV with type t := t
22+23+ type input
24 type output
2526 val of_ : t -> input -> Extension.t
27 end
2829+ module FacetMaker : functor
30+ (I : sig
31+ type t
32+33+ include Jv.CONV with type t := t
34+ end)
35+ -> Facet with type input = I.t
3637+ type ('i, 'o) facet =
38+ | Facet :
39+ (module Facet with type input = 'i and type output = 'o and type t = 'a)
40+ * 'a
41+ -> ('i, 'o) facet
4243 val create : ?config:Config.t -> unit -> t
044 val doc : t -> Text.t
45end
46···79 end
8081 val dom : t -> Brr.El.t
082 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet
083 val line_wrapping : unit -> Extension.t
84end
-3
src/lint/lint.ml
···24 type t = Jv.t
2526 let from t = Jv.Int.get t "from"
27-28 let to_ t = Jv.Int.get t "to"
2930 type severity = Info | Warning | Error
···54 o
5556 let source t = Jv.Jstr.find t "source"
57-58 let message t = Jv.Jstr.get t "message"
59-60 let actions t = Option.map (Jv.to_array Action.to_jv) (Jv.find t "actions")
6162 include (Jv.Id : Jv.CONV with type t := t)
···24 type t = Jv.t
2526 let from t = Jv.Int.get t "from"
027 let to_ t = Jv.Int.get t "to"
2829 type severity = Info | Warning | Error
···53 o
5455 let source t = Jv.Jstr.find t "source"
056 let message t = Jv.Jstr.get t "message"
057 let actions t = Option.map (Jv.to_array Action.to_jv) (Jv.find t "actions")
5859 include (Jv.Id : Jv.CONV with type t := t)
-7
src/lint/lint.mli
···1415module Diagnostic : sig
16 type t
17-18 type severity = Info | Warning | Error
1920 val severity_of_string : string -> severity
21-22 val severity_to_string : severity -> string
2324 val create :
···32 t
3334 val severity : t -> severity
35-36 val from : t -> int
37-38 val to_ : t -> int
39-40 val source : t -> Jstr.t option
41-42 val actions : t -> Action.t array option
43-44 val message : t -> Jstr.t
45end
46
···1415module Diagnostic : sig
16 type t
017 type severity = Info | Warning | Error
1819 val severity_of_string : string -> severity
020 val severity_to_string : severity -> string
2122 val create :
···30 t
3132 val severity : t -> severity
033 val from : t -> int
034 val to_ : t -> int
035 val source : t -> Jstr.t option
036 val actions : t -> Action.t array option
037 val message : t -> Jstr.t
38end
39
+1
src/stream/stream.ml
···4 type t
56 include (Jv.Id : Jv.CONV with type t := t)
07 let g = Jv.get g "StreamLanguage"
89 let define (l : t) =
···4 type t
56 include (Jv.Id : Jv.CONV with type t := t)
7+8 let g = Jv.get g "StreamLanguage"
910 let define (l : t) =
-6
src/text.ml
···6 type t = Jv.t
78 let from t = Jv.Int.get t "from"
9-10 let to_ t = Jv.Int.get t "to"
11-12 let number t = Jv.Int.get t "number"
13-14 let text t = Jv.Jstr.get t "text"
15-16 let length t = Jv.Int.get t "length"
17end
1819let length t = Jv.Int.get t "length"
20-21let line n t = Jv.call t "line" [| Jv.of_int n |]
22-23let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
···6 type t = Jv.t
78 let from t = Jv.Int.get t "from"
09 let to_ t = Jv.Int.get t "to"
010 let number t = Jv.Int.get t "number"
011 let text t = Jv.Jstr.get t "text"
012 let length t = Jv.Int.get t "length"
13end
1415let length t = Jv.Int.get t "length"
016let line n t = Jv.call t "line" [| Jv.of_int n |]
017let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
-1
src/text.mli
···26(** Length of the text *)
2728val line : int -> t -> Line.t
29-30val to_jstr_array : t -> Jstr.t array
···26(** Length of the text *)
2728val line : int -> t -> Line.t
029val to_jstr_array : t -> Jstr.t array