123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108openCode_mirrormoduleRegExp=RegExpletautocomplete=Jv.getJv.global"__CM__autocomplete"moduleCompletion=structtypet=Jv.tinclude(Jv.Id:Jv.CONVwithtypet:=t)letset_if_some_stringtsv=Jv.Jstr.set_if_somets(Option.mapJstr.vv)letset_stringtsv=Jv.Jstr.setts(Jstr.vv)letcreate~label?detail?info?apply?type_?boost()=leto=Jv.obj[||]inset_stringo"label"label;set_if_some_stringo"detail"detail;set_if_some_stringo"info"info;Jv.set_if_someo"apply"apply;set_if_some_stringo"type"type_;Jv.Int.set_if_someo"boost"boost;oendmoduleContext=structtypet=Jv.t(** Completion context *)include(Jv.Id:Jv.CONVwithtypet:=t)letstatet=Jv.gett"state"|>State.EditorState.of_jvletpost=Jv.Int.gett"pos"letexplicitt=Jv.Bool.gett"explicit"lettoken_beforettypes=letjv=Jv.callt"tokenBefore"[|Jv.of_listJv.of_stringtypes|]inifJv.is_nonejvthenNoneelseSomejvletmatch_beforetregex=letjv=Jv.callt"matchBefore"[|RegExp.to_jvregex|]inifJv.is_nonejvthenNoneelseSomejvletabortedt=Jv.Bool.gett"aborted"endmoduleResult=structtypet=Jv.t(** Completion result *)include(Jv.Id:Jv.CONVwithtypet:=t)letcreate~from?to_~options?span?filter()=leto=Jv.obj[||]inJv.Int.seto"from"from;Jv.Int.set_if_someo"to"to_;Jv.seto"options"(Jv.of_listCompletion.to_jvoptions);Jv.set_if_someo"span"(Option.mapRegExp.to_jvspan);Jv.Bool.set_if_someo"filter"filter;oendmoduleSource=structtypet=Jv.tinclude(Jv.Id:Jv.CONVwithtypet:=t)letcreate(src:Context.t->Result.toptionFut.t)=letfctx=letfut=Fut.map(funv->Okv)@@src(Context.of_jvctx)inFut.to_promisefut~ok:(funt->Option.value~default:Jv.null(Option.mapResult.to_jvt))inJv.callback~arity:1fletfrom_list(l:Completion.tlist)=Jv.callautocomplete"completeFromList"[|Jv.of_jv_listl|]|>of_jvendtypeconfig=Jv.tletconfig?activate_on_typing?override?max_rendered_options?default_key_map?above_cursor?option_class?icons?add_to_options()=leto=Jv.obj[||]inJv.Bool.set_if_someo"activateOnTyping"activate_on_typing;Jv.set_if_someo"override"(Option.map(funv->Jv.of_jv_listv)override);Jv.Int.set_if_someo"maxRenderedOptions"max_rendered_options;Jv.Bool.set_if_someo"defaultKeyMap"default_key_map;Jv.Bool.set_if_someo"aboveCursor"above_cursor;Jv.set_if_someo"optionClass"option_class;Jv.Bool.set_if_someo"icons"icons;Jv.set_if_someo"addToOptions"add_to_options;oletcreate?(config=Jv.null)()=Extension.of_jv@@Jv.callautocomplete"autocompletion"[|config|](* type status = Active | Pending
let status state =
val status : Editor.State.t -> status option
(** Gets the current completion status *)
val current_completions : Editor.State.t -> Completion.t list
(** Returns the current available completions *)
val selected_completion : Editor.State.t -> Completion.t option
* Returh the currently selected completion if any *)