feat(api): add nvim_parse_cmdline

Adds an API function to parse a command line string and get command information from it.
This commit is contained in:
Famiu Haque
2022-04-23 10:21:59 +06:00
parent 3c23100130
commit 8dbb11ebf6
6 changed files with 793 additions and 71 deletions

View File

@@ -1350,6 +1350,69 @@ nvim_out_write({str}) *nvim_out_write()*
Parameters: ~
{str} Message
nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
Parse command line.
Doesn't check the validity of command arguments.
Attributes: ~
{fast}
Parameters: ~
{str} Command line string to parse. Cannot contain "\n".
{opts} Optional parameters. Reserved for future use.
Return: ~
Dictionary containing command information, with these
keys:
• cmd: (string) Command name.
• line1: (number) Starting line of command range. Only
applicable if command can take a range.
• line2: (number) Final line of command range. Only
applicable if command can take a range.
• bang: (boolean) Whether command contains a bang (!)
modifier.
• args: (array) Command arguments.
• addr: (string) Value of |:command-addr|. Uses short
name.
• nargs: (string) Value of |:command-nargs|.
• nextcmd: (string) Next command if there are multiple
commands separated by a |:bar|. Empty if there isn't a
next command.
• magic: (dictionary) Which characters have special
meaning in the command arguments.
• file: (boolean) The command expands filenames. Which
means characters such as "%", "#" and wildcards are
expanded.
• bar: (boolean) The "|" character is treated as a
command separator and the double quote character (")
is treated as the start of a comment.
• mods: (dictionary) |:command-modifiers|.
• silent: (boolean) |:silent|.
• emsg_silent: (boolean) |:silent!|.
• sandbox: (boolean) |:sandbox|.
• noautocmd: (boolean) |:noautocmd|.
• browse: (boolean) |:browse|.
• confirm: (boolean) |:confirm|.
• hide: (boolean) |:hide|.
• keepalt: (boolean) |:keepalt|.
• keepjumps: (boolean) |:keepjumps|.
• keepmarks: (boolean) |:keepmarks|.
• keeppatterns: (boolean) |:keeppatterns|.
• lockmarks: (boolean) |:lockmarks|.
• noswapfile: (boolean) |:noswapfile|.
• tab: (integer) |:tab|.
• verbose: (integer) |:verbose|.
• vertical: (boolean) |:vertical|.
• split: (string) Split modifier string, is an empty
string when there's no split modifier. If there is a
split modifier it can be one of:
• "aboveleft": |:aboveleft|.
• "belowright": |:belowright|.
• "topleft": |:topleft|.
• "botright": |:botright|.
nvim_paste({data}, {crlf}, {phase}) *nvim_paste()*
Pastes at cursor, in any mode.

View File

@@ -1421,7 +1421,7 @@ which by default correspond to the current line, last line and the whole
buffer, relate to arguments, (loaded) buffers, windows or tab pages.
Possible values are (second column is the short name used in listing):
-addr=lines Range of lines (this is the default)
-addr=lines line Range of lines (this is the default)
-addr=arguments arg Range for arguments
-addr=buffers buf Range for buffers (also not loaded buffers)
-addr=loaded_buffers load Range for loaded buffers