Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

nx.complete

nx.complete.setup(opts)

nx.complete.setup { sources = { { “buffer”, min_chars = 3 } }, auto = true, keys = { next = “<C-n>”, prev = “<C-p>”, confirm = { “<C-y>”, “<CR>” }, abort = “<C-e>” } } (confirm accepts the highlighted row; <CR> only accepts once you’ve navigated to one — an unnavigated popup is noselect, so Enter still inserts a newline.) Enables the engine. sources is a list of { name, opts... } entries — a built-in (buffer / lsp / snippets) or a registered plugin source. min_chars (from a source, or the top level) gates the prefix length before the popup opens. auto (default true) completes as you type. keys overrides any of the four control actions.

Defined in complete.lua.

nx.complete.trigger()

nx.complete.trigger(): manually open (or refresh) the completion popup at the cursor, ignoring auto / min_chars (an explicit request always offers what’s there). A no-op outside insert mode or before nx.complete.setup{}.

Defined in complete.lua.

nx.complete.source(spec)

nx.complete.source { name, complete = function(ctx)[, debounce] }: register an async completion source. complete streams candidates for the prefix in ctx ({ prefix, buf, row, col }): it calls ctx.push(item) per result — a string (used as both the menu label and the inserted text) or a table { text = <label>, insert = <applied on accept> } — and signals completion by returning (an nx.async source returns its promise; a synchronous one just returns — nx is promise-only, so there is no done callback). The source runs off the input path (debounced by debounce ms, default nx.complete.debounce), and its results are generation-gated: a reply for a prefix the user has typed past is dropped. Register a ctx.on_cancel(fn) reaper to kill an in-flight job when the next prefix supersedes this one. Activate the source by listing its name in nx.complete.setup{ sources = { ... } }.

trigger = { chars = { ":" } } (optional) gates the source: the engine wakes it only when the completion prefix leads with one of those chars (the emoji shape), folding the char into the prefix so the source matches :smi and accept replaces from the :. resolve = function(item) (optional) supplies docs lazily: push an item with no doc, and when the user selects it the engine calls resolve(item), which returns a PROMISE of the docs — a doc string, or an item whose .doc is used. Use it when computing docs up front for every candidate is wasteful.

Defined in complete.lua.