new(
config) ->completion,err
Create a new completion instance from a config table
The config table must contain:
path — module path for the completion search providersources — optional list of module paths for completion sourcesEach source module must export a new() constructor.
The module at config.path must return a table with at least search
and optionally the methods listed below. All provider methods are
injected directly onto the completion object, so inside them self
refers to the completion instance — giving access to self:source(),
self:provide(), self:set_meta(), etc.
Required:
search(self, input, history, cursor_pos) -> bool
Populate the candidate list for the given input line. Call
self:provide() and self:set_meta() inside. When the input
object has eol_only = false, a numeric cursor_pos is passed
so the provider can complete at any position in the line.Optional:
get(self, promoted) -> string
Return the current candidate. When promoted is true,
return raw text; otherwise return styled text for inline display.
If absent a default implementation using a built-in TSS rule is
used.
promote(self, candidate, metadata, line) -> {line=, action=}
Apply candidate to line and return the resulting line. Set
action = "execute" to trigger immediate execution. If absent, the
default behaviour is to append the candidate to the line.
should_promote_full(self) -> bool
Return true when the current candidate must skip common-prefix
narrowing and be promoted in full (e.g. line-replacement
completions).
should_auto_promote(self) -> bool
Return true when ENTER should auto-promote the current candidate
instead of submitting the line as-is.