Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

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

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

Create a new user command user-commands

{name} is the name of the new command. The name must begin with an uppercase letter.

{command} is the replacement text or Lua function to execute.

Example:

:call nvim_create_user_command('SayHello', 'echo "Hello world!"', {})
: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: - 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. See command-attributes for more details. To use boolean attributes (such as :command-bang or :command-bar) set the value to "true". In addition to the string options listed in :command-complete, the "complete" key also accepts a Lua function which works like the "customlist" completion mode :command-completion-customlist. Additional 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>