this repo has no description

Refmt codebase (very noisy)

+112 -139
+15 -7
includes/dune
··· 1 (rule 2 - (deps (source_tree %{project_root}/node_modules)) 3 (target bundle-es6.js) 4 - (enabled_if (= %{profile} "with-bundle")) 5 (action 6 - (run %{project_root}/node_modules/esbuild/bin/esbuild 7 %{dep:includes.js} 8 --bundle 9 --outfile=%{target}))) 10 11 ; warning: node modules are not managed by dune 12 ; to generate a new bundle one should run `npm install` before the first build 13 (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")) 21 (action 22 - (run %{project_root}/node_modules/@babel/cli/bin/babel.js 23 %{dep:bundle-es6.js} 24 - --config-file %{project_root}/babel.config.js 25 - -o %{target}))) 26 27 ; 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}))) 13 14 ; 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}))) 34 35 ; 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
··· 1 open Code_mirror 2 - 3 module RegExp = RegExp 4 let autocomplete = Jv.get Jv.global "__CM__autocomplete" 5 6 module Completion = struct ··· 8 9 include (Jv.Id : Jv.CONV with type t := t) 10 11 - 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) 16 17 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 - 27 end 28 29 module Context = struct ··· 33 include (Jv.Id : Jv.CONV with type t := t) 34 35 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" 40 41 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 ··· 85 86 type config = Jv.t 87 88 - 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 108 109 let create ?(config = Jv.null) () = 110 - Extension.of_jv @@ 111 - Jv.call autocomplete "autocompletion" [| config |] 112 113 (* type status = Active | Pending 114 115 - let status state = 116 117 - val status : Editor.State.t -> status option 118 - (** Gets the current completion status *) 119 120 - val current_completions : Editor.State.t -> Completion.t list 121 - (** Returns the current available completions *) 122 123 - val selected_completion : Editor.State.t -> Completion.t option 124 - * Returh the currently selected completion if any *)
··· 1 open Code_mirror 2 module RegExp = RegExp 3 + 4 let autocomplete = Jv.get Jv.global "__CM__autocomplete" 5 6 module Completion = struct ··· 8 9 include (Jv.Id : Jv.CONV with type t := t) 10 11 + 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) 13 14 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 23 end 24 25 module Context = struct ··· 29 include (Jv.Id : Jv.CONV with type t := t) 30 31 let state t = Jv.get t "state" |> Editor.State.of_jv 32 let pos t = Jv.Int.get t "pos" 33 let explicit t = Jv.Bool.get t "explicit" 34 35 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 -> 71 Option.value ~default:Jv.null (Option.map Result.to_jv t)) 72 in 73 Jv.repr f ··· 78 79 type config = Jv.t 80 81 + let config ?activate_on_typing ?override ?max_rendered_options ?default_key_map 82 + ?above_cursor ?option_class ?icons ?add_to_options () = 83 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 93 94 let create ?(config = Jv.null) () = 95 + Extension.of_jv @@ Jv.call autocomplete "autocompletion" [| config |] 96 97 (* type status = Active | Pending 98 99 + let status state = 100 101 + val status : Editor.State.t -> status option 102 + (** Gets the current completion status *) 103 104 + val current_completions : Editor.State.t -> Completion.t list 105 + (** Returns the current available completions *) 106 107 + 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 29 (** Creates a completion. 30 31 @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 91 (** 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}.*) 132 133 - 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. 31 32 @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}.*) 134 135 + val create : ?config:config -> unit -> Code_mirror.Extension.t 136 + (** Autocompleter *)
+21 -38
src/autocomplete/regExp.ml
··· 6 7 let regexp = Jv.get (Window.to_jv G.window) "RegExp" 8 9 - type opts = 10 - | Indices 11 - | Global 12 - | Ignore 13 - | Multiline 14 - | DotAll 15 - | Unicode 16 - | Sticky 17 18 let 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" 33 34 let 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 ··· 56 let 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 67 68 let 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 72 73 let 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
··· 6 7 let regexp = Jv.get (Window.to_jv G.window) "RegExp" 8 9 + type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky 10 11 let 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" 19 20 let create ?(opts = []) s = 21 let opts = 22 match List.length opts with 23 + | 0 -> Jv.undefined 24 | _ -> 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 ··· 41 let get_indices res = 42 let jv = Jv.get res "indices" in 43 match Jv.is_null jv with 44 + | true -> [] 45 | 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 51 52 let 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 56 57 let 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
+4 -11
src/autocomplete/regExp.mli
··· 1 - (** A regular expression *) 2 type t 3 4 include Jv.CONV with type t := t 5 6 - type opts = 7 - | Indices 8 - | Global 9 - | Ignore 10 - | Multiline 11 - | DotAll 12 - | Unicode 13 - | Sticky 14 15 val 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. *) 20 21 - (** The result of executing a regular expression search on a string *) 22 type result 23 24 val get_full_string_match : result -> string 25 (** The matched text *) ··· 38 in a specified string [s]. *) 39 40 val exec' : t -> Jstr.t -> result option 41 - (** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
··· 1 type t 2 + (** A regular expression *) 3 4 include Jv.CONV with type t := t 5 6 + type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky 7 8 val 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. *) 13 14 type result 15 + (** The result of executing a regular expression search on a string *) 16 17 val get_full_string_match : result -> string 18 (** The matched text *) ··· 31 in a specified string [s]. *) 32 33 val exec' : t -> Jstr.t -> result option 34 + (** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
+26 -14
src/editor.ml
··· 13 14 module type Facet = sig 15 type t 16 include Jv.CONV with type t := t 17 - type input 18 type output 19 20 val of_ : t -> input -> Extension.t 21 end 22 23 - 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 24 type t = Jv.t 25 26 include (Jv.Id : Jv.CONV with type t := t) ··· 28 type input = I.t 29 type output = Jv.t 30 31 - let of_ t i = 32 - Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv 33 end 34 35 - type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet 36 37 type t = Jv.t 38 ··· 46 end 47 48 (* Helper for function *) 49 - module Func (I : sig type t include Jv.CONV with type t := t end) = struct 50 type t = I.t -> unit 51 let to_jv f = Jv.repr f 52 end 53 ··· 67 o 68 69 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 77 module Update = struct 78 type t = Jv.t 79 ··· 85 let dom t = Jv.get t "dom" |> Brr.El.of_jv 86 87 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) 91 92 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv 93 end
··· 13 14 module type Facet = sig 15 type t 16 + 17 include Jv.CONV with type t := t 18 + 19 + type input 20 type output 21 22 val of_ : t -> input -> Extension.t 23 end 24 25 + 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 31 32 include (Jv.Id : Jv.CONV with type t := t) ··· 34 type input = I.t 35 type output = Jv.t 36 37 + let of_ t i = Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv 38 end 39 40 + 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 45 46 type t = Jv.t 47 ··· 55 end 56 57 (* 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 67 end 68 ··· 82 o 83 84 let g = Jv.get Jv.global "__CM__view" 85 + let create ?(opts = Jv.undefined) () = Jv.new' g [| opts |] 86 let state t = Jv.get t "state" |> State.of_jv 87 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 98 99 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) 103 104 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv 105 end
+15 -6
src/editor.mli
··· 17 18 module type Facet = sig 19 type t 20 include Jv.CONV with type t := t 21 - type input 22 type output 23 24 val of_ : t -> input -> Extension.t 25 end 26 27 - module FacetMaker : functor (I : sig type t include Jv.CONV with type t := t end) -> Facet with type input = I.t 28 29 - type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet 30 31 val create : ?config:Config.t -> unit -> t 32 - 33 val doc : t -> Text.t 34 end 35 ··· 68 end 69 70 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 75 end
··· 17 18 module type Facet = sig 19 type t 20 + 21 include Jv.CONV with type t := t 22 + 23 + type input 24 type output 25 26 val of_ : t -> input -> Extension.t 27 end 28 29 + 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 36 37 + 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 42 43 val create : ?config:Config.t -> unit -> t 44 val doc : t -> Text.t 45 end 46 ··· 79 end 80 81 val dom : t -> Brr.El.t 82 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet 83 val line_wrapping : unit -> Extension.t 84 end
-3
src/lint/lint.ml
··· 24 type t = Jv.t 25 26 let from t = Jv.Int.get t "from" 27 - 28 let to_ t = Jv.Int.get t "to" 29 30 type severity = Info | Warning | Error ··· 54 o 55 56 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") 61 62 include (Jv.Id : Jv.CONV with type t := t)
··· 24 type t = Jv.t 25 26 let from t = Jv.Int.get t "from" 27 let to_ t = Jv.Int.get t "to" 28 29 type severity = Info | Warning | Error ··· 53 o 54 55 let source t = Jv.Jstr.find t "source" 56 let message t = Jv.Jstr.get t "message" 57 let actions t = Option.map (Jv.to_array Action.to_jv) (Jv.find t "actions") 58 59 include (Jv.Id : Jv.CONV with type t := t)
-7
src/lint/lint.mli
··· 14 15 module Diagnostic : sig 16 type t 17 - 18 type severity = Info | Warning | Error 19 20 val severity_of_string : string -> severity 21 - 22 val severity_to_string : severity -> string 23 24 val create : ··· 32 t 33 34 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 45 end 46
··· 14 15 module Diagnostic : sig 16 type t 17 type severity = Info | Warning | Error 18 19 val severity_of_string : string -> severity 20 val severity_to_string : severity -> string 21 22 val create : ··· 30 t 31 32 val severity : t -> severity 33 val from : t -> int 34 val to_ : t -> int 35 val source : t -> Jstr.t option 36 val actions : t -> Action.t array option 37 val message : t -> Jstr.t 38 end 39
+1
src/stream/stream.ml
··· 4 type t 5 6 include (Jv.Id : Jv.CONV with type t := t) 7 let g = Jv.get g "StreamLanguage" 8 9 let define (l : t) =
··· 4 type t 5 6 include (Jv.Id : Jv.CONV with type t := t) 7 + 8 let g = Jv.get g "StreamLanguage" 9 10 let define (l : t) =
-6
src/text.ml
··· 6 type t = Jv.t 7 8 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" 17 end 18 19 let length t = Jv.Int.get t "length" 20 - 21 let line n t = Jv.call t "line" [| Jv.of_int n |] 22 - 23 let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
··· 6 type t = Jv.t 7 8 let from t = Jv.Int.get t "from" 9 let to_ t = Jv.Int.get t "to" 10 let number t = Jv.Int.get t "number" 11 let text t = Jv.Jstr.get t "text" 12 let length t = Jv.Int.get t "length" 13 end 14 15 let length t = Jv.Int.get t "length" 16 let line n t = Jv.call t "line" [| Jv.of_int n |] 17 let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
-1
src/text.mli
··· 26 (** Length of the text *) 27 28 val line : int -> t -> Line.t 29 - 30 val to_jstr_array : t -> Jstr.t array
··· 26 (** Length of the text *) 27 28 val line : int -> t -> Line.t 29 val to_jstr_array : t -> Jstr.t array