this repo has no description

Refmt codebase (very noisy)

+112 -139
+15 -7
includes/dune
··· 1 1 (rule 2 - (deps (source_tree %{project_root}/node_modules)) 2 + (deps 3 + (source_tree %{project_root}/node_modules)) 3 4 (target bundle-es6.js) 4 - (enabled_if (= %{profile} "with-bundle")) 5 + (enabled_if 6 + (= %{profile} "with-bundle")) 5 7 (action 6 - (run %{project_root}/node_modules/esbuild/bin/esbuild 8 + (run 9 + %{project_root}/node_modules/esbuild/bin/esbuild 7 10 %{dep:includes.js} 8 11 --bundle 9 12 --outfile=%{target}))) 10 13 11 14 ; warning: node modules are not managed by dune 12 15 ; to generate a new bundle one should run `npm install` before the first build 16 + 13 17 (rule 14 18 (deps 15 19 %{project_root}/package.json ··· 17 21 (source_tree %{project_root}/node_modules)) 18 22 (target bundle.js) 19 23 (mode promote) 20 - (enabled_if (= %{profile} "with-bundle")) 24 + (enabled_if 25 + (= %{profile} "with-bundle")) 21 26 (action 22 - (run %{project_root}/node_modules/@babel/cli/bin/babel.js 27 + (run 28 + %{project_root}/node_modules/@babel/cli/bin/babel.js 23 29 %{dep:bundle-es6.js} 24 - --config-file %{project_root}/babel.config.js 25 - -o %{target}))) 30 + --config-file 31 + %{project_root}/babel.config.js 32 + -o 33 + %{target}))) 26 34 27 35 ; The bundle is only re-generated if the profile is `with-bundle` 28 36 ; If you add new javascript dependency or update the package.json
+23 -39
src/autocomplete/autocomplete.ml
··· 1 1 open Code_mirror 2 - 3 2 module RegExp = RegExp 3 + 4 4 let autocomplete = Jv.get Jv.global "__CM__autocomplete" 5 5 6 6 module Completion = struct ··· 8 8 9 9 include (Jv.Id : Jv.CONV with type t := t) 10 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) 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) 16 13 17 14 let create ~label ?detail ?info ?apply ?type_ ?boost () = 18 15 let o = Jv.obj [||] in ··· 23 20 set_if_some_string o "type" type_; 24 21 Jv.Int.set_if_some o "boost" boost; 25 22 o 26 - 27 23 end 28 24 29 25 module Context = struct ··· 33 29 include (Jv.Id : Jv.CONV with type t := t) 34 30 35 31 let state t = Jv.get t "state" |> Editor.State.of_jv 36 - 37 32 let pos t = Jv.Int.get t "pos" 38 - 39 33 let explicit t = Jv.Bool.get t "explicit" 40 34 41 35 let token_before t types = ··· 73 67 let create (src : Context.t -> Result.t option Fut.t) = 74 68 let f ctx = 75 69 let fut = Fut.map (fun v -> Ok v) @@ src (Context.of_jv ctx) in 76 - Fut.to_promise fut 77 - ~ok:(fun t -> 70 + Fut.to_promise fut ~ok:(fun t -> 78 71 Option.value ~default:Jv.null (Option.map Result.to_jv t)) 79 72 in 80 73 Jv.repr f ··· 85 78 86 79 type config = Jv.t 87 80 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 - () = 81 + let config ?activate_on_typing ?override ?max_rendered_options ?default_key_map 82 + ?above_cursor ?option_class ?icons ?add_to_options () = 98 83 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 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 108 93 109 94 let create ?(config = Jv.null) () = 110 - Extension.of_jv @@ 111 - Jv.call autocomplete "autocompletion" [| config |] 95 + Extension.of_jv @@ Jv.call autocomplete "autocompletion" [| config |] 112 96 113 97 (* type status = Active | Pending 114 98 115 - let status state = 99 + let status state = 116 100 117 - val status : Editor.State.t -> status option 118 - (** Gets the current completion status *) 101 + val status : Editor.State.t -> status option 102 + (** Gets the current completion status *) 119 103 120 - val current_completions : Editor.State.t -> Completion.t list 121 - (** Returns the current available completions *) 104 + val current_completions : Editor.State.t -> Completion.t list 105 + (** Returns the current available completions *) 122 106 123 - val selected_completion : Editor.State.t -> Completion.t option 124 - * Returh the currently selected completion if any *) 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 25 ?apply:t -> 26 26 ?type_:string -> 27 27 ?boost:int -> 28 - unit -> t 28 + unit -> 29 + t 29 30 (** Creates a completion. 30 31 31 32 @param label The label to show in the completion picker. ··· 87 88 options:Completion.t list -> 88 89 ?span:RegExp.t -> 89 90 ?filter:bool -> 90 - unit -> t 91 + unit -> 92 + t 91 93 (** Creating a new completion result (see {{: https://codemirror.net/6/docs/ref/#autocomplete.CompletionResult} the docs}). 92 94 @param from The start of the range that is being completed. 93 95 @param to_ The end of the range that is being completed. Defaults to the ··· 128 130 ?add_to_options:Jv.t -> 129 131 unit -> 130 132 config 131 - (** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*) 133 + (** Configuration options for your autocompleter, see {{: https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config} the online docs}.*) 132 134 133 - val create : 134 - ?config:config -> unit -> 135 - Code_mirror.Extension.t 136 - (** Autocompleter *) 135 + val create : ?config:config -> unit -> Code_mirror.Extension.t 136 + (** Autocompleter *)
+21 -38
src/autocomplete/regExp.ml
··· 6 6 7 7 let regexp = Jv.get (Window.to_jv G.window) "RegExp" 8 8 9 - type opts = 10 - | Indices 11 - | Global 12 - | Ignore 13 - | Multiline 14 - | DotAll 15 - | Unicode 16 - | Sticky 9 + type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky 17 10 18 11 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" 12 + | Indices -> "d" 13 + | Global -> "g" 14 + | Ignore -> "i" 15 + | Multiline -> "m" 16 + | DotAll -> "s" 17 + | Unicode -> "u" 18 + | Sticky -> "y" 33 19 34 20 let create ?(opts = []) s = 35 21 let opts = 36 22 match List.length opts with 37 - | 0 -> 38 - Jv.undefined 23 + | 0 -> Jv.undefined 39 24 | _ -> 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 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 45 30 in 46 31 Jv.new' regexp [| Jv.of_string s; opts |] 47 32 ··· 56 41 let get_indices res = 57 42 let jv = Jv.get res "indices" in 58 43 match Jv.is_null jv with 59 - | true -> 60 - [] 44 + | true -> [] 61 45 | 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 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 67 51 68 52 let get_substring_matches res = 69 53 let arr = Jv.to_jv_array res in ··· 71 55 Array.sub arr 1 length |> Array.to_list |> List.map Jv.to_string 72 56 73 57 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 58 + let exec t s = exec' t @@ Jstr.v s
+4 -11
src/autocomplete/regExp.mli
··· 1 - (** A regular expression *) 2 1 type t 2 + (** A regular expression *) 3 3 4 4 include Jv.CONV with type t := t 5 5 6 - type opts = 7 - | Indices 8 - | Global 9 - | Ignore 10 - | Multiline 11 - | DotAll 12 - | Unicode 13 - | Sticky 6 + type opts = Indices | Global | Ignore | Multiline | DotAll | Unicode | Sticky 14 7 15 8 val create : ?opts:opts list -> string -> t 16 9 (** Create a regular expression from a string. Internally this uses ··· 18 11 {{:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp} 19 12 has it's own documentation}. Note we pass noo flags at the moment. *) 20 13 21 - (** The result of executing a regular expression search on a string *) 22 14 type result 15 + (** The result of executing a regular expression search on a string *) 23 16 24 17 val get_full_string_match : result -> string 25 18 (** The matched text *) ··· 38 31 in a specified string [s]. *) 39 32 40 33 val exec' : t -> Jstr.t -> result option 41 - (** Same as {!exec} only you can pass a {!Jstr.t} instead. *) 34 + (** Same as {!exec} only you can pass a {!Jstr.t} instead. *)
+26 -14
src/editor.ml
··· 13 13 14 14 module type Facet = sig 15 15 type t 16 + 16 17 include Jv.CONV with type t := t 17 - type input 18 + 19 + type input 18 20 type output 19 21 20 22 val of_ : t -> input -> Extension.t 21 23 end 22 24 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 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 24 30 type t = Jv.t 25 31 26 32 include (Jv.Id : Jv.CONV with type t := t) ··· 28 34 type input = I.t 29 35 type output = Jv.t 30 36 31 - let of_ t i = 32 - Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv 37 + let of_ t i = Jv.call t "of" [| I.to_jv i |] |> Extension.of_jv 33 38 end 34 39 35 - type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet 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 36 45 37 46 type t = Jv.t 38 47 ··· 46 55 end 47 56 48 57 (* Helper for function *) 49 - module Func (I : sig type t include Jv.CONV with type t := t end) = struct 58 + module Func (I : sig 59 + type t 60 + 61 + include Jv.CONV with type t := t 62 + end) = 63 + struct 50 64 type t = I.t -> unit 65 + 51 66 let to_jv f = Jv.repr f 52 67 end 53 68 ··· 67 82 o 68 83 69 84 let g = Jv.get Jv.global "__CM__view" 70 - 71 - let create ?(opts = Jv.undefined) () = 72 - Jv.new' g [| opts |] 73 - 85 + let create ?(opts = Jv.undefined) () = Jv.new' g [| opts |] 74 86 let state t = Jv.get t "state" |> State.of_jv 75 - 76 87 let set_state t v = Jv.call t "setState" [| State.to_jv v |] |> ignore 88 + 77 89 module Update = struct 78 90 type t = Jv.t 79 91 ··· 85 97 let dom t = Jv.get t "dom" |> Brr.El.of_jv 86 98 87 99 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) 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) 91 103 92 104 let line_wrapping () = Jv.get g "lineWrapping" |> Extension.of_jv 93 105 end
+15 -6
src/editor.mli
··· 17 17 18 18 module type Facet = sig 19 19 type t 20 + 20 21 include Jv.CONV with type t := t 21 - type input 22 + 23 + type input 22 24 type output 23 25 24 26 val of_ : t -> input -> Extension.t 25 27 end 26 28 27 - module FacetMaker : functor (I : sig type t include Jv.CONV with type t := t end) -> Facet with type input = I.t 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 28 36 29 - type ('i, 'o) facet = Facet : (module Facet with type input = 'i and type output = 'o and type t = 'a) * 'a -> ('i, 'o) facet 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 30 42 31 43 val create : ?config:Config.t -> unit -> t 32 - 33 44 val doc : t -> Text.t 34 45 end 35 46 ··· 68 79 end 69 80 70 81 val dom : t -> Brr.El.t 71 - 72 82 val update_listener : unit -> (Update.t -> unit, Jv.t) State.facet 73 - 74 83 val line_wrapping : unit -> Extension.t 75 84 end
-3
src/lint/lint.ml
··· 24 24 type t = Jv.t 25 25 26 26 let from t = Jv.Int.get t "from" 27 - 28 27 let to_ t = Jv.Int.get t "to" 29 28 30 29 type severity = Info | Warning | Error ··· 54 53 o 55 54 56 55 let source t = Jv.Jstr.find t "source" 57 - 58 56 let message t = Jv.Jstr.get t "message" 59 - 60 57 let actions t = Option.map (Jv.to_array Action.to_jv) (Jv.find t "actions") 61 58 62 59 include (Jv.Id : Jv.CONV with type t := t)
-7
src/lint/lint.mli
··· 14 14 15 15 module Diagnostic : sig 16 16 type t 17 - 18 17 type severity = Info | Warning | Error 19 18 20 19 val severity_of_string : string -> severity 21 - 22 20 val severity_to_string : severity -> string 23 21 24 22 val create : ··· 32 30 t 33 31 34 32 val severity : t -> severity 35 - 36 33 val from : t -> int 37 - 38 34 val to_ : t -> int 39 - 40 35 val source : t -> Jstr.t option 41 - 42 36 val actions : t -> Action.t array option 43 - 44 37 val message : t -> Jstr.t 45 38 end 46 39
+1
src/stream/stream.ml
··· 4 4 type t 5 5 6 6 include (Jv.Id : Jv.CONV with type t := t) 7 + 7 8 let g = Jv.get g "StreamLanguage" 8 9 9 10 let define (l : t) =
-6
src/text.ml
··· 6 6 type t = Jv.t 7 7 8 8 let from t = Jv.Int.get t "from" 9 - 10 9 let to_ t = Jv.Int.get t "to" 11 - 12 10 let number t = Jv.Int.get t "number" 13 - 14 11 let text t = Jv.Jstr.get t "text" 15 - 16 12 let length t = Jv.Int.get t "length" 17 13 end 18 14 19 15 let length t = Jv.Int.get t "length" 20 - 21 16 let line n t = Jv.call t "line" [| Jv.of_int n |] 22 - 23 17 let to_jstr_array t = Jv.call t "toJSON" [||] |> Jv.to_jstr_array
-1
src/text.mli
··· 26 26 (** Length of the text *) 27 27 28 28 val line : int -> t -> Line.t 29 - 30 29 val to_jstr_array : t -> Jstr.t array