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.user_command

nx.user_command.create(name, command, opts)

nx.user_command.create(name, command, opts) [alias nvim_create_user_command]: register a global :Name. command is a function or an ex-command string. opts.desc (a one-line summary) is stored alongside the body — get() surfaces it and the command-line completion catalog shows it as the command’s docs. opts.usage (a string) is the command’s ARGUMENT signature — the part after the name, in vim help notation ({arg} required, [arg] optional), e.g. usage = "[config]". The completion docs pane heads with :Name <usage> exactly as a built-in’s synopsis does, so a plugin command’s parameters are discoverable in the same place. Omit it for a command that takes no arguments. opts.complete makes <Tab> in the command’s argument offer completion:

  • "dir" / "file" — path completion via the picker the built-in :cd/:edit use;
  • a function fn(args) — generate candidates dynamically. args is the list of whitespace-separated argument words typed so far, the last being the partial word under the cursor (:Cmd <Tab>{}, :Cmd a<Tab>{"a"}, :Cmd a b<Tab>{"a","b"}). It returns a list of candidates — each a string, or a table { label =, insert =, doc = }. A SYNC function (returns a list) shows inline in the wildmenu and is re-run as you type; an ASYNC one (returns a promise, e.g. an nx.async function) lists in the picker. A throw / rejection yields no candidates.

Defined in autocmd.lua.

nx.user_command.buf_create(buffer, name, command, opts)

nx.user_command.buf_create(buffer, name, command, opts) [alias nvim_buf_create_user_command]: register a buffer-local command (buffer 0 = current). It dispatches only while that buffer is current and shadows a global command of the same name there — everywhere else it’s unknown. Lives in its own per-bufnr table so the global registry stays clean; nx._resolve_user_command consults both at dispatch.

Defined in autocmd.lua.

nx.user_command.get(_opts)

No documentation comment in the prelude.

Defined in autocmd.lua.

nx.user_command.buf_get(buf, _opts)

No documentation comment in the prelude.

Defined in autocmd.lua.