Module Autocomplete.ContextSource

An instance of this is passed to completion source functions.

Sourcetype t

Completion context

include Jv.CONV with type t := t
val to_jv : t -> Jv.jv

to_jv reveals the JavaScript implementation.

val of_jv : Jv.jv -> t

of_jv hides the JavaScript implementation. Implementations usually do not guarantee type safety.

The editor state that the completion happens in.

Sourceval pos : t -> int

The position at which the completion is happening.

Sourceval explicit : t -> bool

Indicates whether completion was activated explicitly, or implicitly by typing. The usual way to respond to this is to only return completions when either there is part of a completable entity before the cursor, or explicit is true.

Sourceval token_before : t -> string list -> Jv.t option

Get the extent, content, and (if there is a token) type of the token before this.pos.

Sourceval match_before : t -> RegExp.t -> Jv.t option

Get the match of the given expression directly before the cursor.

Sourceval aborted : t -> bool

Yields true when the query has been aborted. Can be useful in asynchronous queries to avoid doing work that will be ignored.