Skip to main content
Deno 2 is finally here 🎉️
Learn more
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@v4.1.4/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 || • fargs: (table) The args split by unescaped whitespace (when more than one argument is allowed), if any || • bang: (boolean) "true" if the command was executed with a ! modifier || • line1: (number) The starting line of the command range || • line2: (number) The final line of the command range || • range: (number) The number of items in the command range: 0, 1, or 2 || • count: (number) Any count supplied || • reg: (string) The optional register, if specified || • mods: (string) Command modifiers, if any || • 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>