Skip to main content
Module

x/denops_std/function/nvim/mod.ts>nvim_create_user_command

📚 Standard module for denops.vim
Latest
function nvim_create_user_command
import { nvim_create_user_command } from "https://deno.land/x/denops_std@v6.5.0/function/nvim/mod.ts";

Creates a global user-commands command.

For Lua usage see lua-guide-commands-create.

Example: >vim :call nvim_create_user_command('SayHello', 'echo "Hello world!"', {'bang': v:true}) :SayHello Hello world! <

Parameters:

  • {name} Name of the new user command. Must begin with an uppercase letter.
  • {command} Replacement command to execute when this user command is executed. When called from Lua, the command can also be a Lua function. The function is called with a single table argument that contains the following keys: - name: (string) Command name - args: (string) The args passed to the command, if any <args> - fargs: (table) The args split by unescaped whitespace (when more than one argument is allowed), if any <f-args> - bang: (boolean) "true" if the command was executed with a ! modifier <bang> - line1: (number) The starting line of the command range <line1> - line2: (number) The final line of the command range <line2> - range: (number) The number of items in the command range: 0, 1, or 2 <range> - count: (number) Any count supplied <count> - reg: (string) The optional register, if specified <reg> - mods: (string) Command modifiers, if any <mods> - smods: (table) Command modifiers in a structured format. Has the same structure as the "mods" key of nvim_parse_cmd().
  • {opts} Optional command-attributes. - Set boolean attributes such as :command-bang or :command-bar to true (but not :command-buffer, use nvim_buf_create_user_command() instead). - "complete" :command-complete also accepts a Lua function which works like :command-completion-customlist. - Other parameters: - desc: (string) Used for listing the command when a Lua function is used for {command}. - force: (boolean, default true) Override any previous definition. - preview: (function) Preview callback for 'inccommand' :command-preview

Parameters

denops: Denops
name: unknown
command: unknown
opts: unknown

Returns

Promise<unknown>