mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #30435 refactor: rename "Dictionary" => "Dict"
This commit is contained in:
commit
34a40d3a50
@ -42,9 +42,9 @@ The RPC API is like a more powerful version of Vim's "clientserver" feature.
|
||||
CONNECTING *rpc-connecting*
|
||||
|
||||
See |channel-intro| for various ways to open a channel. Channel-opening
|
||||
functions take an `rpc` key in the options dictionary. RPC channels can also
|
||||
be opened by other processes connecting to TCP/IP sockets or named pipes
|
||||
listened to by Nvim.
|
||||
functions take an `rpc` key in the options dict. RPC channels can also be
|
||||
opened by other processes connecting to TCP/IP sockets or named pipes listened
|
||||
to by Nvim.
|
||||
|
||||
Nvim creates a default RPC socket at |startup|, given by |v:servername|. To
|
||||
start with a TCP/IP socket instead, use |--listen| with a TCP-style address: >
|
||||
@ -108,9 +108,9 @@ Basic types ~
|
||||
Integer (signed 64-bit integer) int64_t
|
||||
Float (IEEE 754 double precision) double
|
||||
String {char* data, size_t size} struct
|
||||
Array
|
||||
Dictionary (msgpack: map)
|
||||
Object
|
||||
Array kvec
|
||||
Dict (msgpack: map) kvec
|
||||
Object any of the above
|
||||
<
|
||||
Note:
|
||||
- Empty Array is accepted as a valid Dictionary parameter.
|
||||
@ -708,12 +708,12 @@ nvim_eval_statusline({str}, {opts}) *nvim_eval_statusline()*
|
||||
line number instead of statusline.
|
||||
|
||||
Return: ~
|
||||
Dictionary containing statusline information, with these keys:
|
||||
Dict containing statusline information, with these keys:
|
||||
• str: (string) Characters that will be displayed on the statusline.
|
||||
• width: (number) Display width of the statusline.
|
||||
• highlights: Array containing highlight information of the
|
||||
statusline. Only included when the "highlights" key in {opts} is
|
||||
true. Each element of the array is a |Dictionary| with these keys:
|
||||
true. Each element of the array is a |Dict| with these keys:
|
||||
• start: (number) Byte index (0-based) of first character that uses
|
||||
the highlight.
|
||||
• group: (string) Name of highlight group.
|
||||
@ -763,7 +763,7 @@ nvim_feedkeys({keys}, {mode}, {escape_ks}) *nvim_feedkeys()*
|
||||
|
||||
nvim_get_api_info() *nvim_get_api_info()*
|
||||
Returns a 2-tuple (Array), where item 0 is the current channel id and item
|
||||
1 is the |api-metadata| map (Dictionary).
|
||||
1 is the |api-metadata| map (Dict).
|
||||
|
||||
Attributes: ~
|
||||
|api-fast|
|
||||
@ -939,7 +939,7 @@ nvim_get_mode() *nvim_get_mode()*
|
||||
|api-fast|
|
||||
|
||||
Return: ~
|
||||
Dictionary { "mode": String, "blocking": Boolean }
|
||||
Dict { "mode": String, "blocking": Boolean }
|
||||
|
||||
nvim_get_proc({pid}) *nvim_get_proc()*
|
||||
Gets info describing process `pid`.
|
||||
@ -1249,8 +1249,7 @@ nvim_set_client_info({name}, {version}, {type}, {methods}, {attributes})
|
||||
|
||||
Parameters: ~
|
||||
• {name} Short name for the connected client
|
||||
• {version} Dictionary describing the version, with these (optional)
|
||||
keys:
|
||||
• {version} Dict describing the version, with these (optional) keys:
|
||||
• "major" major version (defaults to 0 if not set, for
|
||||
no release yet)
|
||||
• "minor" minor version
|
||||
@ -1475,7 +1474,7 @@ nvim__complete_set({index}, {opts}) *nvim__complete_set()*
|
||||
• info: (string) info text.
|
||||
|
||||
Return: ~
|
||||
Dictionary containing these keys:
|
||||
Dict containing these keys:
|
||||
• winid: (number) floating window id
|
||||
• bufnr: (number) buffer id in floating window
|
||||
|
||||
@ -1517,14 +1516,14 @@ nvim__id_array({arr}) *nvim__id_array()*
|
||||
Return: ~
|
||||
its argument.
|
||||
|
||||
nvim__id_dictionary({dct}) *nvim__id_dictionary()*
|
||||
Returns dictionary given as argument.
|
||||
nvim__id_dict({dct}) *nvim__id_dict()*
|
||||
Returns dict given as argument.
|
||||
|
||||
This API function is used for testing. One should not rely on its presence
|
||||
in plugins.
|
||||
|
||||
Parameters: ~
|
||||
• {dct} Dictionary to return.
|
||||
• {dct} Dict to return.
|
||||
|
||||
Return: ~
|
||||
its argument.
|
||||
@ -1595,7 +1594,7 @@ nvim_call_dict_function({dict}, {fn}, {args})
|
||||
On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
|
||||
Parameters: ~
|
||||
• {dict} Dictionary, or String evaluating to a Vimscript |self| dict
|
||||
• {dict} Dict, or String evaluating to a Vimscript |self| dict
|
||||
• {fn} Name of the function defined on the Vimscript dict
|
||||
• {args} Function arguments packed in an Array
|
||||
|
||||
@ -1629,7 +1628,7 @@ nvim_command({command}) *nvim_command()*
|
||||
• {command} Ex command string
|
||||
|
||||
nvim_eval({expr}) *nvim_eval()*
|
||||
Evaluates a Vimscript |expression|. Dictionaries and Lists are recursively
|
||||
Evaluates a Vimscript |expression|. Dicts and Lists are recursively
|
||||
expanded.
|
||||
|
||||
On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
@ -1656,7 +1655,7 @@ nvim_exec2({src}, {opts}) *nvim_exec2()*
|
||||
return all (non-error, non-shell |:!|) output.
|
||||
|
||||
Return: ~
|
||||
Dictionary containing information about execution, with these keys:
|
||||
Dict containing information about execution, with these keys:
|
||||
• output: (string|nil) Output if `opts.output` is true.
|
||||
|
||||
See also: ~
|
||||
@ -1693,9 +1692,9 @@ nvim_parse_expression({expr}, {flags}, {highlight})
|
||||
region [start_col, end_col)).
|
||||
|
||||
Return: ~
|
||||
• AST: top-level dictionary with these keys:
|
||||
• "error": Dictionary with error, present only if parser saw some
|
||||
error. Contains the following keys:
|
||||
• AST: top-level dict with these keys:
|
||||
• "error": Dict with error, present only if parser saw some error.
|
||||
Contains the following keys:
|
||||
• "message": String, error message in printf format, translated.
|
||||
Must contain exactly one "%.*s".
|
||||
• "arg": String, error message argument.
|
||||
@ -1703,7 +1702,7 @@ nvim_parse_expression({expr}, {flags}, {highlight})
|
||||
that should be equal to the length of expr string. ("Successfully
|
||||
parsed" here means "participated in AST creation", not "till the
|
||||
first error".)
|
||||
• "ast": AST, either nil or a dictionary with these keys:
|
||||
• "ast": AST, either nil or a dict with these keys:
|
||||
• "type": node type, one of the value names from ExprASTNodeType
|
||||
stringified without "kExprNode" prefix.
|
||||
• "start": a pair `[line, column]` describing where node is
|
||||
@ -1779,8 +1778,8 @@ nvim_buf_get_commands({buffer}, {opts}) *nvim_buf_get_commands()*
|
||||
nvim_cmd({cmd}, {opts}) *nvim_cmd()*
|
||||
Executes an Ex command.
|
||||
|
||||
Unlike |nvim_command()| this command takes a structured Dictionary instead
|
||||
of a String. This allows for easier construction and manipulation of an Ex
|
||||
Unlike |nvim_command()| this command takes a structured Dict instead of a
|
||||
String. This allows for easier construction and manipulation of an Ex
|
||||
command. This also allows for things such as having spaces inside a
|
||||
command argument, expanding filenames in a command that otherwise doesn't
|
||||
expand filenames, etc. Command arguments may also be Number, Boolean or
|
||||
@ -1794,8 +1793,8 @@ nvim_cmd({cmd}, {opts}) *nvim_cmd()*
|
||||
On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
|
||||
Parameters: ~
|
||||
• {cmd} Command to execute. Must be a Dictionary that can contain the
|
||||
same values as the return value of |nvim_parse_cmd()| except
|
||||
• {cmd} Command to execute. Must be a Dict that can contain the same
|
||||
values as the return value of |nvim_parse_cmd()| except
|
||||
"addr", "nargs" and "nextcmd" which are ignored if provided.
|
||||
All values except for "cmd" are optional.
|
||||
• {opts} Optional parameters.
|
||||
@ -1897,7 +1896,7 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
|
||||
• {opts} Optional parameters. Reserved for future use.
|
||||
|
||||
Return: ~
|
||||
Dictionary containing command information, with these keys:
|
||||
Dict containing command information, with these keys:
|
||||
• cmd: (string) Command name.
|
||||
• range: (array) (optional) Command range (<line1> <line2>). Omitted
|
||||
if command doesn't accept a range. Otherwise, has no elements if no
|
||||
@ -1914,15 +1913,15 @@ nvim_parse_cmd({str}, {opts}) *nvim_parse_cmd()*
|
||||
• 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.
|
||||
• magic: (dict) 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|.
|
||||
• filter: (dictionary) |:filter|.
|
||||
• mods: (dict) |:command-modifiers|.
|
||||
• filter: (dict) |:filter|.
|
||||
• pattern: (string) Filter pattern. Empty string if there is no
|
||||
filter.
|
||||
• force: (boolean) Whether filter is inverted or not.
|
||||
@ -1959,11 +1958,11 @@ Options Functions *api-options*
|
||||
nvim_get_all_options_info() *nvim_get_all_options_info()*
|
||||
Gets the option information for all options.
|
||||
|
||||
The dictionary has the full option names as keys and option metadata
|
||||
dictionaries as detailed at |nvim_get_option_info2()|.
|
||||
The dict has the full option names as keys and option metadata dicts as
|
||||
detailed at |nvim_get_option_info2()|.
|
||||
|
||||
Return: ~
|
||||
dictionary of all options
|
||||
dict of all options
|
||||
|
||||
See also: ~
|
||||
• |nvim_get_commands()|
|
||||
@ -1971,7 +1970,7 @@ nvim_get_all_options_info() *nvim_get_all_options_info()*
|
||||
nvim_get_option_info2({name}, {opts}) *nvim_get_option_info2()*
|
||||
Gets the option information for one option from arbitrary buffer or window
|
||||
|
||||
Resulting dictionary has keys:
|
||||
Resulting dict has keys:
|
||||
• name: Name of the option (like 'filetype')
|
||||
• shortname: Shortened name of the option (like 'ft')
|
||||
• type: type of option ("string", "number" or "boolean")
|
||||
@ -3081,7 +3080,7 @@ nvim_win_text_height({window}, {opts}) *nvim_win_text_height()*
|
||||
omitted include the whole line.
|
||||
|
||||
Return: ~
|
||||
Dictionary containing text height information, with these keys:
|
||||
Dict containing text height information, with these keys:
|
||||
• all: The total number of screen lines occupied by the range.
|
||||
• fill: The number of diff filler or virtual lines among them.
|
||||
|
||||
@ -3405,7 +3404,7 @@ nvim_create_augroup({name}, {opts}) *nvim_create_augroup()*
|
||||
|
||||
Parameters: ~
|
||||
• {name} String: The name of the group
|
||||
• {opts} Dictionary Parameters
|
||||
• {opts} Dict Parameters
|
||||
• clear (bool) optional: defaults to true. Clear existing
|
||||
commands if the group already exists |autocmd-groups|.
|
||||
|
||||
@ -3524,7 +3523,7 @@ nvim_exec_autocmds({event}, {opts}) *nvim_exec_autocmds()*
|
||||
|
||||
Parameters: ~
|
||||
• {event} (String|Array) The event or events to execute
|
||||
• {opts} Dictionary of autocommand options:
|
||||
• {opts} Dict of autocommand options:
|
||||
• group (string|integer) optional: the autocommand group name
|
||||
or id to match against. |autocmd-groups|.
|
||||
• pattern (string|array) optional: defaults to "*"
|
||||
@ -3560,7 +3559,7 @@ nvim_get_autocmds({opts}) *nvim_get_autocmds()*
|
||||
autocommands that match any combination of them.
|
||||
|
||||
Parameters: ~
|
||||
• {opts} Dictionary with at least one of the following:
|
||||
• {opts} Dict with at least one of the following:
|
||||
• group (string|integer): the autocommand group name or id to
|
||||
match against.
|
||||
• event (string|array): event or events to match against
|
||||
|
@ -1058,7 +1058,7 @@ Lua module: vim.lsp.client *lsp-client*
|
||||
`client.cancel_request(request_id)` to cancel
|
||||
the request.
|
||||
• {request_sync} (`fun(method: string, params: table?, timeout_ms: integer?, bufnr: integer): {err: lsp.ResponseError?, result:any}?, string?`)
|
||||
err # a dictionary, where
|
||||
err # a dict
|
||||
• {notify} (`fun(method: string, params: table?): boolean`)
|
||||
Sends a notification to an LSP server.
|
||||
Returns: a boolean to indicate if the
|
||||
|
@ -35,6 +35,12 @@ API
|
||||
now maintain their own list of channels.
|
||||
• In the future, |vim.rpcnotify()| may accept a list of channels, if there
|
||||
is demand for this use-case.
|
||||
• "Dictionary" was renamed to "Dict" internally and in the RPC |api-metadata|.
|
||||
This is not expected to break clients because there are no known clients
|
||||
that actually use the `return_type` field or the parameter type names
|
||||
reported by |--api-info| or |nvim_get_api_info()|.
|
||||
• Renamed `nvim__id_dictionary` (unsupported/experimental API) to
|
||||
`nvim__id_dict`.
|
||||
|
||||
DEFAULTS
|
||||
|
||||
|
34
runtime/lua/vim/_meta/api.lua
generated
34
runtime/lua/vim/_meta/api.lua
generated
@ -64,14 +64,14 @@ function vim.api.nvim__id(obj) end
|
||||
function vim.api.nvim__id_array(arr) end
|
||||
|
||||
--- @private
|
||||
--- Returns dictionary given as argument.
|
||||
--- Returns dict given as argument.
|
||||
---
|
||||
--- This API function is used for testing. One should not rely on its presence
|
||||
--- in plugins.
|
||||
---
|
||||
--- @param dct table<string,any> Dictionary to return.
|
||||
--- @param dct table<string,any> Dict to return.
|
||||
--- @return table<string,any>
|
||||
function vim.api.nvim__id_dictionary(dct) end
|
||||
function vim.api.nvim__id_dict(dct) end
|
||||
|
||||
--- @private
|
||||
--- Returns floating-point value given as argument.
|
||||
@ -777,7 +777,7 @@ function vim.api.nvim_buf_set_virtual_text(buffer, src_id, line, chunks, opts) e
|
||||
---
|
||||
--- On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
---
|
||||
--- @param dict any Dictionary, or String evaluating to a Vimscript `self` dict
|
||||
--- @param dict any Dict, or String evaluating to a Vimscript `self` dict
|
||||
--- @param fn string Name of the function defined on the Vimscript dict
|
||||
--- @param args any[] Function arguments packed in an Array
|
||||
--- @return any
|
||||
@ -830,8 +830,8 @@ function vim.api.nvim_clear_autocmds(opts) end
|
||||
|
||||
--- Executes an Ex command.
|
||||
---
|
||||
--- Unlike `nvim_command()` this command takes a structured Dictionary instead
|
||||
--- of a String. This allows for easier construction and manipulation of an Ex
|
||||
--- Unlike `nvim_command()` this command takes a structured Dict instead of a
|
||||
--- String. This allows for easier construction and manipulation of an Ex
|
||||
--- command. This also allows for things such as having spaces inside a
|
||||
--- command argument, expanding filenames in a command that otherwise doesn't
|
||||
--- expand filenames, etc. Command arguments may also be Number, Boolean or
|
||||
@ -844,10 +844,10 @@ function vim.api.nvim_clear_autocmds(opts) end
|
||||
---
|
||||
--- On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
---
|
||||
--- @param cmd vim.api.keyset.cmd Command to execute. Must be a Dictionary that can contain the
|
||||
--- same values as the return value of `nvim_parse_cmd()` except
|
||||
--- "addr", "nargs" and "nextcmd" which are ignored if provided.
|
||||
--- All values except for "cmd" are optional.
|
||||
--- @param cmd vim.api.keyset.cmd Command to execute. Must be a Dict that can contain the same
|
||||
--- values as the return value of `nvim_parse_cmd()` except "addr",
|
||||
--- "nargs" and "nextcmd" which are ignored if provided. All values
|
||||
--- except for "cmd" are optional.
|
||||
--- @param opts vim.api.keyset.cmd_opts Optional parameters.
|
||||
--- • output: (boolean, default false) Whether to return command
|
||||
--- output.
|
||||
@ -884,7 +884,7 @@ function vim.api.nvim_command_output(command) end
|
||||
---
|
||||
---
|
||||
--- @param name string String: The name of the group
|
||||
--- @param opts vim.api.keyset.create_augroup Dictionary Parameters
|
||||
--- @param opts vim.api.keyset.create_augroup Dict Parameters
|
||||
--- • clear (bool) optional: defaults to true. Clear existing
|
||||
--- commands if the group already exists `autocmd-groups`.
|
||||
--- @return integer
|
||||
@ -1111,7 +1111,7 @@ function vim.api.nvim_err_write(str) end
|
||||
--- @param str string Message
|
||||
function vim.api.nvim_err_writeln(str) end
|
||||
|
||||
--- Evaluates a Vimscript `expression`. Dictionaries and Lists are recursively
|
||||
--- Evaluates a Vimscript `expression`. Dicts and Lists are recursively
|
||||
--- expanded.
|
||||
---
|
||||
--- On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
@ -1165,7 +1165,7 @@ function vim.api.nvim_exec2(src, opts) end
|
||||
--- `autocmd-execute`.
|
||||
---
|
||||
--- @param event any (String|Array) The event or events to execute
|
||||
--- @param opts vim.api.keyset.exec_autocmds Dictionary of autocommand options:
|
||||
--- @param opts vim.api.keyset.exec_autocmds Dict of autocommand options:
|
||||
--- • group (string|integer) optional: the autocommand group name
|
||||
--- or id to match against. `autocmd-groups`.
|
||||
--- • pattern (string|array) optional: defaults to "*"
|
||||
@ -1204,8 +1204,8 @@ function vim.api.nvim_feedkeys(keys, mode, escape_ks) end
|
||||
|
||||
--- Gets the option information for all options.
|
||||
---
|
||||
--- The dictionary has the full option names as keys and option metadata
|
||||
--- dictionaries as detailed at `nvim_get_option_info2()`.
|
||||
--- The dict has the full option names as keys and option metadata dicts as
|
||||
--- detailed at `nvim_get_option_info2()`.
|
||||
---
|
||||
--- @return table<string,any>
|
||||
function vim.api.nvim_get_all_options_info() end
|
||||
@ -1231,7 +1231,7 @@ function vim.api.nvim_get_all_options_info() end
|
||||
--- NOTE: When multiple patterns or events are provided, it will find all the
|
||||
--- autocommands that match any combination of them.
|
||||
---
|
||||
--- @param opts vim.api.keyset.get_autocmds Dictionary with at least one of the following:
|
||||
--- @param opts vim.api.keyset.get_autocmds Dict with at least one of the following:
|
||||
--- • group (string|integer): the autocommand group name or id to
|
||||
--- match against.
|
||||
--- • event (string|array): event or events to match against
|
||||
@ -1394,7 +1394,7 @@ function vim.api.nvim_get_option_info(name) end
|
||||
|
||||
--- Gets the option information for one option from arbitrary buffer or window
|
||||
---
|
||||
--- Resulting dictionary has keys:
|
||||
--- Resulting dict has keys:
|
||||
--- • name: Name of the option (like 'filetype')
|
||||
--- • shortname: Shortened name of the option (like 'ft')
|
||||
--- • type: type of option ("string", "number" or "boolean")
|
||||
|
@ -233,11 +233,11 @@ local validate = vim.validate
|
||||
---
|
||||
--- Sends a request to the server and synchronously waits for the response.
|
||||
--- This is a wrapper around {client.request}
|
||||
--- Returns: { err=err, result=result }, a dictionary, where `err` and `result`
|
||||
--- Returns: { err=err, result=result }, a dict, where `err` and `result`
|
||||
--- come from the |lsp-handler|. On timeout, cancel or error, returns `(nil,
|
||||
--- err)` where `err` is a string describing the failure reason. If the request
|
||||
--- was unsuccessful returns `nil`.
|
||||
--- @field request_sync fun(method: string, params: table?, timeout_ms: integer?, bufnr: integer): {err: lsp.ResponseError|nil, result:any}|nil, string|nil err # a dictionary, where
|
||||
--- @field request_sync fun(method: string, params: table?, timeout_ms: integer?, bufnr: integer): {err: lsp.ResponseError|nil, result:any}|nil, string|nil err # a dict
|
||||
---
|
||||
--- Sends a notification to an LSP server.
|
||||
--- Returns: a boolean to indicate if the notification was successful. If
|
||||
@ -738,7 +738,7 @@ end
|
||||
--- @param timeout_ms (integer|nil) Maximum time in milliseconds to wait for
|
||||
--- a result. Defaults to 1000
|
||||
--- @param bufnr (integer) Buffer handle (0 for current).
|
||||
--- @return {err: lsp.ResponseError|nil, result:any}|nil, string|nil err # a dictionary, where
|
||||
--- @return {err: lsp.ResponseError|nil, result:any}|nil, string|nil err # a dict, where
|
||||
--- `err` and `result` come from the |lsp-handler|.
|
||||
--- On timeout, cancel or error, returns `(nil, err)` where `err` is a
|
||||
--- string describing the failure reason. If the request was unsuccessful
|
||||
|
@ -112,7 +112,7 @@ local API_TYPES = {
|
||||
String = 'string',
|
||||
Array = 'any[]',
|
||||
LuaRef = 'function',
|
||||
Dictionary = 'table<string,any>',
|
||||
Dict = 'table<string,any>',
|
||||
Float = 'number',
|
||||
HLGroupID = 'number|string',
|
||||
void = '',
|
||||
@ -140,7 +140,7 @@ local function api_type(t)
|
||||
return 'vim.api.keyset.' .. d
|
||||
end
|
||||
|
||||
local d0 = t:match('^DictionaryOf%((.*)%)')
|
||||
local d0 = t:match('^DictOf%((.*)%)')
|
||||
if d0 then
|
||||
return 'table<string,' .. api_type(d0) .. '>'
|
||||
end
|
||||
|
@ -1781,7 +1781,7 @@ def CheckSpacing(filename, clean_lines, linenum, error):
|
||||
r'(?<!\bPMap)'
|
||||
r'(?<!\bSet)'
|
||||
r'(?<!\bArrayOf)'
|
||||
r'(?<!\bDictionaryOf)'
|
||||
r'(?<!\bDictOf)'
|
||||
r'(?<!\bDict)'
|
||||
r'\((?:const )?(?:struct )?[a-zA-Z_]\w*(?: *\*(?:const)?)*\)'
|
||||
r' +'
|
||||
|
@ -67,7 +67,7 @@ static int64_t next_autocmd_id = 1;
|
||||
/// NOTE: When multiple patterns or events are provided, it will find all the autocommands that
|
||||
/// match any combination of them.
|
||||
///
|
||||
/// @param opts Dictionary with at least one of the following:
|
||||
/// @param opts Dict with at least one of the following:
|
||||
/// - group (string|integer): the autocommand group name or id to match against.
|
||||
/// - event (string|array): event or events to match against |autocmd-events|.
|
||||
/// - pattern (string|array): pattern or patterns to match against |autocmd-pattern|.
|
||||
@ -270,7 +270,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Arena *arena, Error *err)
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary autocmd_info = arena_dict(arena, 11);
|
||||
Dict autocmd_info = arena_dict(arena, 11);
|
||||
|
||||
if (ap->group != AUGROUP_DEFAULT) {
|
||||
PUT_C(autocmd_info, "group", INTEGER_OBJ(ap->group));
|
||||
@ -334,7 +334,7 @@ Array nvim_get_autocmds(Dict(get_autocmds) *opts, Arena *arena, Error *err)
|
||||
// PUT_C(autocmd_info, "sid", INTEGER_OBJ(ac->script_ctx.sc_sid));
|
||||
// PUT_C(autocmd_info, "lnum", INTEGER_OBJ(ac->script_ctx.sc_lnum));
|
||||
|
||||
kvi_push(autocmd_list, DICTIONARY_OBJ(autocmd_info));
|
||||
kvi_push(autocmd_list, DICT_OBJ(autocmd_info));
|
||||
}
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Arena *arena, Error *err)
|
||||
/// ```
|
||||
///
|
||||
/// @param name String: The name of the group
|
||||
/// @param opts Dictionary Parameters
|
||||
/// @param opts Dict Parameters
|
||||
/// - clear (bool) optional: defaults to true. Clear existing
|
||||
/// commands if the group already exists |autocmd-groups|.
|
||||
/// @return Integer id of the created group.
|
||||
@ -686,7 +686,7 @@ void nvim_del_augroup_by_name(String name, Error *err)
|
||||
/// Execute all autocommands for {event} that match the corresponding
|
||||
/// {opts} |autocmd-execute|.
|
||||
/// @param event (String|Array) The event or events to execute
|
||||
/// @param opts Dictionary of autocommand options:
|
||||
/// @param opts Dict of autocommand options:
|
||||
/// - group (string|integer) optional: the autocommand group name or
|
||||
/// id to match against. |autocmd-groups|.
|
||||
/// - pattern (string|array) optional: defaults to "*" |autocmd-pattern|. Cannot be used
|
||||
|
@ -866,7 +866,7 @@ Integer nvim_buf_get_changedtick(Buffer buffer, Error *err)
|
||||
/// @param[out] err Error details, if any
|
||||
/// @returns Array of |maparg()|-like dictionaries describing mappings.
|
||||
/// The "buffer" key holds the associated buffer handle.
|
||||
ArrayOf(Dictionary) nvim_buf_get_keymap(Buffer buffer, String mode, Arena *arena, Error *err)
|
||||
ArrayOf(Dict) nvim_buf_get_keymap(Buffer buffer, String mode, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(3)
|
||||
{
|
||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||
@ -1221,14 +1221,14 @@ Object nvim_buf_call(Buffer buffer, LuaRef fun, Error *err)
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
Dictionary nvim__buf_stats(Buffer buffer, Arena *arena, Error *err)
|
||||
Dict nvim__buf_stats(Buffer buffer, Arena *arena, Error *err)
|
||||
{
|
||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||
if (!buf) {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
Dictionary rv = arena_dict(arena, 7);
|
||||
Dict rv = arena_dict(arena, 7);
|
||||
// Number of times the cached line was flushed.
|
||||
// This should generally not increase while editing the same
|
||||
// line in the same mode.
|
||||
|
@ -46,7 +46,7 @@
|
||||
/// @param str Command line string to parse. Cannot contain "\n".
|
||||
/// @param opts Optional parameters. Reserved for future use.
|
||||
/// @param[out] err Error details, if any.
|
||||
/// @return Dictionary containing command information, with these keys:
|
||||
/// @return Dict containing command information, with these keys:
|
||||
/// - cmd: (string) Command name.
|
||||
/// - range: (array) (optional) Command range ([<line1>] [<line2>]).
|
||||
/// Omitted if command doesn't accept a range.
|
||||
@ -63,13 +63,13 @@
|
||||
/// - 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.
|
||||
/// - magic: (dict) 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|.
|
||||
/// - filter: (dictionary) |:filter|.
|
||||
/// - mods: (dict) |:command-modifiers|.
|
||||
/// - filter: (dict) |:filter|.
|
||||
/// - pattern: (string) Filter pattern. Empty string if there is no filter.
|
||||
/// - force: (boolean) Whether filter is inverted or not.
|
||||
/// - silent: (boolean) |:silent|.
|
||||
@ -230,12 +230,12 @@ Dict(cmd) nvim_parse_cmd(String str, Dict(empty) *opts, Arena *arena, Error *err
|
||||
PUT_KEY(result, cmd, nextcmd, CSTR_AS_OBJ(ea.nextcmd));
|
||||
|
||||
// TODO(bfredl): nested keydict would be nice..
|
||||
Dictionary mods = arena_dict(arena, 20);
|
||||
Dict mods = arena_dict(arena, 20);
|
||||
|
||||
Dictionary filter = arena_dict(arena, 2);
|
||||
Dict filter = arena_dict(arena, 2);
|
||||
PUT_C(filter, "pattern", CSTR_TO_ARENA_OBJ(arena, cmdinfo.cmdmod.cmod_filter_pat));
|
||||
PUT_C(filter, "force", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_filter_force));
|
||||
PUT_C(mods, "filter", DICTIONARY_OBJ(filter));
|
||||
PUT_C(mods, "filter", DICT_OBJ(filter));
|
||||
|
||||
PUT_C(mods, "silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_SILENT));
|
||||
PUT_C(mods, "emsg_silent", BOOLEAN_OBJ(cmdinfo.cmdmod.cmod_flags & CMOD_ERRSILENT));
|
||||
@ -272,7 +272,7 @@ Dict(cmd) nvim_parse_cmd(String str, Dict(empty) *opts, Arena *arena, Error *err
|
||||
|
||||
PUT_KEY(result, cmd, mods, mods);
|
||||
|
||||
Dictionary magic = arena_dict(arena, 2);
|
||||
Dict magic = arena_dict(arena, 2);
|
||||
PUT_C(magic, "file", BOOLEAN_OBJ(cmdinfo.magic.file));
|
||||
PUT_C(magic, "bar", BOOLEAN_OBJ(cmdinfo.magic.bar));
|
||||
PUT_KEY(result, cmd, magic, magic);
|
||||
@ -284,7 +284,7 @@ end:
|
||||
|
||||
/// Executes an Ex command.
|
||||
///
|
||||
/// Unlike |nvim_command()| this command takes a structured Dictionary instead of a String. This
|
||||
/// Unlike |nvim_command()| this command takes a structured Dict instead of a String. This
|
||||
/// allows for easier construction and manipulation of an Ex command. This also allows for things
|
||||
/// such as having spaces inside a command argument, expanding filenames in a command that otherwise
|
||||
/// doesn't expand filenames, etc. Command arguments may also be Number, Boolean or String.
|
||||
@ -298,7 +298,7 @@ end:
|
||||
/// @see |nvim_exec2()|
|
||||
/// @see |nvim_command()|
|
||||
///
|
||||
/// @param cmd Command to execute. Must be a Dictionary that can contain the same values as
|
||||
/// @param cmd Command to execute. Must be a Dict that can contain the same values as
|
||||
/// the return value of |nvim_parse_cmd()| except "addr", "nargs" and "nextcmd"
|
||||
/// which are ignored if provided. All values except for "cmd" are optional.
|
||||
/// @param opts Optional parameters.
|
||||
@ -1166,7 +1166,7 @@ err:
|
||||
/// @param[out] err Error details, if any.
|
||||
///
|
||||
/// @returns Map of maps describing commands.
|
||||
Dictionary nvim_get_commands(Dict(get_commands) *opts, Arena *arena, Error *err)
|
||||
Dict nvim_get_commands(Dict(get_commands) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(4)
|
||||
{
|
||||
return nvim_buf_get_commands(-1, opts, arena, err);
|
||||
@ -1179,25 +1179,25 @@ Dictionary nvim_get_commands(Dict(get_commands) *opts, Arena *arena, Error *err)
|
||||
/// @param[out] err Error details, if any.
|
||||
///
|
||||
/// @returns Map of maps describing commands.
|
||||
Dictionary nvim_buf_get_commands(Buffer buffer, Dict(get_commands) *opts, Arena *arena, Error *err)
|
||||
Dict nvim_buf_get_commands(Buffer buffer, Dict(get_commands) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(4)
|
||||
{
|
||||
bool global = (buffer == -1);
|
||||
if (ERROR_SET(err)) {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
if (global) {
|
||||
if (opts->builtin) {
|
||||
api_set_error(err, kErrorTypeValidation, "builtin=true not implemented");
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
return commands_array(NULL, arena);
|
||||
}
|
||||
|
||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||
if (opts->builtin || !buf) {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
return commands_array(buf, arena);
|
||||
}
|
||||
|
@ -183,11 +183,11 @@ Integer nvim_buf_set_virtual_text(Buffer buffer, Integer src_id, Integer line, A
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Highlight definition map
|
||||
/// @see nvim_get_hl_by_name
|
||||
Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Arena *arena, Error *err)
|
||||
Dict nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(3)
|
||||
FUNC_API_DEPRECATED_SINCE(9)
|
||||
{
|
||||
Dictionary dic = ARRAY_DICT_INIT;
|
||||
Dict dic = ARRAY_DICT_INIT;
|
||||
VALIDATE_INT((syn_get_final_id((int)hl_id) != 0), "highlight id", hl_id, {
|
||||
return dic;
|
||||
});
|
||||
@ -204,11 +204,11 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Arena *arena, Error *er
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Highlight definition map
|
||||
/// @see nvim_get_hl_by_id
|
||||
Dictionary nvim_get_hl_by_name(String name, Boolean rgb, Arena *arena, Error *err)
|
||||
Dict nvim_get_hl_by_name(String name, Boolean rgb, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(3)
|
||||
FUNC_API_DEPRECATED_SINCE(9)
|
||||
{
|
||||
Dictionary result = ARRAY_DICT_INIT;
|
||||
Dict result = ARRAY_DICT_INIT;
|
||||
int id = syn_name2id(name.data);
|
||||
|
||||
VALIDATE_S((id != 0), "highlight name", name.data, {
|
||||
@ -515,7 +515,7 @@ static int64_t convert_index(int64_t index)
|
||||
/// @param name Option name
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Option Information
|
||||
Dictionary nvim_get_option_info(String name, Arena *arena, Error *err)
|
||||
Dict nvim_get_option_info(String name, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(7)
|
||||
FUNC_API_DEPRECATED_SINCE(11)
|
||||
{
|
||||
|
@ -74,10 +74,10 @@ Integer nvim_create_namespace(String name)
|
||||
/// Gets existing, non-anonymous |namespace|s.
|
||||
///
|
||||
/// @return dict that maps from names to namespace ids.
|
||||
Dictionary nvim_get_namespaces(Arena *arena)
|
||||
Dict nvim_get_namespaces(Arena *arena)
|
||||
FUNC_API_SINCE(5)
|
||||
{
|
||||
Dictionary retval = arena_dict(arena, map_size(&namespace_ids));
|
||||
Dict retval = arena_dict(arena, map_size(&namespace_ids));
|
||||
String name;
|
||||
handle_T id;
|
||||
|
||||
@ -158,7 +158,7 @@ static Array extmark_to_array(MTPair extmark, bool id, bool add_dict, bool hl_na
|
||||
if (add_dict) {
|
||||
// TODO(bfredl): coding the size like this is a bit fragile.
|
||||
// We want ArrayOf(Dict(set_extmark)) as the return type..
|
||||
Dictionary dict = arena_dict(arena, ARRAY_SIZE(set_extmark_table));
|
||||
Dict dict = arena_dict(arena, ARRAY_SIZE(set_extmark_table));
|
||||
|
||||
PUT_C(dict, "ns_id", INTEGER_OBJ((Integer)start.ns));
|
||||
|
||||
@ -183,7 +183,7 @@ static Array extmark_to_array(MTPair extmark, bool id, bool add_dict, bool hl_na
|
||||
|
||||
decor_to_dict_legacy(&dict, mt_decor(start), hl_name, arena);
|
||||
|
||||
ADD_C(rv, DICTIONARY_OBJ(dict));
|
||||
ADD_C(rv, DICT_OBJ(dict));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -275,8 +275,8 @@ typedef struct {
|
||||
String reg;
|
||||
Boolean bang;
|
||||
Array args;
|
||||
Dictionary magic;
|
||||
Dictionary mods;
|
||||
Dict magic;
|
||||
Dict mods;
|
||||
Object nargs;
|
||||
Object addr;
|
||||
Object nextcmd;
|
||||
@ -293,7 +293,7 @@ typedef struct {
|
||||
Boolean silent;
|
||||
Boolean emsg_silent;
|
||||
Boolean unsilent;
|
||||
Dictionary filter;
|
||||
Dict filter;
|
||||
Boolean sandbox;
|
||||
Boolean noautocmd;
|
||||
Boolean browse;
|
||||
|
@ -256,13 +256,13 @@ void nvim_set_option_value(uint64_t channel_id, String name, Object value, Dict(
|
||||
|
||||
/// Gets the option information for all options.
|
||||
///
|
||||
/// The dictionary has the full option names as keys and option metadata
|
||||
/// dictionaries as detailed at |nvim_get_option_info2()|.
|
||||
/// The dict has the full option names as keys and option metadata dicts as detailed at
|
||||
/// |nvim_get_option_info2()|.
|
||||
///
|
||||
/// @see |nvim_get_commands()|
|
||||
///
|
||||
/// @return dictionary of all options
|
||||
Dictionary nvim_get_all_options_info(Arena *arena, Error *err)
|
||||
/// @return dict of all options
|
||||
Dict nvim_get_all_options_info(Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(7)
|
||||
{
|
||||
return get_all_vimoptions(arena);
|
||||
@ -270,7 +270,7 @@ Dictionary nvim_get_all_options_info(Arena *arena, Error *err)
|
||||
|
||||
/// Gets the option information for one option from arbitrary buffer or window
|
||||
///
|
||||
/// Resulting dictionary has keys:
|
||||
/// Resulting dict has keys:
|
||||
/// - name: Name of the option (like 'filetype')
|
||||
/// - shortname: Shortened name of the option (like 'ft')
|
||||
/// - type: type of option ("string", "number" or "boolean")
|
||||
@ -301,7 +301,7 @@ Dictionary nvim_get_all_options_info(Arena *arena, Error *err)
|
||||
/// Implies {scope} is "local".
|
||||
/// @param[out] err Error details, if any
|
||||
/// @return Option Information
|
||||
Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Arena *arena, Error *err)
|
||||
Dict nvim_get_option_info2(String name, Dict(option) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(11)
|
||||
{
|
||||
OptIndex opt_idx = 0;
|
||||
@ -310,7 +310,7 @@ Dictionary nvim_get_option_info2(String name, Dict(option) *opts, Arena *arena,
|
||||
void *from = NULL;
|
||||
if (!validate_option_value_args(opts, name.data, &opt_idx, &scope, &req_scope, &from, NULL,
|
||||
err)) {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
buf_T *buf = (req_scope == kOptReqBuf) ? (buf_T *)from : curbuf;
|
||||
|
@ -94,8 +94,7 @@ static Object typval_cbuf_to_obj(EncodedData *edata, const char *data, size_t le
|
||||
kvi_push(edata->stack, ARRAY_OBJ(((Array) { .capacity = 0, .size = 0 })))
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict) \
|
||||
kvi_push(edata->stack, \
|
||||
DICTIONARY_OBJ(((Dictionary) { .capacity = 0, .size = 0 })))
|
||||
kvi_push(edata->stack, DICT_OBJ(((Dict) { .capacity = 0, .size = 0 })))
|
||||
|
||||
static inline void typval_encode_list_start(EncodedData *const edata, const size_t len)
|
||||
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL
|
||||
@ -137,7 +136,7 @@ static inline void typval_encode_list_end(EncodedData *const edata)
|
||||
static inline void typval_encode_dict_start(EncodedData *const edata, const size_t len)
|
||||
FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
kvi_push(edata->stack, DICTIONARY_OBJ(arena_dict(edata->arena, len)));
|
||||
kvi_push(edata->stack, DICT_OBJ(arena_dict(edata->arena, len)));
|
||||
}
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_DICT_START(tv, dict, len) \
|
||||
@ -152,13 +151,13 @@ static inline void typval_encode_after_key(EncodedData *const edata)
|
||||
{
|
||||
Object key = kv_pop(edata->stack);
|
||||
Object *const dict = &kv_last(edata->stack);
|
||||
assert(dict->type == kObjectTypeDictionary);
|
||||
assert(dict->data.dictionary.size < dict->data.dictionary.capacity);
|
||||
assert(dict->type == kObjectTypeDict);
|
||||
assert(dict->data.dict.size < dict->data.dict.capacity);
|
||||
if (key.type == kObjectTypeString) {
|
||||
dict->data.dictionary.items[dict->data.dictionary.size].key
|
||||
dict->data.dict.items[dict->data.dict.size].key
|
||||
= key.data.string;
|
||||
} else {
|
||||
dict->data.dictionary.items[dict->data.dictionary.size].key
|
||||
dict->data.dict.items[dict->data.dict.size].key
|
||||
= STATIC_CSTR_AS_STRING("__INVALID_KEY__");
|
||||
}
|
||||
}
|
||||
@ -171,9 +170,9 @@ static inline void typval_encode_between_dict_items(EncodedData *const edata)
|
||||
{
|
||||
Object val = kv_pop(edata->stack);
|
||||
Object *const dict = &kv_last(edata->stack);
|
||||
assert(dict->type == kObjectTypeDictionary);
|
||||
assert(dict->data.dictionary.size < dict->data.dictionary.capacity);
|
||||
dict->data.dictionary.items[dict->data.dictionary.size++].value = val;
|
||||
assert(dict->type == kObjectTypeDict);
|
||||
assert(dict->data.dict.size < dict->data.dict.capacity);
|
||||
dict->data.dict.items[dict->data.dict.size++].value = val;
|
||||
}
|
||||
|
||||
#define TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS(tv, dict) \
|
||||
@ -185,7 +184,7 @@ static inline void typval_encode_dict_end(EncodedData *const edata)
|
||||
typval_encode_between_dict_items(edata);
|
||||
#ifndef NDEBUG
|
||||
const Object *const dict = &kv_last(edata->stack);
|
||||
assert(dict->data.dictionary.size == dict->data.dictionary.capacity);
|
||||
assert(dict->data.dict.size == dict->data.dict.capacity);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -325,11 +324,11 @@ void object_to_vim_take_luaref(Object *obj, typval_T *tv, bool take_luaref, Erro
|
||||
break;
|
||||
}
|
||||
|
||||
case kObjectTypeDictionary: {
|
||||
case kObjectTypeDict: {
|
||||
dict_T *const dict = tv_dict_alloc();
|
||||
|
||||
for (uint32_t i = 0; i < obj->data.dictionary.size; i++) {
|
||||
KeyValuePair *item = &obj->data.dictionary.items[i];
|
||||
for (uint32_t i = 0; i < obj->data.dict.size; i++) {
|
||||
KeyValuePair *item = &obj->data.dict.items[i];
|
||||
String key = item->key;
|
||||
dictitem_T *const di = tv_dict_item_alloc(key.data);
|
||||
object_to_vim_take_luaref(&item->value, &di->di_tv, take_luaref, err);
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# define ArrayOf(...) Array
|
||||
# define DictionaryOf(...) Dictionary
|
||||
# define DictOf(...) Dict
|
||||
# define Dict(name) KeyDict_##name
|
||||
# define DictHash(name) KeyDict_##name##_get_field
|
||||
# define DictKey(name)
|
||||
@ -88,7 +88,7 @@ typedef struct object Object;
|
||||
typedef kvec_t(Object) Array;
|
||||
|
||||
typedef struct key_value_pair KeyValuePair;
|
||||
typedef kvec_t(KeyValuePair) Dictionary;
|
||||
typedef kvec_t(KeyValuePair) Dict;
|
||||
|
||||
typedef kvec_t(String) StringArray;
|
||||
|
||||
@ -99,7 +99,7 @@ typedef enum {
|
||||
kObjectTypeFloat,
|
||||
kObjectTypeString,
|
||||
kObjectTypeArray,
|
||||
kObjectTypeDictionary,
|
||||
kObjectTypeDict,
|
||||
kObjectTypeLuaRef,
|
||||
// EXT types, cannot be split or reordered, see #EXT_OBJECT_TYPE_SHIFT
|
||||
kObjectTypeBuffer,
|
||||
@ -127,7 +127,7 @@ struct object {
|
||||
Float floating;
|
||||
String string;
|
||||
Array array;
|
||||
Dictionary dictionary;
|
||||
Dict dict;
|
||||
LuaRef luaref;
|
||||
} data;
|
||||
};
|
||||
|
@ -198,7 +198,7 @@ dictitem_T *dict_check_writable(dict_T *dict, String key, bool del, Error *err)
|
||||
api_set_error(err, kErrorTypeException, "Key is fixed: %s", key.data);
|
||||
}
|
||||
} else if (dict->dv_lock) {
|
||||
api_set_error(err, kErrorTypeException, "Dictionary is locked");
|
||||
api_set_error(err, kErrorTypeException, "Dict is locked");
|
||||
} else if (key.size == 0) {
|
||||
api_set_error(err, kErrorTypeValidation, "Key name is empty");
|
||||
} else if (key.size > INT_MAX) {
|
||||
@ -551,9 +551,9 @@ Array arena_array(Arena *arena, size_t max_size)
|
||||
return arr;
|
||||
}
|
||||
|
||||
Dictionary arena_dict(Arena *arena, size_t max_size)
|
||||
Dict arena_dict(Arena *arena, size_t max_size)
|
||||
{
|
||||
Dictionary dict = ARRAY_DICT_INIT;
|
||||
Dict dict = ARRAY_DICT_INIT;
|
||||
kv_fixsize_arena(arena, dict, max_size);
|
||||
return dict;
|
||||
}
|
||||
@ -596,8 +596,8 @@ void api_free_object(Object value)
|
||||
api_free_array(value.data.array);
|
||||
break;
|
||||
|
||||
case kObjectTypeDictionary:
|
||||
api_free_dictionary(value.data.dictionary);
|
||||
case kObjectTypeDict:
|
||||
api_free_dict(value.data.dict);
|
||||
break;
|
||||
|
||||
case kObjectTypeLuaRef:
|
||||
@ -615,7 +615,7 @@ void api_free_array(Array value)
|
||||
xfree(value.items);
|
||||
}
|
||||
|
||||
void api_free_dictionary(Dictionary value)
|
||||
void api_free_dict(Dict value)
|
||||
{
|
||||
for (size_t i = 0; i < value.size; i++) {
|
||||
api_free_string(value.items[i].key);
|
||||
@ -648,7 +648,7 @@ Object api_metadata(void)
|
||||
Arena arena = ARENA_EMPTY;
|
||||
Error err = ERROR_INIT;
|
||||
metadata = unpack((char *)packed_api_metadata, sizeof(packed_api_metadata), &arena, &err);
|
||||
if (ERROR_SET(&err) || metadata.type != kObjectTypeDictionary) {
|
||||
if (ERROR_SET(&err) || metadata.type != kObjectTypeDict) {
|
||||
abort();
|
||||
}
|
||||
mem_for_metadata = arena_finish(&arena);
|
||||
@ -684,9 +684,9 @@ Array copy_array(Array array, Arena *arena)
|
||||
return rv;
|
||||
}
|
||||
|
||||
Dictionary copy_dictionary(Dictionary dict, Arena *arena)
|
||||
Dict copy_dict(Dict dict, Arena *arena)
|
||||
{
|
||||
Dictionary rv = arena_dict(arena, dict.size);
|
||||
Dict rv = arena_dict(arena, dict.size);
|
||||
for (size_t i = 0; i < dict.size; i++) {
|
||||
KeyValuePair item = dict.items[i];
|
||||
PUT_C(rv, copy_string(item.key, arena).data, copy_object(item.value, arena));
|
||||
@ -713,8 +713,8 @@ Object copy_object(Object obj, Arena *arena)
|
||||
case kObjectTypeArray:
|
||||
return ARRAY_OBJ(copy_array(obj.data.array, arena));
|
||||
|
||||
case kObjectTypeDictionary:
|
||||
return DICTIONARY_OBJ(copy_dictionary(obj.data.dictionary, arena));
|
||||
case kObjectTypeDict:
|
||||
return DICT_OBJ(copy_dict(obj.data.dict, arena));
|
||||
|
||||
case kObjectTypeLuaRef:
|
||||
return LUAREF_OBJ(api_new_luaref(obj.data.luaref));
|
||||
@ -791,7 +791,7 @@ char *api_typename(ObjectType t)
|
||||
return "String";
|
||||
case kObjectTypeArray:
|
||||
return "Array";
|
||||
case kObjectTypeDictionary:
|
||||
case kObjectTypeDict:
|
||||
return "Dict";
|
||||
case kObjectTypeLuaRef:
|
||||
return "Function";
|
||||
@ -844,7 +844,7 @@ free_exit:
|
||||
}
|
||||
|
||||
// see also nlua_pop_keydict for the lua specific implementation
|
||||
bool api_dict_to_keydict(void *retval, FieldHashfn hashy, Dictionary dict, Error *err)
|
||||
bool api_dict_to_keydict(void *retval, FieldHashfn hashy, Dict dict, Error *err)
|
||||
{
|
||||
for (size_t i = 0; i < dict.size; i++) {
|
||||
String k = dict.items[i].key;
|
||||
@ -908,13 +908,13 @@ bool api_dict_to_keydict(void *retval, FieldHashfn hashy, Dictionary dict, Error
|
||||
return false;
|
||||
});
|
||||
*(Array *)mem = value->data.array;
|
||||
} else if (field->type == kObjectTypeDictionary) {
|
||||
Dictionary *val = (Dictionary *)mem;
|
||||
} else if (field->type == kObjectTypeDict) {
|
||||
Dict *val = (Dict *)mem;
|
||||
// allow empty array as empty dict for lua (directly or via lua-client RPC)
|
||||
if (value->type == kObjectTypeArray && value->data.array.size == 0) {
|
||||
*val = (Dictionary)ARRAY_DICT_INIT;
|
||||
} else if (value->type == kObjectTypeDictionary) {
|
||||
*val = value->data.dictionary;
|
||||
*val = (Dict)ARRAY_DICT_INIT;
|
||||
} else if (value->type == kObjectTypeDict) {
|
||||
*val = value->data.dict;
|
||||
} else {
|
||||
api_err_exp(err, field->str, api_typename((ObjectType)field->type),
|
||||
api_typename(value->type));
|
||||
@ -941,9 +941,9 @@ bool api_dict_to_keydict(void *retval, FieldHashfn hashy, Dictionary dict, Error
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary api_keydict_to_dict(void *value, KeySetLink *table, size_t max_size, Arena *arena)
|
||||
Dict api_keydict_to_dict(void *value, KeySetLink *table, size_t max_size, Arena *arena)
|
||||
{
|
||||
Dictionary rv = arena_dict(arena, max_size);
|
||||
Dict rv = arena_dict(arena, max_size);
|
||||
for (size_t i = 0; table[i].str; i++) {
|
||||
KeySetLink *field = &table[i];
|
||||
bool is_set = true;
|
||||
@ -971,8 +971,8 @@ Dictionary api_keydict_to_dict(void *value, KeySetLink *table, size_t max_size,
|
||||
val = STRING_OBJ(*(String *)mem);
|
||||
} else if (field->type == kObjectTypeArray) {
|
||||
val = ARRAY_OBJ(*(Array *)mem);
|
||||
} else if (field->type == kObjectTypeDictionary) {
|
||||
val = DICTIONARY_OBJ(*(Dictionary *)mem);
|
||||
} else if (field->type == kObjectTypeDict) {
|
||||
val = DICT_OBJ(*(Dict *)mem);
|
||||
} else if (field->type == kObjectTypeBuffer || field->type == kObjectTypeWindow
|
||||
|| field->type == kObjectTypeTabpage) {
|
||||
val.data.integer = *(handle_T *)mem;
|
||||
@ -1002,8 +1002,8 @@ void api_luarefs_free_object(Object value)
|
||||
api_luarefs_free_array(value.data.array);
|
||||
break;
|
||||
|
||||
case kObjectTypeDictionary:
|
||||
api_luarefs_free_dict(value.data.dictionary);
|
||||
case kObjectTypeDict:
|
||||
api_luarefs_free_dict(value.data.dict);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1019,8 +1019,8 @@ void api_luarefs_free_keydict(void *dict, KeySetLink *table)
|
||||
api_luarefs_free_object(*(Object *)mem);
|
||||
} else if (table[i].type == kObjectTypeLuaRef) {
|
||||
api_free_luaref(*(LuaRef *)mem);
|
||||
} else if (table[i].type == kObjectTypeDictionary) {
|
||||
api_luarefs_free_dict(*(Dictionary *)mem);
|
||||
} else if (table[i].type == kObjectTypeDict) {
|
||||
api_luarefs_free_dict(*(Dict *)mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1032,7 +1032,7 @@ void api_luarefs_free_array(Array value)
|
||||
}
|
||||
}
|
||||
|
||||
void api_luarefs_free_dict(Dictionary value)
|
||||
void api_luarefs_free_dict(Dict value)
|
||||
{
|
||||
for (size_t i = 0; i < value.size; i++) {
|
||||
api_luarefs_free_object(value.items[i].value);
|
||||
|
@ -53,9 +53,9 @@
|
||||
.type = kObjectTypeArray, \
|
||||
.data.array = a })
|
||||
|
||||
#define DICTIONARY_OBJ(d) ((Object) { \
|
||||
.type = kObjectTypeDictionary, \
|
||||
.data.dictionary = d })
|
||||
#define DICT_OBJ(d) ((Object) { \
|
||||
.type = kObjectTypeDict, \
|
||||
.data.dict = d })
|
||||
|
||||
#define LUAREF_OBJ(r) ((Object) { \
|
||||
.type = kObjectTypeLuaRef, \
|
||||
@ -90,7 +90,7 @@
|
||||
name.items = name##__items; \
|
||||
|
||||
#define MAXSIZE_TEMP_DICT(name, maxsize) \
|
||||
Dictionary name = ARRAY_DICT_INIT; \
|
||||
Dict name = ARRAY_DICT_INIT; \
|
||||
KeyValuePair name##__items[maxsize]; \
|
||||
name.capacity = maxsize; \
|
||||
name.items = name##__items; \
|
||||
@ -121,7 +121,7 @@ typedef kvec_withinit_t(Object, 16) ArrayBuilder;
|
||||
#define api_init_tabpage
|
||||
#define api_init_object = NIL
|
||||
#define api_init_array = ARRAY_DICT_INIT
|
||||
#define api_init_dictionary = ARRAY_DICT_INIT
|
||||
#define api_init_dict = ARRAY_DICT_INIT
|
||||
|
||||
#define KEYDICT_INIT { 0 }
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#define VALIDATE_T(name, expected_t, actual_t, code) \
|
||||
do { \
|
||||
STATIC_ASSERT(expected_t != kObjectTypeDictionary, "use VALIDATE_T_DICT"); \
|
||||
STATIC_ASSERT(expected_t != kObjectTypeDict, "use VALIDATE_T_DICT"); \
|
||||
if (expected_t != actual_t) { \
|
||||
api_err_exp(err, name, api_typename(expected_t), api_typename(actual_t)); \
|
||||
code; \
|
||||
@ -52,7 +52,7 @@
|
||||
/// Checks that `obj_` has type `expected_t`.
|
||||
#define VALIDATE_T2(obj_, expected_t, code) \
|
||||
do { \
|
||||
STATIC_ASSERT(expected_t != kObjectTypeDictionary, "use VALIDATE_T_DICT"); \
|
||||
STATIC_ASSERT(expected_t != kObjectTypeDict, "use VALIDATE_T_DICT"); \
|
||||
if ((obj_).type != expected_t) { \
|
||||
api_err_exp(err, STR(obj_), api_typename(expected_t), api_typename((obj_).type)); \
|
||||
code; \
|
||||
@ -62,11 +62,11 @@
|
||||
/// Checks that `obj_` has Dict type. Also allows empty Array in a Lua context.
|
||||
#define VALIDATE_T_DICT(name, obj_, code) \
|
||||
do { \
|
||||
if ((obj_).type != kObjectTypeDictionary \
|
||||
if ((obj_).type != kObjectTypeDict \
|
||||
&& !(channel_id == LUA_INTERNAL_CALL \
|
||||
&& (obj_).type == kObjectTypeArray \
|
||||
&& (obj_).data.array.size == 0)) { \
|
||||
api_err_exp(err, name, api_typename(kObjectTypeDictionary), api_typename((obj_).type)); \
|
||||
api_err_exp(err, name, api_typename(kObjectTypeDict), api_typename((obj_).type)); \
|
||||
code; \
|
||||
} \
|
||||
} while (0)
|
||||
|
@ -128,8 +128,7 @@ void remote_ui_wait_for_attach(bool only_stdio)
|
||||
/// @param height Requested screen rows
|
||||
/// @param options |ui-option| map
|
||||
/// @param[out] err Error details, if any
|
||||
void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictionary options,
|
||||
Error *err)
|
||||
void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dict options, Error *err)
|
||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
if (map_has(uint64_t, &connected_uis, channel_id)) {
|
||||
@ -687,8 +686,8 @@ void remote_ui_hl_attr_define(RemoteUI *ui, Integer id, HlAttrs rgb_attrs, HlAtt
|
||||
PUT_C(rgb, "url", CSTR_AS_OBJ(url));
|
||||
}
|
||||
|
||||
ADD_C(args, DICTIONARY_OBJ(rgb));
|
||||
ADD_C(args, DICTIONARY_OBJ(cterm));
|
||||
ADD_C(args, DICT_OBJ(rgb));
|
||||
ADD_C(args, DICT_OBJ(cterm));
|
||||
|
||||
if (ui->ui_ext[kUIHlState]) {
|
||||
ADD_C(args, ARRAY_OBJ(info));
|
||||
@ -709,7 +708,7 @@ void remote_ui_highlight_set(RemoteUI *ui, int id)
|
||||
MAXSIZE_TEMP_DICT(dict, HLATTRS_DICT_SIZE);
|
||||
hlattrs2dict(&dict, NULL, syn_attr2entry(id), ui->rgb, false);
|
||||
MAXSIZE_TEMP_ARRAY(args, 1);
|
||||
ADD_C(args, DICTIONARY_OBJ(dict));
|
||||
ADD_C(args, DICT_OBJ(dict));
|
||||
push_call(ui, "highlight_set", args);
|
||||
}
|
||||
|
||||
@ -920,11 +919,11 @@ static Array translate_contents(RemoteUI *ui, Array contents, Arena *arena)
|
||||
Array new_item = arena_array(arena, 2);
|
||||
int attr = (int)item.items[0].data.integer;
|
||||
if (attr) {
|
||||
Dictionary rgb_attrs = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
Dict rgb_attrs = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
hlattrs2dict(&rgb_attrs, NULL, syn_attr2entry(attr), ui->rgb, false);
|
||||
ADD_C(new_item, DICTIONARY_OBJ(rgb_attrs));
|
||||
ADD_C(new_item, DICT_OBJ(rgb_attrs));
|
||||
} else {
|
||||
ADD_C(new_item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT));
|
||||
ADD_C(new_item, DICT_OBJ((Dict)ARRAY_DICT_INIT));
|
||||
}
|
||||
ADD_C(new_item, item.items[1]);
|
||||
ADD_C(new_contents, ARRAY_OBJ(new_item));
|
||||
|
@ -117,7 +117,7 @@ Integer nvim_get_hl_id_by_name(String name)
|
||||
/// @param[out] err Error details, if any.
|
||||
/// @return Highlight groups as a map from group name to a highlight definition map as in |nvim_set_hl()|,
|
||||
/// or only a single highlight definition map if requested by name or id.
|
||||
Dictionary nvim_get_hl(Integer ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
|
||||
Dict nvim_get_hl(Integer ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(11)
|
||||
{
|
||||
return ns_get_hl_defs((NS)ns_id, opts, arena, err);
|
||||
@ -526,13 +526,13 @@ Object nvim_exec_lua(String code, Array args, Arena *arena, Error *err)
|
||||
/// @param log_level The log level
|
||||
/// @param opts Reserved for future use.
|
||||
/// @param[out] err Error details, if any
|
||||
Object nvim_notify(String msg, Integer log_level, Dictionary opts, Arena *arena, Error *err)
|
||||
Object nvim_notify(String msg, Integer log_level, Dict opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(7)
|
||||
{
|
||||
MAXSIZE_TEMP_ARRAY(args, 3);
|
||||
ADD_C(args, STRING_OBJ(msg));
|
||||
ADD_C(args, INTEGER_OBJ(log_level));
|
||||
ADD_C(args, DICTIONARY_OBJ(opts));
|
||||
ADD_C(args, DICT_OBJ(opts));
|
||||
|
||||
return NLUA_EXEC_STATIC("return vim.notify(...)", args, kRetObject, arena, err);
|
||||
}
|
||||
@ -1350,10 +1350,10 @@ Integer nvim_get_color_by_name(String name)
|
||||
/// (e.g. 65535).
|
||||
///
|
||||
/// @return Map of color names and RGB values.
|
||||
Dictionary nvim_get_color_map(Arena *arena)
|
||||
Dict nvim_get_color_map(Arena *arena)
|
||||
FUNC_API_SINCE(1)
|
||||
{
|
||||
Dictionary colors = arena_dict(arena, ARRAY_SIZE(color_name_table));
|
||||
Dict colors = arena_dict(arena, ARRAY_SIZE(color_name_table));
|
||||
|
||||
for (int i = 0; color_name_table[i].name != NULL; i++) {
|
||||
PUT_C(colors, color_name_table[i].name, INTEGER_OBJ(color_name_table[i].color));
|
||||
@ -1369,7 +1369,7 @@ Dictionary nvim_get_color_map(Arena *arena)
|
||||
/// @param[out] err Error details, if any
|
||||
///
|
||||
/// @return map of global |context|.
|
||||
Dictionary nvim_get_context(Dict(context) *opts, Arena *arena, Error *err)
|
||||
Dict nvim_get_context(Dict(context) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(6)
|
||||
{
|
||||
Array types = ARRAY_DICT_INIT;
|
||||
@ -1396,7 +1396,7 @@ Dictionary nvim_get_context(Dict(context) *opts, Arena *arena, Error *err)
|
||||
int_types |= kCtxFuncs;
|
||||
} else {
|
||||
VALIDATE_S(false, "type", s, {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1405,7 +1405,7 @@ Dictionary nvim_get_context(Dict(context) *opts, Arena *arena, Error *err)
|
||||
|
||||
Context ctx = CONTEXT_INIT;
|
||||
ctx_save(&ctx, int_types);
|
||||
Dictionary dict = ctx_to_dict(&ctx, arena);
|
||||
Dict dict = ctx_to_dict(&ctx, arena);
|
||||
ctx_free(&ctx);
|
||||
return dict;
|
||||
}
|
||||
@ -1413,7 +1413,7 @@ Dictionary nvim_get_context(Dict(context) *opts, Arena *arena, Error *err)
|
||||
/// Sets the current editor state from the given |context| map.
|
||||
///
|
||||
/// @param dict |Context| map.
|
||||
Object nvim_load_context(Dictionary dict, Error *err)
|
||||
Object nvim_load_context(Dict dict, Error *err)
|
||||
FUNC_API_SINCE(6)
|
||||
{
|
||||
Context ctx = CONTEXT_INIT;
|
||||
@ -1435,11 +1435,11 @@ Object nvim_load_context(Dictionary dict, Error *err)
|
||||
/// Gets the current mode. |mode()|
|
||||
/// "blocking" is true if Nvim is waiting for input.
|
||||
///
|
||||
/// @returns Dictionary { "mode": String, "blocking": Boolean }
|
||||
Dictionary nvim_get_mode(Arena *arena)
|
||||
/// @returns Dict { "mode": String, "blocking": Boolean }
|
||||
Dict nvim_get_mode(Arena *arena)
|
||||
FUNC_API_SINCE(2) FUNC_API_FAST
|
||||
{
|
||||
Dictionary rv = arena_dict(arena, 2);
|
||||
Dict rv = arena_dict(arena, 2);
|
||||
char *modestr = arena_alloc(arena, MODE_MAX_LENGTH, false);
|
||||
get_mode(modestr);
|
||||
bool blocked = input_blocking();
|
||||
@ -1455,7 +1455,7 @@ Dictionary nvim_get_mode(Arena *arena)
|
||||
/// @param mode Mode short-name ("n", "i", "v", ...)
|
||||
/// @returns Array of |maparg()|-like dictionaries describing mappings.
|
||||
/// The "buffer" key is always zero.
|
||||
ArrayOf(Dictionary) nvim_get_keymap(String mode, Arena *arena)
|
||||
ArrayOf(Dict) nvim_get_keymap(String mode, Arena *arena)
|
||||
FUNC_API_SINCE(3)
|
||||
{
|
||||
return keymap_array(mode, NULL, arena);
|
||||
@ -1514,7 +1514,7 @@ void nvim_del_keymap(uint64_t channel_id, String mode, String lhs, Error *err)
|
||||
}
|
||||
|
||||
/// Returns a 2-tuple (Array), where item 0 is the current channel id and item
|
||||
/// 1 is the |api-metadata| map (Dictionary).
|
||||
/// 1 is the |api-metadata| map (Dict).
|
||||
///
|
||||
/// @returns 2-tuple `[{channel-id}, {api-metadata}]`
|
||||
Array nvim_get_api_info(uint64_t channel_id, Arena *arena)
|
||||
@ -1543,7 +1543,7 @@ Array nvim_get_api_info(uint64_t channel_id, Arena *arena)
|
||||
///
|
||||
/// @param channel_id
|
||||
/// @param name Short name for the connected client
|
||||
/// @param version Dictionary describing the version, with these
|
||||
/// @param version Dict describing the version, with these
|
||||
/// (optional) keys:
|
||||
/// - "major" major version (defaults to 0 if not set, for no release yet)
|
||||
/// - "minor" minor version
|
||||
@ -1582,8 +1582,8 @@ Array nvim_get_api_info(uint64_t channel_id, Arena *arena)
|
||||
/// .png or .svg format is preferred.
|
||||
///
|
||||
/// @param[out] err Error details, if any
|
||||
void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version, String type,
|
||||
Dictionary methods, Dictionary attributes, Arena *arena, Error *err)
|
||||
void nvim_set_client_info(uint64_t channel_id, String name, Dict version, String type, Dict methods,
|
||||
Dict attributes, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(4) FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
MAXSIZE_TEMP_DICT(info, 5);
|
||||
@ -1597,7 +1597,7 @@ void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version,
|
||||
}
|
||||
}
|
||||
if (!has_major) {
|
||||
Dictionary v = arena_dict(arena, version.size + 1);
|
||||
Dict v = arena_dict(arena, version.size + 1);
|
||||
if (version.size) {
|
||||
memcpy(v.items, version.items, version.size * sizeof(v.items[0]));
|
||||
v.size = version.size;
|
||||
@ -1605,13 +1605,13 @@ void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version,
|
||||
PUT_C(v, "major", INTEGER_OBJ(0));
|
||||
version = v;
|
||||
}
|
||||
PUT_C(info, "version", DICTIONARY_OBJ(version));
|
||||
PUT_C(info, "version", DICT_OBJ(version));
|
||||
|
||||
PUT_C(info, "type", STRING_OBJ(type));
|
||||
PUT_C(info, "methods", DICTIONARY_OBJ(methods));
|
||||
PUT_C(info, "attributes", DICTIONARY_OBJ(attributes));
|
||||
PUT_C(info, "methods", DICT_OBJ(methods));
|
||||
PUT_C(info, "attributes", DICT_OBJ(attributes));
|
||||
|
||||
rpc_set_client_info(channel_id, copy_dictionary(info, NULL));
|
||||
rpc_set_client_info(channel_id, copy_dict(info, NULL));
|
||||
}
|
||||
|
||||
/// Gets information about a channel.
|
||||
@ -1636,11 +1636,11 @@ void nvim_set_client_info(uint64_t channel_id, String name, Dictionary version,
|
||||
/// - "client" (optional) Info about the peer (client on the other end of the RPC channel),
|
||||
/// which it provided via |nvim_set_client_info()|.
|
||||
///
|
||||
Dictionary nvim_get_chan_info(uint64_t channel_id, Integer chan, Arena *arena, Error *err)
|
||||
Dict nvim_get_chan_info(uint64_t channel_id, Integer chan, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(4)
|
||||
{
|
||||
if (chan < 0) {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
if (chan == 0 && !is_internal_call(channel_id)) {
|
||||
@ -1737,17 +1737,17 @@ Array nvim__id_array(Array arr, Arena *arena)
|
||||
return copy_array(arr, arena);
|
||||
}
|
||||
|
||||
/// Returns dictionary given as argument.
|
||||
/// Returns dict given as argument.
|
||||
///
|
||||
/// This API function is used for testing. One should not rely on its presence
|
||||
/// in plugins.
|
||||
///
|
||||
/// @param[in] dct Dictionary to return.
|
||||
/// @param[in] dct Dict to return.
|
||||
///
|
||||
/// @return its argument.
|
||||
Dictionary nvim__id_dictionary(Dictionary dct, Arena *arena)
|
||||
Dict nvim__id_dict(Dict dct, Arena *arena)
|
||||
{
|
||||
return copy_dictionary(dct, arena);
|
||||
return copy_dict(dct, arena);
|
||||
}
|
||||
|
||||
/// Returns floating-point value given as argument.
|
||||
@ -1766,9 +1766,9 @@ Float nvim__id_float(Float flt)
|
||||
/// Gets internal stats.
|
||||
///
|
||||
/// @return Map of various internal stats.
|
||||
Dictionary nvim__stats(Arena *arena)
|
||||
Dict nvim__stats(Arena *arena)
|
||||
{
|
||||
Dictionary rv = arena_dict(arena, 6);
|
||||
Dict rv = arena_dict(arena, 6);
|
||||
PUT_C(rv, "fsync", INTEGER_OBJ(g_stats.fsync));
|
||||
PUT_C(rv, "log_skip", INTEGER_OBJ(g_stats.log_skip));
|
||||
PUT_C(rv, "lua_refcount", INTEGER_OBJ(nlua_get_global_ref_count()));
|
||||
@ -1845,8 +1845,8 @@ Object nvim_get_proc(Integer pid, Arena *arena, Error *err)
|
||||
});
|
||||
|
||||
#ifdef MSWIN
|
||||
rvobj = DICTIONARY_OBJ(os_proc_info((int)pid, arena));
|
||||
if (rvobj.data.dictionary.size == 0) { // Process not found.
|
||||
rvobj = DICT_OBJ(os_proc_info((int)pid, arena));
|
||||
if (rvobj.data.dict.size == 0) { // Process not found.
|
||||
return NIL;
|
||||
}
|
||||
#else
|
||||
@ -1856,7 +1856,7 @@ Object nvim_get_proc(Integer pid, Arena *arena, Error *err)
|
||||
Object o = NLUA_EXEC_STATIC("return vim._os_proc_info(...)", a, kRetObject, arena, err);
|
||||
if (o.type == kObjectTypeArray && o.data.array.size == 0) {
|
||||
return NIL; // Process not found.
|
||||
} else if (o.type == kObjectTypeDictionary) {
|
||||
} else if (o.type == kObjectTypeDict) {
|
||||
rvobj = o;
|
||||
} else if (!ERROR_SET(err)) {
|
||||
api_set_error(err, kErrorTypeException,
|
||||
@ -1920,7 +1920,7 @@ Array nvim__inspect_cell(Integer grid, Integer row, Integer col, Arena *arena, E
|
||||
schar_get(sc_buf, g->chars[off]);
|
||||
ADD_C(ret, CSTR_AS_OBJ(sc_buf));
|
||||
int attr = g->attrs[off];
|
||||
ADD_C(ret, DICTIONARY_OBJ(hl_get_attr_by_id(attr, true, arena, err)));
|
||||
ADD_C(ret, DICT_OBJ(hl_get_attr_by_id(attr, true, arena, err)));
|
||||
// will not work first time
|
||||
if (!highlight_use_hlstate()) {
|
||||
ADD_C(ret, ARRAY_OBJ(hl_inspect(attr, arena)));
|
||||
@ -2063,18 +2063,18 @@ Array nvim_get_mark(String name, Dict(empty) *opts, Arena *arena, Error *err)
|
||||
/// - use_statuscol_lnum: (number) Evaluate statuscolumn for this line number instead of statusline.
|
||||
///
|
||||
/// @param[out] err Error details, if any.
|
||||
/// @return Dictionary containing statusline information, with these keys:
|
||||
/// @return Dict containing statusline information, with these keys:
|
||||
/// - str: (string) Characters that will be displayed on the statusline.
|
||||
/// - width: (number) Display width of the statusline.
|
||||
/// - highlights: Array containing highlight information of the statusline. Only included when
|
||||
/// the "highlights" key in {opts} is true. Each element of the array is a
|
||||
/// |Dictionary| with these keys:
|
||||
/// |Dict| with these keys:
|
||||
/// - start: (number) Byte index (0-based) of first character that uses the highlight.
|
||||
/// - group: (string) Name of highlight group.
|
||||
Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *arena, Error *err)
|
||||
Dict nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(8) FUNC_API_FAST
|
||||
{
|
||||
Dictionary result = ARRAY_DICT_INIT;
|
||||
Dict result = ARRAY_DICT_INIT;
|
||||
|
||||
int maxwidth;
|
||||
schar_T fillchar = 0;
|
||||
@ -2200,18 +2200,18 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *
|
||||
// If first character doesn't have a defined highlight,
|
||||
// add the default highlight at the beginning of the highlight list
|
||||
if (hltab->start == NULL || (hltab->start - buf) != 0) {
|
||||
Dictionary hl_info = arena_dict(arena, 2);
|
||||
Dict hl_info = arena_dict(arena, 2);
|
||||
const char *grpname = get_default_stl_hl(opts->use_tabline ? NULL : wp,
|
||||
opts->use_winbar, stc_hl_id);
|
||||
|
||||
PUT_C(hl_info, "start", INTEGER_OBJ(0));
|
||||
PUT_C(hl_info, "group", CSTR_AS_OBJ(grpname));
|
||||
|
||||
ADD_C(hl_values, DICTIONARY_OBJ(hl_info));
|
||||
ADD_C(hl_values, DICT_OBJ(hl_info));
|
||||
}
|
||||
|
||||
for (stl_hlrec_t *sp = hltab; sp->start != NULL; sp++) {
|
||||
Dictionary hl_info = arena_dict(arena, 2);
|
||||
Dict hl_info = arena_dict(arena, 2);
|
||||
|
||||
PUT_C(hl_info, "start", INTEGER_OBJ(sp->start - buf));
|
||||
|
||||
@ -2225,7 +2225,7 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *
|
||||
grpname = arena_memdupz(arena, user_group, strlen(user_group));
|
||||
}
|
||||
PUT_C(hl_info, "group", CSTR_AS_OBJ(grpname));
|
||||
ADD_C(hl_values, DICTIONARY_OBJ(hl_info));
|
||||
ADD_C(hl_values, DICT_OBJ(hl_info));
|
||||
}
|
||||
PUT_C(result, "highlights", ARRAY_OBJ(hl_values));
|
||||
}
|
||||
@ -2251,12 +2251,12 @@ void nvim_error_event(uint64_t channel_id, Integer lvl, String data)
|
||||
/// @param index Completion candidate index
|
||||
/// @param opts Optional parameters.
|
||||
/// - info: (string) info text.
|
||||
/// @return Dictionary containing these keys:
|
||||
/// @return Dict containing these keys:
|
||||
/// - winid: (number) floating window id
|
||||
/// - bufnr: (number) buffer id in floating window
|
||||
Dictionary nvim__complete_set(Integer index, Dict(complete_set) *opts, Arena *arena)
|
||||
Dict nvim__complete_set(Integer index, Dict(complete_set) *opts, Arena *arena)
|
||||
{
|
||||
Dictionary rv = arena_dict(arena, 2);
|
||||
Dict rv = arena_dict(arena, 2);
|
||||
if (HAS_KEY(opts, complete_set, info)) {
|
||||
win_T *wp = pum_set_info((int)index, opts->info.data);
|
||||
if (wp) {
|
||||
|
@ -48,12 +48,12 @@
|
||||
/// - output: (boolean, default false) Whether to capture and return
|
||||
/// all (non-error, non-shell |:!|) output.
|
||||
/// @param[out] err Error details (Vim error), if any
|
||||
/// @return Dictionary containing information about execution, with these keys:
|
||||
/// @return Dict containing information about execution, with these keys:
|
||||
/// - output: (string|nil) Output if `opts.output` is true.
|
||||
Dictionary nvim_exec2(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *err)
|
||||
Dict nvim_exec2(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *err)
|
||||
FUNC_API_SINCE(11) FUNC_API_RET_ALLOC
|
||||
{
|
||||
Dictionary result = ARRAY_DICT_INIT;
|
||||
Dict result = ARRAY_DICT_INIT;
|
||||
|
||||
String output = exec_impl(channel_id, src, opts, err);
|
||||
if (ERROR_SET(err)) {
|
||||
@ -140,8 +140,7 @@ void nvim_command(String command, Error *err)
|
||||
try_end(err);
|
||||
}
|
||||
|
||||
/// Evaluates a Vimscript |expression|.
|
||||
/// Dictionaries and Lists are recursively expanded.
|
||||
/// Evaluates a Vimscript |expression|. Dicts and Lists are recursively expanded.
|
||||
///
|
||||
/// On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
///
|
||||
@ -270,7 +269,7 @@ Object nvim_call_function(String fn, Array args, Arena *arena, Error *err)
|
||||
///
|
||||
/// On execution error: fails with Vimscript error, updates v:errmsg.
|
||||
///
|
||||
/// @param dict Dictionary, or String evaluating to a Vimscript |self| dict
|
||||
/// @param dict Dict, or String evaluating to a Vimscript |self| dict
|
||||
/// @param fn Name of the function defined on the Vimscript dict
|
||||
/// @param args Function arguments packed in an Array
|
||||
/// @param[out] err Error details, if any
|
||||
@ -297,12 +296,11 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Arena *arena,
|
||||
// refcount of a dict. Not necessary for a RPC dict.
|
||||
mustfree = true;
|
||||
break;
|
||||
case kObjectTypeDictionary:
|
||||
case kObjectTypeDict:
|
||||
object_to_vim(dict, &rettv, err);
|
||||
break;
|
||||
default:
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
"dict argument type must be String or Dictionary");
|
||||
api_set_error(err, kErrorTypeValidation, "dict argument type must be String or Dict");
|
||||
return rv;
|
||||
}
|
||||
dict_T *self_dict = rettv.vval.v_dict;
|
||||
@ -311,7 +309,7 @@ Object nvim_call_dict_function(Object dict, String fn, Array args, Arena *arena,
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (fn.data && fn.size > 0 && dict.type != kObjectTypeDictionary) {
|
||||
if (fn.data && fn.size > 0 && dict.type != kObjectTypeDict) {
|
||||
dictitem_T *const di = tv_dict_find(self_dict, fn.data, (ptrdiff_t)fn.size);
|
||||
if (di == NULL) {
|
||||
api_set_error(err, kErrorTypeValidation, "Not found: %s", fn.data);
|
||||
@ -377,8 +375,8 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
|
||||
/// one should highlight region [start_col, end_col)).
|
||||
///
|
||||
/// @return
|
||||
/// - AST: top-level dictionary with these keys:
|
||||
/// - "error": Dictionary with error, present only if parser saw some
|
||||
/// - AST: top-level dict with these keys:
|
||||
/// - "error": Dict with error, present only if parser saw some
|
||||
/// error. Contains the following keys:
|
||||
/// - "message": String, error message in printf format, translated.
|
||||
/// Must contain exactly one "%.*s".
|
||||
@ -387,7 +385,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
|
||||
/// that should be equal to the length of expr string.
|
||||
/// ("Successfully parsed" here means "participated in AST
|
||||
/// creation", not "till the first error".)
|
||||
/// - "ast": AST, either nil or a dictionary with these keys:
|
||||
/// - "ast": AST, either nil or a dict with these keys:
|
||||
/// - "type": node type, one of the value names from ExprASTNodeType
|
||||
/// stringified without "kExprNode" prefix.
|
||||
/// - "start": a pair `[line, column]` describing where node is "started"
|
||||
@ -427,8 +425,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack;
|
||||
/// - "svalue": String, value for "SingleQuotedString" and
|
||||
/// "DoubleQuotedString" nodes.
|
||||
/// @param[out] err Error details, if any
|
||||
Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, Arena *arena,
|
||||
Error *err)
|
||||
Dict nvim_parse_expression(String expr, String flags, Boolean highlight, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(4) FUNC_API_FAST
|
||||
{
|
||||
int pflags = 0;
|
||||
@ -443,11 +440,11 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, A
|
||||
case NUL:
|
||||
api_set_error(err, kErrorTypeValidation, "Invalid flag: '\\0' (%u)",
|
||||
(unsigned)flags.data[i]);
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
default:
|
||||
api_set_error(err, kErrorTypeValidation, "Invalid flag: '%c' (%u)",
|
||||
flags.data[i], (unsigned)flags.data[i]);
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
}
|
||||
ParserLine parser_lines[] = {
|
||||
@ -471,15 +468,15 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, A
|
||||
+ (size_t)highlight // "highlight"
|
||||
+ 0);
|
||||
|
||||
Dictionary ret = arena_dict(arena, ret_size);
|
||||
Dict ret = arena_dict(arena, ret_size);
|
||||
PUT_C(ret, "len", INTEGER_OBJ((Integer)(pstate.pos.line == 1
|
||||
? parser_lines[0].size
|
||||
: pstate.pos.col)));
|
||||
if (east.err.msg != NULL) {
|
||||
Dictionary err_dict = arena_dict(arena, 2);
|
||||
Dict err_dict = arena_dict(arena, 2);
|
||||
PUT_C(err_dict, "message", CSTR_TO_ARENA_OBJ(arena, east.err.msg));
|
||||
PUT_C(err_dict, "arg", CBUF_TO_ARENA_OBJ(arena, east.err.arg, (size_t)east.err.arg_len));
|
||||
PUT_C(ret, "error", DICTIONARY_OBJ(err_dict));
|
||||
PUT_C(ret, "error", DICT_OBJ(err_dict));
|
||||
}
|
||||
if (highlight) {
|
||||
Array hl = arena_array(arena, kv_size(colors));
|
||||
@ -530,10 +527,10 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, A
|
||||
|| node->type == kExprNodeSingleQuotedString) // "svalue"
|
||||
+ (node->type == kExprNodeAssignment) // "augmentation"
|
||||
+ 0);
|
||||
Dictionary ret_node = arena_dict(arena, items_size);
|
||||
*cur_item.ret_node_p = DICTIONARY_OBJ(ret_node);
|
||||
Dict ret_node = arena_dict(arena, items_size);
|
||||
*cur_item.ret_node_p = DICT_OBJ(ret_node);
|
||||
}
|
||||
Dictionary *ret_node = &cur_item.ret_node_p->data.dictionary;
|
||||
Dict *ret_node = &cur_item.ret_node_p->data.dict;
|
||||
if (node->children != NULL) {
|
||||
const size_t num_children = 1 + (node->children->next != NULL);
|
||||
Array children_array = arena_array(arena, num_children);
|
||||
@ -638,8 +635,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, A
|
||||
case kExprNodeMod:
|
||||
break;
|
||||
}
|
||||
assert(cur_item.ret_node_p->data.dictionary.size
|
||||
== cur_item.ret_node_p->data.dictionary.capacity);
|
||||
assert(cur_item.ret_node_p->data.dict.size == cur_item.ret_node_p->data.dict.capacity);
|
||||
xfree(*cur_item.node_p);
|
||||
*cur_item.node_p = NULL;
|
||||
}
|
||||
|
@ -503,16 +503,15 @@ void nvim_win_set_hl_ns(Window window, Integer ns_id, Error *err)
|
||||
/// - end_vcol: Ending virtual column index on "end_row",
|
||||
/// 0-based exclusive, rounded up to full screen lines.
|
||||
/// When omitted include the whole line.
|
||||
/// @return Dictionary containing text height information, with these keys:
|
||||
/// @return Dict containing text height information, with these keys:
|
||||
/// - all: The total number of screen lines occupied by the range.
|
||||
/// - fill: The number of diff filler or virtual lines among them.
|
||||
///
|
||||
/// @see |virtcol()| for text width.
|
||||
Dictionary nvim_win_text_height(Window window, Dict(win_text_height) *opts, Arena *arena,
|
||||
Error *err)
|
||||
Dict nvim_win_text_height(Window window, Dict(win_text_height) *opts, Arena *arena, Error *err)
|
||||
FUNC_API_SINCE(12)
|
||||
{
|
||||
Dictionary rv = arena_dict(arena, 2);
|
||||
Dict rv = arena_dict(arena, 2);
|
||||
|
||||
win_T *const win = find_window_by_handle(window, err);
|
||||
if (!win) {
|
||||
|
@ -2052,7 +2052,7 @@ static bool call_autocmd_callback(const AutoCmd *ac, const AutoPatCmd *apc)
|
||||
}
|
||||
|
||||
MAXSIZE_TEMP_ARRAY(args, 1);
|
||||
ADD_C(args, DICTIONARY_OBJ(data));
|
||||
ADD_C(args, DICT_OBJ(data));
|
||||
|
||||
Object result = nlua_call_ref(callback.data.luaref, NULL, args, kRetNilBool, NULL, NULL);
|
||||
return LUARET_TRUTHY(result);
|
||||
|
@ -393,7 +393,7 @@ struct file_buffer {
|
||||
|
||||
/// Change-identifier incremented for each change, including undo.
|
||||
///
|
||||
/// This is a dictionary item used to store b:changedtick.
|
||||
/// This is a dict item used to store b:changedtick.
|
||||
ChangedtickDictItem changedtick_di;
|
||||
|
||||
varnumber_T b_last_changedtick; // b:changedtick when TextChanged was
|
||||
@ -672,8 +672,8 @@ struct file_buffer {
|
||||
int b_bad_char; // "++bad=" argument when edit started or 0
|
||||
int b_start_bomb; // 'bomb' when it was read
|
||||
|
||||
ScopeDictDictItem b_bufvar; ///< Variable for "b:" Dictionary.
|
||||
dict_T *b_vars; ///< b: scope dictionary.
|
||||
ScopeDictDictItem b_bufvar; ///< Variable for "b:" Dict.
|
||||
dict_T *b_vars; ///< b: scope Dict.
|
||||
|
||||
// When a buffer is created, it starts without a swap file. b_may_swap is
|
||||
// then set to indicate that a swap file may be opened later. It is reset
|
||||
@ -792,7 +792,7 @@ struct tabpage_S {
|
||||
int tp_diff_invalid; ///< list of diffs is outdated
|
||||
int tp_diff_update; ///< update diffs before redrawing
|
||||
frame_T *(tp_snapshot[SNAP_COUNT]); ///< window layout snapshots
|
||||
ScopeDictDictItem tp_winvar; ///< Variable for "t:" Dictionary.
|
||||
ScopeDictDictItem tp_winvar; ///< Variable for "t:" Dict.
|
||||
dict_T *tp_vars; ///< Internal variables, local to tab page.
|
||||
char *tp_localdir; ///< Absolute path of local cwd or NULL.
|
||||
char *tp_prevdir; ///< Previous directory.
|
||||
@ -1263,8 +1263,8 @@ struct window_S {
|
||||
|
||||
int w_scbind_pos;
|
||||
|
||||
ScopeDictDictItem w_winvar; ///< Variable for "w:" dictionary.
|
||||
dict_T *w_vars; ///< Dictionary with w: variables.
|
||||
ScopeDictDictItem w_winvar; ///< Variable for "w:" dict.
|
||||
dict_T *w_vars; ///< Dict with w: variables.
|
||||
|
||||
// The w_prev_pcmark field is used to check whether we really did jump to
|
||||
// a new line after setting the w_pcmark. If not, then we revert to
|
||||
|
@ -239,11 +239,11 @@ void channel_create_event(Channel *chan, const char *ext_source)
|
||||
|
||||
assert(chan->id <= VARNUMBER_MAX);
|
||||
Arena arena = ARENA_EMPTY;
|
||||
Dictionary info = channel_info(chan->id, &arena);
|
||||
Dict info = channel_info(chan->id, &arena);
|
||||
typval_T tv = TV_INITIAL_VALUE;
|
||||
// TODO(bfredl): do the conversion in one step. Also would be nice
|
||||
// to pretty print top level dict in defined order
|
||||
object_to_vim(DICTIONARY_OBJ(info), &tv, NULL);
|
||||
object_to_vim(DICT_OBJ(info), &tv, NULL);
|
||||
assert(tv.v_type == VAR_DICT);
|
||||
char *str = encode_tv2json(&tv, NULL);
|
||||
ILOG("new channel %" PRIu64 " (%s) : %s", chan->id, source, str);
|
||||
@ -888,9 +888,9 @@ static void set_info_event(void **argv)
|
||||
save_v_event_T save_v_event;
|
||||
dict_T *dict = get_v_event(&save_v_event);
|
||||
Arena arena = ARENA_EMPTY;
|
||||
Dictionary info = channel_info(chan->id, &arena);
|
||||
Dict info = channel_info(chan->id, &arena);
|
||||
typval_T retval;
|
||||
object_to_vim(DICTIONARY_OBJ(info), &retval, NULL);
|
||||
object_to_vim(DICT_OBJ(info), &retval, NULL);
|
||||
assert(retval.v_type == VAR_DICT);
|
||||
tv_dict_add_dict(dict, S_LEN("info"), retval.vval.v_dict);
|
||||
tv_dict_set_keys_readonly(dict);
|
||||
@ -910,14 +910,14 @@ bool channel_job_running(uint64_t id)
|
||||
&& !proc_is_stopped(&chan->stream.proc));
|
||||
}
|
||||
|
||||
Dictionary channel_info(uint64_t id, Arena *arena)
|
||||
Dict channel_info(uint64_t id, Arena *arena)
|
||||
{
|
||||
Channel *chan = find_channel(id);
|
||||
if (!chan) {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
Dictionary info = arena_dict(arena, 8);
|
||||
Dict info = arena_dict(arena, 8);
|
||||
PUT_C(info, "id", INTEGER_OBJ((Integer)chan->id));
|
||||
|
||||
const char *stream_desc, *mode_desc;
|
||||
@ -963,7 +963,7 @@ Dictionary channel_info(uint64_t id, Arena *arena)
|
||||
|
||||
if (chan->is_rpc) {
|
||||
mode_desc = "rpc";
|
||||
PUT_C(info, "client", DICTIONARY_OBJ(chan->rpc.info));
|
||||
PUT_C(info, "client", DICT_OBJ(chan->rpc.info));
|
||||
} else if (chan->term) {
|
||||
mode_desc = "terminal";
|
||||
PUT_C(info, "buffer", BUFFER_OBJ(terminal_buf(chan->term)));
|
||||
@ -996,7 +996,7 @@ Array channel_all_info(Arena *arena)
|
||||
|
||||
Array ret = arena_array(arena, ids.size);
|
||||
for (size_t i = 0; i < ids.size; i++) {
|
||||
ADD_C(ret, DICTIONARY_OBJ(channel_info((uint64_t)ids.items[i], arena)));
|
||||
ADD_C(ret, DICT_OBJ(channel_info((uint64_t)ids.items[i], arena)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -265,17 +265,17 @@ static inline String array_to_string(Array array, Error *err)
|
||||
return sbuf;
|
||||
}
|
||||
|
||||
/// Converts Context to Dictionary representation.
|
||||
/// Converts Context to Dict representation.
|
||||
///
|
||||
/// @param[in] ctx Context to convert.
|
||||
///
|
||||
/// @return Dictionary representing "ctx".
|
||||
Dictionary ctx_to_dict(Context *ctx, Arena *arena)
|
||||
/// @return Dict representing "ctx".
|
||||
Dict ctx_to_dict(Context *ctx, Arena *arena)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
assert(ctx != NULL);
|
||||
|
||||
Dictionary rv = arena_dict(arena, 5);
|
||||
Dict rv = arena_dict(arena, 5);
|
||||
|
||||
PUT_C(rv, "regs", ARRAY_OBJ(string_to_array(ctx->regs, false, arena)));
|
||||
PUT_C(rv, "jumps", ARRAY_OBJ(string_to_array(ctx->jumps, false, arena)));
|
||||
@ -286,14 +286,14 @@ Dictionary ctx_to_dict(Context *ctx, Arena *arena)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/// Converts Dictionary representation of Context back to Context object.
|
||||
/// Converts Dict representation of Context back to Context object.
|
||||
///
|
||||
/// @param[in] dict Context Dictionary representation.
|
||||
/// @param[in] dict Context Dict representation.
|
||||
/// @param[out] ctx Context object to store conversion result into.
|
||||
/// @param[out] err Error object.
|
||||
///
|
||||
/// @return types of included context items.
|
||||
int ctx_from_dict(Dictionary dict, Context *ctx, Error *err)
|
||||
int ctx_from_dict(Dict dict, Context *ctx, Error *err)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
assert(ctx != NULL);
|
||||
|
@ -57,7 +57,7 @@ Array mode_style_array(Arena *arena)
|
||||
|
||||
for (int i = 0; i < SHAPE_IDX_COUNT; i++) {
|
||||
cursorentry_T *cur = &shape_table[i];
|
||||
Dictionary dic = arena_dict(arena, 3 + ((cur->used_for & SHAPE_CURSOR) ? 9 : 0));
|
||||
Dict dic = arena_dict(arena, 3 + ((cur->used_for & SHAPE_CURSOR) ? 9 : 0));
|
||||
PUT_C(dic, "name", CSTR_AS_OBJ(cur->full_name));
|
||||
PUT_C(dic, "short_name", CSTR_AS_OBJ(cur->name));
|
||||
if (cur->used_for & SHAPE_MOUSE) {
|
||||
@ -86,7 +86,7 @@ Array mode_style_array(Arena *arena)
|
||||
PUT_C(dic, "attr_id_lm", INTEGER_OBJ(cur->id_lm ? syn_id2attr(cur->id_lm) : 0));
|
||||
}
|
||||
|
||||
ADD_C(all, DICTIONARY_OBJ(dic));
|
||||
ADD_C(all, DICT_OBJ(dic));
|
||||
}
|
||||
|
||||
return all;
|
||||
|
@ -938,7 +938,7 @@ int decor_virt_lines(win_T *wp, int start_row, int end_row, VirtLines *lines, bo
|
||||
/// This assumes maximum one entry of each kind, which will not always be the case.
|
||||
///
|
||||
/// NB: assumes caller has allocated enough space in dict for all fields!
|
||||
void decor_to_dict_legacy(Dictionary *dict, DecorInline decor, bool hl_name, Arena *arena)
|
||||
void decor_to_dict_legacy(Dict *dict, DecorInline decor, bool hl_name, Arena *arena)
|
||||
{
|
||||
DecorSignHighlight sh_hl = DECOR_SIGN_HIGHLIGHT_INIT;
|
||||
DecorSignHighlight sh_sign = DECOR_SIGN_HIGHLIGHT_INIT;
|
||||
|
@ -61,7 +61,7 @@ typedef struct {
|
||||
bool ll_empty2; ///< Second index is empty: [i:].
|
||||
int ll_n1; ///< First index for list.
|
||||
int ll_n2; ///< Second index for list range.
|
||||
dict_T *ll_dict; ///< The Dictionary or NULL.
|
||||
dict_T *ll_dict; ///< The Dict or NULL.
|
||||
dictitem_T *ll_di; ///< The dictitem or NULL.
|
||||
char *ll_newkey; ///< New key for Dict in allocated memory or NULL.
|
||||
blob_T *ll_blob; ///< The Blob or NULL.
|
||||
@ -172,7 +172,7 @@ typedef enum {
|
||||
VV_MSGPACK_TYPES,
|
||||
VV__NULL_STRING, // String with NULL value. For test purposes only.
|
||||
VV__NULL_LIST, // List with NULL value. For test purposes only.
|
||||
VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
|
||||
VV__NULL_DICT, // Dict with NULL value. For test purposes only.
|
||||
VV__NULL_BLOB, // Blob with NULL value. For test purposes only.
|
||||
VV_LUA,
|
||||
VV_RELNUM,
|
||||
|
@ -995,9 +995,9 @@ static void f_ctxget(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
}
|
||||
|
||||
Arena arena = ARENA_EMPTY;
|
||||
Dictionary ctx_dict = ctx_to_dict(ctx, &arena);
|
||||
Dict ctx_dict = ctx_to_dict(ctx, &arena);
|
||||
Error err = ERROR_INIT;
|
||||
object_to_vim(DICTIONARY_OBJ(ctx_dict), rettv, &err);
|
||||
object_to_vim(DICT_OBJ(ctx_dict), rettv, &err);
|
||||
arena_mem_free(arena_finish(&arena));
|
||||
api_clear_error(&err);
|
||||
}
|
||||
@ -1067,7 +1067,7 @@ static void f_ctxset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
did_emsg = false;
|
||||
|
||||
Arena arena = ARENA_EMPTY;
|
||||
Dictionary dict = vim_to_object(&argvars[0], &arena, true).data.dictionary;
|
||||
Dict dict = vim_to_object(&argvars[0], &arena, true).data.dict;
|
||||
Context tmp = CONTEXT_INIT;
|
||||
Error err = ERROR_INIT;
|
||||
ctx_from_dict(dict, &tmp, &err);
|
||||
|
@ -109,7 +109,7 @@ typedef enum {
|
||||
VAR_STRING, ///< String, .v_string is used.
|
||||
VAR_FUNC, ///< Function reference, .v_string is used as function name.
|
||||
VAR_LIST, ///< List, .v_list is used.
|
||||
VAR_DICT, ///< Dictionary, .v_dict is used.
|
||||
VAR_DICT, ///< Dict, .v_dict is used.
|
||||
VAR_FLOAT, ///< Floating-point value, .v_float is used.
|
||||
VAR_BOOL, ///< true, false
|
||||
VAR_SPECIAL, ///< Special value (null), .v_special is used.
|
||||
@ -141,7 +141,7 @@ typedef struct {
|
||||
float_T v_float; ///< Floating-point number, for VAR_FLOAT.
|
||||
char *v_string; ///< String, for VAR_STRING and VAR_FUNC, can be NULL.
|
||||
list_T *v_list; ///< List for VAR_LIST, can be NULL.
|
||||
dict_T *v_dict; ///< Dictionary for VAR_DICT, can be NULL.
|
||||
dict_T *v_dict; ///< Dict for VAR_DICT, can be NULL.
|
||||
partial_T *v_partial; ///< Closure: function with args.
|
||||
blob_T *v_blob; ///< Blob for VAR_BLOB, can be NULL.
|
||||
} vval; ///< Actual value.
|
||||
@ -259,7 +259,7 @@ struct dictvar_S {
|
||||
dict_T *dv_copydict; ///< Copied dict used by deepcopy().
|
||||
dict_T *dv_used_next; ///< Next dictionary in used dictionaries list.
|
||||
dict_T *dv_used_prev; ///< Previous dictionary in used dictionaries list.
|
||||
QUEUE watchers; ///< Dictionary key watchers set by user code.
|
||||
QUEUE watchers; ///< Dict key watchers set by user code.
|
||||
|
||||
LuaRef lua_table_ref;
|
||||
};
|
||||
|
@ -173,8 +173,7 @@
|
||||
/// point to a special dictionary.
|
||||
/// @param dict Converted dictionary, lvalue or #TYPVAL_ENCODE_NODICT_VAR
|
||||
/// (for dictionaries represented as special lists).
|
||||
/// @param len Dictionary length. Is an expression which evaluates to an
|
||||
/// integer.
|
||||
/// @param len Dict length. Is an expression which evaluates to an integer.
|
||||
|
||||
/// @def TYPVAL_ENCODE_CONV_REAL_DICT_AFTER_START
|
||||
/// @brief Macros used after pushing dictionary onto the stack
|
||||
|
@ -955,7 +955,7 @@ void remove_funccal(void)
|
||||
/// @param[out] rettv Return value.
|
||||
/// @param[in] firstline First line of range.
|
||||
/// @param[in] lastline Last line of range.
|
||||
/// @param selfdict Dictionary for "self" for dictionary functions.
|
||||
/// @param selfdict Dict for "self" for dictionary functions.
|
||||
void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, typval_T *rettv,
|
||||
linenr_T firstline, linenr_T lastline, dict_T *selfdict)
|
||||
FUNC_ATTR_NONNULL_ARG(1, 3, 4)
|
||||
@ -1922,7 +1922,7 @@ static int list_func_head(ufunc_T *fp, bool indent, bool force)
|
||||
}
|
||||
|
||||
/// Get a function name, translating "<SID>" and "<SNR>".
|
||||
/// Also handles a Funcref in a List or Dictionary.
|
||||
/// Also handles a Funcref in a List or Dict.
|
||||
/// flags:
|
||||
/// TFN_INT: internal function name OK
|
||||
/// TFN_QUIET: be quiet
|
||||
@ -3242,7 +3242,7 @@ static int ex_call_inner(exarg_T *eap, char *name, char **arg, char *startarg,
|
||||
break;
|
||||
}
|
||||
|
||||
// Handle a function returning a Funcref, Dictionary or List.
|
||||
// Handle a function returning a Funcref, Dict or List.
|
||||
if (handle_subscript((const char **)arg, &rettv, &EVALARG_EVALUATE, true) == FAIL) {
|
||||
failed = true;
|
||||
break;
|
||||
|
@ -32,9 +32,9 @@
|
||||
|
||||
/// Structure used by trans_function_name()
|
||||
typedef struct {
|
||||
dict_T *fd_dict; ///< Dictionary used.
|
||||
dict_T *fd_dict; ///< Dict used.
|
||||
char *fd_newkey; ///< New key in "dict" in allocated memory.
|
||||
dictitem_T *fd_di; ///< Dictionary item used.
|
||||
dictitem_T *fd_di; ///< Dict item used.
|
||||
} funcdict_T;
|
||||
|
||||
typedef struct funccal_entry funccal_entry_T;
|
||||
@ -69,7 +69,7 @@ typedef struct {
|
||||
bool *fe_doesrange; ///< [out] if not NULL: function handled range
|
||||
bool fe_evaluate; ///< actually evaluate expressions
|
||||
partial_T *fe_partial; ///< for extra arguments
|
||||
dict_T *fe_selfdict; ///< Dictionary for "self"
|
||||
dict_T *fe_selfdict; ///< Dict for "self"
|
||||
typval_T *fe_basetv; ///< base for base->method()
|
||||
bool fe_found_var; ///< if the function is not found then give an
|
||||
///< error that a variable is not callable.
|
||||
|
@ -1108,7 +1108,7 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_
|
||||
// unlet a List item.
|
||||
tv_list_item_remove(lp->ll_list, lp->ll_li);
|
||||
} else {
|
||||
// unlet a Dictionary item.
|
||||
// unlet a Dict item.
|
||||
dict_T *d = lp->ll_dict;
|
||||
assert(d != NULL);
|
||||
dictitem_T *di = lp->ll_di;
|
||||
@ -1283,7 +1283,7 @@ static int do_lock_var(lval_T *lp, char *name_end FUNC_ATTR_UNUSED, exarg_T *eap
|
||||
// (un)lock a List item.
|
||||
tv_item_lock(TV_LIST_ITEM_TV(lp->ll_li), deep, lock, false);
|
||||
} else {
|
||||
// (un)lock a Dictionary item.
|
||||
// (un)lock a Dict item.
|
||||
tv_item_lock(&lp->ll_di->di_tv, deep, lock, false);
|
||||
}
|
||||
|
||||
|
@ -35,11 +35,7 @@ local cdoc_comment = P('///') * opt(Ct(Cg(rep(space) * rep(not_nl), 'comment')))
|
||||
local c_preproc = P('#') * rep(not_nl)
|
||||
local dllexport = P('DLLEXPORT') * rep1(ws)
|
||||
|
||||
local typed_container = (
|
||||
(P('ArrayOf(') + P('DictionaryOf(') + P('Dict('))
|
||||
* rep1(any - P(')'))
|
||||
* P(')')
|
||||
)
|
||||
local typed_container = ((P('ArrayOf(') + P('DictOf(') + P('Dict(')) * rep1(any - P(')')) * P(')'))
|
||||
|
||||
local c_id = (typed_container + (letter * rep(alpha)))
|
||||
local c_void = P('void')
|
||||
|
@ -216,15 +216,15 @@ for _, f in ipairs(functions) do
|
||||
end
|
||||
f_exported.parameters = {}
|
||||
for i, param in ipairs(f.parameters) do
|
||||
if param[1] == 'DictionaryOf(LuaRef)' then
|
||||
param = { 'Dictionary', param[2] }
|
||||
if param[1] == 'DictOf(LuaRef)' then
|
||||
param = { 'Dict', param[2] }
|
||||
elseif startswith(param[1], 'Dict(') then
|
||||
param = { 'Dictionary', param[2] }
|
||||
param = { 'Dict', param[2] }
|
||||
end
|
||||
f_exported.parameters[i] = param
|
||||
end
|
||||
if startswith(f.return_type, 'Dict(') then
|
||||
f_exported.return_type = 'Dictionary'
|
||||
f_exported.return_type = 'Dict'
|
||||
end
|
||||
exported_functions[#exported_functions + 1] = f_exported
|
||||
end
|
||||
@ -406,7 +406,7 @@ local function real_type(type)
|
||||
if rv:match('Array') then
|
||||
rv = 'Array'
|
||||
else
|
||||
rv = 'Dictionary'
|
||||
rv = 'Dict'
|
||||
end
|
||||
end
|
||||
return rv
|
||||
@ -466,7 +466,7 @@ for i = 1, #functions do
|
||||
output:write('\n ' .. converted .. ' = args.items[' .. (j - 1) .. '];\n')
|
||||
elseif rt:match('^KeyDict_') then
|
||||
converted = '&' .. converted
|
||||
output:write('\n if (args.items[' .. (j - 1) .. '].type == kObjectTypeDictionary) {') --luacheck: ignore 631
|
||||
output:write('\n if (args.items[' .. (j - 1) .. '].type == kObjectTypeDict) {') --luacheck: ignore 631
|
||||
output:write('\n memset(' .. converted .. ', 0, sizeof(*' .. converted .. '));') -- TODO: neeeee
|
||||
output:write(
|
||||
'\n if (!api_dict_to_keydict('
|
||||
@ -475,7 +475,7 @@ for i = 1, #functions do
|
||||
.. rt
|
||||
.. '_get_field, args.items['
|
||||
.. (j - 1)
|
||||
.. '].data.dictionary, error)) {'
|
||||
.. '].data.dict, error)) {'
|
||||
)
|
||||
output:write('\n goto cleanup;')
|
||||
output:write('\n }')
|
||||
@ -554,7 +554,7 @@ for i = 1, #functions do
|
||||
)
|
||||
end
|
||||
-- accept empty lua tables as empty dictionaries
|
||||
if rt:match('^Dictionary') then
|
||||
if rt:match('^Dict') then
|
||||
output:write(
|
||||
'\n } else if (args.items['
|
||||
.. (j - 1)
|
||||
@ -562,7 +562,7 @@ for i = 1, #functions do
|
||||
.. (j - 1)
|
||||
.. '].data.array.size == 0) {'
|
||||
) --luacheck: ignore 631
|
||||
output:write('\n ' .. converted .. ' = (Dictionary)ARRAY_DICT_INIT;')
|
||||
output:write('\n ' .. converted .. ' = (Dict)ARRAY_DICT_INIT;')
|
||||
end
|
||||
output:write('\n } else {')
|
||||
output:write(
|
||||
@ -643,7 +643,7 @@ for i = 1, #functions do
|
||||
if string.match(ret_type, '^KeyDict_') then
|
||||
local table = string.sub(ret_type, 9) .. '_table'
|
||||
output:write(
|
||||
'\n ret = DICTIONARY_OBJ(api_keydict_to_dict(&rv, '
|
||||
'\n ret = DICT_OBJ(api_keydict_to_dict(&rv, '
|
||||
.. table
|
||||
.. ', ARRAY_SIZE('
|
||||
.. table
|
||||
@ -779,12 +779,12 @@ local function process_function(fn)
|
||||
local param = fn.parameters[j]
|
||||
local cparam = string.format('arg%u', j)
|
||||
local param_type = real_type(param[1])
|
||||
local extra = param_type == 'Dictionary' and 'false, ' or ''
|
||||
local extra = param_type == 'Dict' and 'false, ' or ''
|
||||
local arg_free_code = ''
|
||||
if param[1] == 'Object' then
|
||||
extra = 'true, '
|
||||
arg_free_code = 'api_luarefs_free_object(' .. cparam .. ');'
|
||||
elseif param[1] == 'DictionaryOf(LuaRef)' then
|
||||
elseif param[1] == 'DictOf(LuaRef)' then
|
||||
extra = 'true, '
|
||||
arg_free_code = 'api_luarefs_free_dict(' .. cparam .. ');'
|
||||
elseif param[1] == 'LuaRef' then
|
||||
|
@ -54,7 +54,7 @@ local function call_ui_event_method(output, ev)
|
||||
local kind = ev.parameters[j][1]
|
||||
if kind ~= 'Object' then
|
||||
if kind == 'HlAttrs' then
|
||||
kind = 'Dictionary'
|
||||
kind = 'Dict'
|
||||
end
|
||||
output:write('\n || args.items[' .. (j - 1) .. '].type != kObjectType' .. kind .. '')
|
||||
end
|
||||
@ -74,7 +74,7 @@ local function call_ui_event_method(output, ev)
|
||||
output:write(
|
||||
'ui_client_dict2hlattrs(args.items['
|
||||
.. (j - 1)
|
||||
.. '].data.dictionary, '
|
||||
.. '].data.dict, '
|
||||
.. (hlattrs_args_count == 0 and 'true' or 'false')
|
||||
.. ');\n'
|
||||
)
|
||||
@ -205,7 +205,8 @@ for _, ev in ipairs(events) do
|
||||
ev_exported[attr] = ev[attr]
|
||||
end
|
||||
for _, p in ipairs(ev_exported.parameters) do
|
||||
if p[1] == 'HlAttrs' then
|
||||
if p[1] == 'HlAttrs' or p[1] == 'Dict' then
|
||||
-- TODO(justinmk): for back-compat, but do clients actually look at this?
|
||||
p[1] = 'Dictionary'
|
||||
end
|
||||
end
|
||||
|
@ -70,7 +70,7 @@ local raw_word = concat(w, any_amount(aw))
|
||||
local right_word = concat(raw_word, neg_look_ahead(aw))
|
||||
local word = branch(
|
||||
concat(
|
||||
branch(lit('ArrayOf('), lit('DictionaryOf('), lit('Dict(')), -- typed container macro
|
||||
branch(lit('ArrayOf('), lit('DictOf('), lit('Dict(')), -- typed container macro
|
||||
one_or_more(any_character - lit(')')),
|
||||
lit(')')
|
||||
),
|
||||
|
@ -80,7 +80,7 @@ enum_w('')
|
||||
--- @type { [string]: string }
|
||||
local option_index = {}
|
||||
|
||||
-- Generate option index enum and populate the `option_index` dictionary.
|
||||
-- Generate option index enum and populate the `option_index` dict.
|
||||
enum_w('typedef enum {')
|
||||
enum_w(' kOptInvalid = -1,')
|
||||
|
||||
|
@ -178,8 +178,8 @@ EXTERN long emsg_assert_fails_lnum INIT( = 0);
|
||||
EXTERN char *emsg_assert_fails_context INIT( = NULL);
|
||||
|
||||
EXTERN bool did_endif INIT( = false); // just had ":endif"
|
||||
EXTERN dict_T vimvardict; // Dictionary with v: variables
|
||||
EXTERN dict_T globvardict; // Dictionary with g: variables
|
||||
EXTERN dict_T vimvardict; // Dict with v: variables
|
||||
EXTERN dict_T globvardict; // Dict with g: variables
|
||||
/// g: value
|
||||
#define globvarht globvardict.dv_hashtab
|
||||
EXTERN int did_emsg; // incremented by emsg() when a
|
||||
|
@ -219,11 +219,10 @@ int ns_get_hl(NS *ns_hl, int hl_id, bool link, bool nodefault)
|
||||
bool fallback = true;
|
||||
int tmp = false;
|
||||
HlAttrs attrs = HLATTRS_INIT;
|
||||
if (ret.type == kObjectTypeDictionary) {
|
||||
if (ret.type == kObjectTypeDict) {
|
||||
fallback = false;
|
||||
Dict(highlight) dict = KEYDICT_INIT;
|
||||
if (api_dict_to_keydict(&dict, KeyDict_highlight_get_field,
|
||||
ret.data.dictionary, &err)) {
|
||||
if (api_dict_to_keydict(&dict, KeyDict_highlight_get_field, ret.data.dict, &err)) {
|
||||
attrs = dict2hlattrs(&dict, true, &it.link_id, &err);
|
||||
fallback = GET_BOOL_OR_TRUE(&dict, highlight, fallback);
|
||||
tmp = dict.fallback; // or false
|
||||
@ -875,9 +874,9 @@ HlAttrs syn_attr2entry(int attr)
|
||||
}
|
||||
|
||||
/// Gets highlight description for id `attr_id` as a map.
|
||||
Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Arena *arena, Error *err)
|
||||
Dict hl_get_attr_by_id(Integer attr_id, Boolean rgb, Arena *arena, Error *err)
|
||||
{
|
||||
Dictionary dic = ARRAY_DICT_INIT;
|
||||
Dict dic = ARRAY_DICT_INIT;
|
||||
|
||||
if (attr_id == 0) {
|
||||
return dic;
|
||||
@ -888,19 +887,19 @@ Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Arena *arena, Error *
|
||||
"Invalid attribute id: %" PRId64, attr_id);
|
||||
return dic;
|
||||
}
|
||||
Dictionary retval = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
Dict retval = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
hlattrs2dict(&retval, NULL, syn_attr2entry((int)attr_id), rgb, false);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// Converts an HlAttrs into Dictionary
|
||||
/// Converts an HlAttrs into Dict
|
||||
///
|
||||
/// @param[in/out] hl Dictionary with pre-allocated space for HLATTRS_DICT_SIZE elements
|
||||
/// @param[in/out] hl Dict with pre-allocated space for HLATTRS_DICT_SIZE elements
|
||||
/// @param[in] aep data to convert
|
||||
/// @param use_rgb use 'gui*' settings if true, else resorts to 'cterm*'
|
||||
/// @param short_keys change (foreground, background, special) to (fg, bg, sp) for 'gui*' settings
|
||||
/// (foreground, background) to (ctermfg, ctermbg) for 'cterm*' settings
|
||||
void hlattrs2dict(Dictionary *hl, Dictionary *hl_attrs, HlAttrs ae, bool use_rgb, bool short_keys)
|
||||
void hlattrs2dict(Dict *hl, Dict *hl_attrs, HlAttrs ae, bool use_rgb, bool short_keys)
|
||||
{
|
||||
hl_attrs = hl_attrs ? hl_attrs : hl;
|
||||
assert(hl->capacity >= HLATTRS_DICT_SIZE); // at most 16 items
|
||||
@ -1088,10 +1087,10 @@ HlAttrs dict2hlattrs(Dict(highlight) *dict, bool use_rgb, int *link_id, Error *e
|
||||
}
|
||||
|
||||
// Handle cterm attrs
|
||||
if (dict->cterm.type == kObjectTypeDictionary) {
|
||||
if (dict->cterm.type == kObjectTypeDict) {
|
||||
Dict(highlight_cterm) cterm[1] = KEYDICT_INIT;
|
||||
if (!api_dict_to_keydict(cterm, KeyDict_highlight_cterm_get_field,
|
||||
dict->cterm.data.dictionary, err)) {
|
||||
dict->cterm.data.dict, err)) {
|
||||
return hlattrs;
|
||||
}
|
||||
|
||||
@ -1206,7 +1205,7 @@ static size_t hl_inspect_size(int attr)
|
||||
|
||||
static void hl_inspect_impl(Array *arr, int attr, Arena *arena)
|
||||
{
|
||||
Dictionary item = ARRAY_DICT_INIT;
|
||||
Dict item = ARRAY_DICT_INIT;
|
||||
if (attr <= 0 || attr >= (int)set_size(&attr_entries)) {
|
||||
return;
|
||||
}
|
||||
@ -1245,5 +1244,5 @@ static void hl_inspect_impl(Array *arr, int attr, Arena *arena)
|
||||
return;
|
||||
}
|
||||
PUT_C(item, "id", INTEGER_OBJ(attr));
|
||||
ADD_C(*arr, DICTIONARY_OBJ(item));
|
||||
ADD_C(*arr, DICT_OBJ(item));
|
||||
}
|
||||
|
@ -1629,7 +1629,7 @@ static void highlight_list_one(const int id)
|
||||
}
|
||||
}
|
||||
|
||||
static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
|
||||
static bool hlgroup2dict(Dict *hl, NS ns_id, int hl_id, Arena *arena)
|
||||
{
|
||||
HlGroup *sgp = &hl_table[hl_id - 1];
|
||||
int link = ns_id == 0 ? sgp->sg_link : ns_get_hl(&ns_id, hl_id, true, sgp->sg_set);
|
||||
@ -1650,16 +1650,16 @@ static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
|
||||
assert(1 <= link && link <= highlight_ga.ga_len);
|
||||
PUT_C(*hl, "link", CSTR_AS_OBJ(hl_table[link - 1].sg_name));
|
||||
}
|
||||
Dictionary hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
Dict hl_cterm = arena_dict(arena, HLATTRS_DICT_SIZE);
|
||||
hlattrs2dict(hl, NULL, attr, true, true);
|
||||
hlattrs2dict(hl, &hl_cterm, attr, false, true);
|
||||
if (kv_size(hl_cterm)) {
|
||||
PUT_C(*hl, "cterm", DICTIONARY_OBJ(hl_cterm));
|
||||
PUT_C(*hl, "cterm", DICT_OBJ(hl_cterm));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
|
||||
Dict ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Error *err)
|
||||
{
|
||||
Boolean link = GET_BOOL_OR_TRUE(opts, get_highlight, link);
|
||||
int id = -1;
|
||||
@ -1668,7 +1668,7 @@ Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Err
|
||||
id = create ? syn_check_group(opts->name.data, opts->name.size)
|
||||
: syn_name2id_len(opts->name.data, opts->name.size);
|
||||
if (id == 0 && !create) {
|
||||
Dictionary attrs = ARRAY_DICT_INIT;
|
||||
Dict attrs = ARRAY_DICT_INIT;
|
||||
return attrs;
|
||||
}
|
||||
} else if (HAS_KEY(opts, get_highlight, id)) {
|
||||
@ -1679,7 +1679,7 @@ Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Err
|
||||
VALIDATE(1 <= id && id <= highlight_ga.ga_len, "%s", "Highlight id out of bounds", {
|
||||
goto cleanup;
|
||||
});
|
||||
Dictionary attrs = ARRAY_DICT_INIT;
|
||||
Dict attrs = ARRAY_DICT_INIT;
|
||||
hlgroup2dict(&attrs, ns_id, link ? id : syn_get_final_id(id), arena);
|
||||
return attrs;
|
||||
}
|
||||
@ -1687,19 +1687,19 @@ Dictionary ns_get_hl_defs(NS ns_id, Dict(get_highlight) *opts, Arena *arena, Err
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Dictionary rv = arena_dict(arena, (size_t)highlight_ga.ga_len);
|
||||
Dict rv = arena_dict(arena, (size_t)highlight_ga.ga_len);
|
||||
for (int i = 1; i <= highlight_ga.ga_len; i++) {
|
||||
Dictionary attrs = ARRAY_DICT_INIT;
|
||||
Dict attrs = ARRAY_DICT_INIT;
|
||||
if (!hlgroup2dict(&attrs, ns_id, i, arena)) {
|
||||
continue;
|
||||
}
|
||||
PUT_C(rv, hl_table[(link ? i : syn_get_final_id(i)) - 1].sg_name, DICTIONARY_OBJ(attrs));
|
||||
PUT_C(rv, hl_table[(link ? i : syn_get_final_id(i)) - 1].sg_name, DICT_OBJ(attrs));
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
cleanup:
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
}
|
||||
|
||||
/// Outputs a highlight when doing ":hi MyHighlight"
|
||||
|
@ -26,13 +26,13 @@
|
||||
#include "nvim/types_defs.h"
|
||||
#include "nvim/vim_defs.h"
|
||||
|
||||
/// Determine, which keys lua table contains
|
||||
/// Determine, which keys Lua table contains
|
||||
typedef struct {
|
||||
size_t maxidx; ///< Maximum positive integral value found.
|
||||
size_t string_keys_num; ///< Number of string keys.
|
||||
bool has_string_with_nul; ///< True if there is string key with NUL byte.
|
||||
ObjectType type; ///< If has_type_key is true then attached value. Otherwise
|
||||
///< either kObjectTypeNil, kObjectTypeDictionary or
|
||||
///< either kObjectTypeNil, kObjectTypeDict or
|
||||
///< kObjectTypeArray, depending on other properties.
|
||||
lua_Number val; ///< If has_val_key and val_type == LUA_TNUMBER: value.
|
||||
bool has_type_key; ///< True if type key is present.
|
||||
@ -52,7 +52,7 @@ static LuaTableProps nlua_traverse_table(lua_State *const lstate)
|
||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
size_t tsize = 0; // Total number of keys.
|
||||
int val_type = 0; // If has_val_key: lua type of the value.
|
||||
int val_type = 0; // If has_val_key: Lua type of the value.
|
||||
bool has_val_key = false; // True if val key was found,
|
||||
// @see nlua_push_val_idx().
|
||||
size_t other_keys_num = 0; // Number of keys that are not string, integral
|
||||
@ -96,7 +96,7 @@ static LuaTableProps nlua_traverse_table(lua_State *const lstate)
|
||||
lua_Number n = lua_tonumber(lstate, -1);
|
||||
if (n == (lua_Number)kObjectTypeFloat
|
||||
|| n == (lua_Number)kObjectTypeArray
|
||||
|| n == (lua_Number)kObjectTypeDictionary) {
|
||||
|| n == (lua_Number)kObjectTypeDict) {
|
||||
ret.has_type_key = true;
|
||||
ret.type = (ObjectType)n;
|
||||
} else {
|
||||
@ -156,12 +156,12 @@ static LuaTableProps nlua_traverse_table(lua_State *const lstate)
|
||||
if (tsize == 0 && lua_getmetatable(lstate, -1)) {
|
||||
nlua_pushref(lstate, nlua_global_refs->empty_dict_ref);
|
||||
if (lua_rawequal(lstate, -2, -1)) {
|
||||
ret.type = kObjectTypeDictionary;
|
||||
ret.type = kObjectTypeDict;
|
||||
}
|
||||
lua_pop(lstate, 2);
|
||||
}
|
||||
} else if (ret.string_keys_num == tsize) {
|
||||
ret.type = kObjectTypeDictionary;
|
||||
ret.type = kObjectTypeDict;
|
||||
} else {
|
||||
ret.type = kObjectTypeNil;
|
||||
}
|
||||
@ -174,14 +174,14 @@ typedef struct {
|
||||
typval_T *tv; ///< Location where conversion result is saved.
|
||||
size_t list_len; ///< Maximum length when tv is a list.
|
||||
bool container; ///< True if tv is a container.
|
||||
bool special; ///< If true then tv is a _VAL part of special dictionary
|
||||
bool special; ///< If true then tv is a _VAL part of special dict.
|
||||
///< that represents mapping.
|
||||
int idx; ///< Container index (used to detect self-referencing structures).
|
||||
} TVPopStackItem;
|
||||
|
||||
/// Convert lua object to Vimscript typval_T
|
||||
/// Convert Lua object to Vimscript typval_T
|
||||
///
|
||||
/// Should pop exactly one value from lua stack.
|
||||
/// Should pop exactly one value from Lua stack.
|
||||
///
|
||||
/// @param lstate Lua state.
|
||||
/// @param[out] ret_tv Where to put the result.
|
||||
@ -322,7 +322,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv)
|
||||
kvi_push(stack, cur);
|
||||
}
|
||||
break;
|
||||
case kObjectTypeDictionary:
|
||||
case kObjectTypeDict:
|
||||
if (table_props.string_keys_num == 0) {
|
||||
cur.tv->v_type = VAR_DICT;
|
||||
cur.tv->vval.v_dict = tv_dict_alloc();
|
||||
@ -357,7 +357,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv)
|
||||
cur.tv->vval.v_float = (float_T)table_props.val;
|
||||
break;
|
||||
case kObjectTypeNil:
|
||||
emsg(_("E5100: Cannot convert given lua table: table should "
|
||||
emsg(_("E5100: Cannot convert given Lua table: table should "
|
||||
"contain either only integer keys or only string keys"));
|
||||
ret = false;
|
||||
break;
|
||||
@ -385,13 +385,13 @@ nlua_pop_typval_table_processing_end:
|
||||
cur.tv->v_type = VAR_SPECIAL;
|
||||
cur.tv->vval.v_special = kSpecialVarNull;
|
||||
} else {
|
||||
emsg(_("E5101: Cannot convert given lua type"));
|
||||
emsg(_("E5101: Cannot convert given Lua type"));
|
||||
ret = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
emsg(_("E5101: Cannot convert given lua type"));
|
||||
emsg(_("E5101: Cannot convert given Lua type"));
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
@ -474,7 +474,7 @@ static bool typval_conv_special = false;
|
||||
#define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict) \
|
||||
do { \
|
||||
if (typval_conv_special) { \
|
||||
nlua_create_typed_table(lstate, 0, 0, kObjectTypeDictionary); \
|
||||
nlua_create_typed_table(lstate, 0, 0, kObjectTypeDict); \
|
||||
} else { \
|
||||
lua_createtable(lstate, 0, 0); \
|
||||
nlua_pushref(lstate, nlua_global_refs->empty_dict_ref); \
|
||||
@ -583,10 +583,9 @@ static bool typval_conv_special = false;
|
||||
#undef TYPVAL_ENCODE_CONV_RECURSE
|
||||
#undef TYPVAL_ENCODE_ALLOW_SPECIALS
|
||||
|
||||
/// Convert Vimscript typval_T to lua value
|
||||
/// Convert Vimscript typval_T to Lua value
|
||||
///
|
||||
/// Should leave single value in lua stack. May only fail if lua failed to grow
|
||||
/// stack.
|
||||
/// Should leave single value in Lua stack. May only fail if Lua failed to grow stack.
|
||||
///
|
||||
/// @param lstate Lua interpreter state.
|
||||
/// @param[in] tv typval_T to convert.
|
||||
@ -654,7 +653,7 @@ static inline void nlua_create_typed_table(lua_State *lstate, const size_t narr,
|
||||
lua_rawset(lstate, -3);
|
||||
}
|
||||
|
||||
/// Convert given String to lua string
|
||||
/// Convert given String to Lua string
|
||||
///
|
||||
/// Leaves converted string on top of the stack.
|
||||
void nlua_push_String(lua_State *lstate, const String s, int flags)
|
||||
@ -663,7 +662,7 @@ void nlua_push_String(lua_State *lstate, const String s, int flags)
|
||||
lua_pushlstring(lstate, s.data, s.size);
|
||||
}
|
||||
|
||||
/// Convert given Integer to lua number
|
||||
/// Convert given Integer to Lua number
|
||||
///
|
||||
/// Leaves converted number on top of the stack.
|
||||
void nlua_push_Integer(lua_State *lstate, const Integer n, int flags)
|
||||
@ -672,7 +671,7 @@ void nlua_push_Integer(lua_State *lstate, const Integer n, int flags)
|
||||
lua_pushnumber(lstate, (lua_Number)n);
|
||||
}
|
||||
|
||||
/// Convert given Float to lua table
|
||||
/// Convert given Float to Lua table
|
||||
///
|
||||
/// Leaves converted table on top of the stack.
|
||||
void nlua_push_Float(lua_State *lstate, const Float f, int flags)
|
||||
@ -688,7 +687,7 @@ void nlua_push_Float(lua_State *lstate, const Float f, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert given Float to lua boolean
|
||||
/// Convert given Float to Lua boolean
|
||||
///
|
||||
/// Leaves converted value on top of the stack.
|
||||
void nlua_push_Boolean(lua_State *lstate, const Boolean b, int flags)
|
||||
@ -697,10 +696,10 @@ void nlua_push_Boolean(lua_State *lstate, const Boolean b, int flags)
|
||||
lua_pushboolean(lstate, b);
|
||||
}
|
||||
|
||||
/// Convert given Dictionary to lua table
|
||||
/// Convert given Dict to Lua table
|
||||
///
|
||||
/// Leaves converted table on top of the stack.
|
||||
void nlua_push_Dictionary(lua_State *lstate, const Dictionary dict, int flags)
|
||||
void nlua_push_Dict(lua_State *lstate, const Dict dict, int flags)
|
||||
FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
lua_createtable(lstate, 0, (int)dict.size);
|
||||
@ -715,7 +714,7 @@ void nlua_push_Dictionary(lua_State *lstate, const Dictionary dict, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert given Array to lua table
|
||||
/// Convert given Array to Lua table
|
||||
///
|
||||
/// Leaves converted table on top of the stack.
|
||||
void nlua_push_Array(lua_State *lstate, const Array array, int flags)
|
||||
@ -741,7 +740,7 @@ GENERATE_INDEX_FUNCTION(Tabpage)
|
||||
|
||||
#undef GENERATE_INDEX_FUNCTION
|
||||
|
||||
/// Convert given Object to lua value
|
||||
/// Convert given Object to Lua value
|
||||
///
|
||||
/// Leaves converted value on top of the stack.
|
||||
void nlua_push_Object(lua_State *lstate, Object *obj, int flags)
|
||||
@ -773,7 +772,7 @@ void nlua_push_Object(lua_State *lstate, Object *obj, int flags)
|
||||
ADD_TYPE(Float, floating)
|
||||
ADD_TYPE(String, string)
|
||||
ADD_TYPE(Array, array)
|
||||
ADD_TYPE(Dictionary, dictionary)
|
||||
ADD_TYPE(Dict, dict)
|
||||
#undef ADD_TYPE
|
||||
#define ADD_REMOTE_TYPE(type) \
|
||||
case kObjectType##type: { \
|
||||
@ -787,7 +786,7 @@ void nlua_push_Object(lua_State *lstate, Object *obj, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert lua value to string
|
||||
/// Convert Lua value to string
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
String nlua_pop_String(lua_State *lstate, Arena *arena, Error *err)
|
||||
@ -802,16 +801,16 @@ String nlua_pop_String(lua_State *lstate, Arena *arena, Error *err)
|
||||
|
||||
ret.data = (char *)lua_tolstring(lstate, -1, &(ret.size));
|
||||
assert(ret.data != NULL);
|
||||
// TODO(bfredl): it would be "nice" to just use the memory of the lua string
|
||||
// TODO(bfredl): it would be "nice" to just use the memory of the Lua string
|
||||
// directly, although ensuring the lifetime of such strings is a bit tricky
|
||||
// (an API call could invoke nested lua, which triggers GC, and kaboom?)
|
||||
// (an API call could invoke nested Lua, which triggers GC, and kaboom?)
|
||||
ret.data = arena_memdupz(arena, ret.data, ret.size);
|
||||
lua_pop(lstate, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Convert lua value to integer
|
||||
/// Convert Lua value to integer
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
Integer nlua_pop_Integer(lua_State *lstate, Arena *arena, Error *err)
|
||||
@ -832,10 +831,10 @@ Integer nlua_pop_Integer(lua_State *lstate, Arena *arena, Error *err)
|
||||
return (Integer)n;
|
||||
}
|
||||
|
||||
/// Convert lua value to boolean
|
||||
/// Convert Lua value to boolean
|
||||
///
|
||||
/// Despite the name of the function, this uses lua semantics for booleans.
|
||||
/// thus `err` is never set as any lua value can be co-erced into a lua bool
|
||||
/// Despite the name of the function, this uses Lua semantics for booleans.
|
||||
/// thus `err` is never set as any Lua value can be co-erced into a Lua bool
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
Boolean nlua_pop_Boolean(lua_State *lstate, Arena *arena, Error *err)
|
||||
@ -846,7 +845,7 @@ Boolean nlua_pop_Boolean(lua_State *lstate, Arena *arena, Error *err)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Convert lua value to boolean
|
||||
/// Convert Lua value to boolean
|
||||
///
|
||||
/// This follows API conventions for a Boolean value, compare api_object_to_bool
|
||||
///
|
||||
@ -896,9 +895,9 @@ static inline LuaTableProps nlua_check_type(lua_State *const lstate, Error *cons
|
||||
}
|
||||
LuaTableProps table_props = nlua_traverse_table(lstate);
|
||||
|
||||
if (type == kObjectTypeDictionary && table_props.type == kObjectTypeArray
|
||||
if (type == kObjectTypeDict && table_props.type == kObjectTypeArray
|
||||
&& table_props.maxidx == 0 && !table_props.has_type_key) {
|
||||
table_props.type = kObjectTypeDictionary;
|
||||
table_props.type = kObjectTypeDict;
|
||||
}
|
||||
|
||||
if (table_props.type != type) {
|
||||
@ -910,7 +909,7 @@ static inline LuaTableProps nlua_check_type(lua_State *const lstate, Error *cons
|
||||
return table_props;
|
||||
}
|
||||
|
||||
/// Convert lua table to float
|
||||
/// Convert Lua table to float
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
Float nlua_pop_Float(lua_State *lstate, Arena *arena, Error *err)
|
||||
@ -931,7 +930,7 @@ Float nlua_pop_Float(lua_State *lstate, Arena *arena, Error *err)
|
||||
return (Float)table_props.val;
|
||||
}
|
||||
|
||||
/// Convert lua table to array without determining whether it is array
|
||||
/// Convert Lua table to array without determining whether it is array
|
||||
///
|
||||
/// @param lstate Lua state.
|
||||
/// @param[in] table_props nlua_traverse_table() output.
|
||||
@ -966,7 +965,7 @@ static Array nlua_pop_Array_unchecked(lua_State *const lstate, const LuaTablePro
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Convert lua table to array
|
||||
/// Convert Lua table to array
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
Array nlua_pop_Array(lua_State *lstate, Arena *arena, Error *err)
|
||||
@ -979,7 +978,7 @@ Array nlua_pop_Array(lua_State *lstate, Arena *arena, Error *err)
|
||||
return nlua_pop_Array_unchecked(lstate, table_props, arena, err);
|
||||
}
|
||||
|
||||
/// Convert lua table to dictionary
|
||||
/// Convert Lua table to dictionary
|
||||
///
|
||||
/// Always pops one value from the stack. Does not check whether whether topmost
|
||||
/// value on the stack is a table.
|
||||
@ -987,11 +986,11 @@ Array nlua_pop_Array(lua_State *lstate, Arena *arena, Error *err)
|
||||
/// @param lstate Lua interpreter state.
|
||||
/// @param[in] table_props nlua_traverse_table() output.
|
||||
/// @param[out] err Location where error will be saved.
|
||||
static Dictionary nlua_pop_Dictionary_unchecked(lua_State *lstate, const LuaTableProps table_props,
|
||||
bool ref, Arena *arena, Error *err)
|
||||
static Dict nlua_pop_Dict_unchecked(lua_State *lstate, const LuaTableProps table_props, bool ref,
|
||||
Arena *arena, Error *err)
|
||||
FUNC_ATTR_NONNULL_ARG(1, 5) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
Dictionary ret = arena_dict(arena, table_props.string_keys_num);
|
||||
Dict ret = arena_dict(arena, table_props.string_keys_num);
|
||||
|
||||
if (table_props.string_keys_num == 0) {
|
||||
lua_pop(lstate, 1);
|
||||
@ -1020,11 +1019,11 @@ static Dictionary nlua_pop_Dictionary_unchecked(lua_State *lstate, const LuaTabl
|
||||
|
||||
if (ERROR_SET(err)) {
|
||||
if (!arena) {
|
||||
api_free_dictionary(ret);
|
||||
api_free_dict(ret);
|
||||
}
|
||||
lua_pop(lstate, 2);
|
||||
// stack:
|
||||
return (Dictionary) { .size = 0, .items = NULL };
|
||||
return (Dict) { .size = 0, .items = NULL };
|
||||
}
|
||||
i++;
|
||||
} else {
|
||||
@ -1037,20 +1036,20 @@ static Dictionary nlua_pop_Dictionary_unchecked(lua_State *lstate, const LuaTabl
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Convert lua table to dictionary
|
||||
/// Convert Lua table to dictionary
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
Dictionary nlua_pop_Dictionary(lua_State *lstate, bool ref, Arena *arena, Error *err)
|
||||
Dict nlua_pop_Dict(lua_State *lstate, bool ref, Arena *arena, Error *err)
|
||||
FUNC_ATTR_NONNULL_ARG(1, 4) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||
{
|
||||
const LuaTableProps table_props = nlua_check_type(lstate, err,
|
||||
kObjectTypeDictionary);
|
||||
if (table_props.type != kObjectTypeDictionary) {
|
||||
kObjectTypeDict);
|
||||
if (table_props.type != kObjectTypeDict) {
|
||||
lua_pop(lstate, 1);
|
||||
return (Dictionary) { .size = 0, .items = NULL };
|
||||
return (Dict) { .size = 0, .items = NULL };
|
||||
}
|
||||
|
||||
return nlua_pop_Dictionary_unchecked(lstate, table_props, ref, arena, err);
|
||||
return nlua_pop_Dict_unchecked(lstate, table_props, ref, arena, err);
|
||||
}
|
||||
|
||||
/// Helper structure for nlua_pop_Object
|
||||
@ -1059,7 +1058,7 @@ typedef struct {
|
||||
bool container; ///< True if tv is a container.
|
||||
} ObjPopStackItem;
|
||||
|
||||
/// Convert lua table to object
|
||||
/// Convert Lua table to object
|
||||
///
|
||||
/// Always pops one value from the stack.
|
||||
Object nlua_pop_Object(lua_State *const lstate, bool ref, Arena *arena, Error *const err)
|
||||
@ -1077,9 +1076,9 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Arena *arena, Error *c
|
||||
api_set_error(err, kErrorTypeException, "Lua failed to grow stack");
|
||||
break;
|
||||
}
|
||||
if (cur.obj->type == kObjectTypeDictionary) {
|
||||
if (cur.obj->type == kObjectTypeDict) {
|
||||
// stack: …, dict, key
|
||||
if (cur.obj->data.dictionary.size == cur.obj->data.dictionary.capacity) {
|
||||
if (cur.obj->data.dict.size == cur.obj->data.dict.capacity) {
|
||||
lua_pop(lstate, 2);
|
||||
continue;
|
||||
}
|
||||
@ -1097,10 +1096,10 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Arena *arena, Error *c
|
||||
// stack: …, dict, new key, val
|
||||
size_t len;
|
||||
const char *s = lua_tolstring(lstate, -2, &len);
|
||||
const size_t idx = cur.obj->data.dictionary.size++;
|
||||
cur.obj->data.dictionary.items[idx].key = CBUF_TO_ARENA_STR(arena, s, len);
|
||||
const size_t idx = cur.obj->data.dict.size++;
|
||||
cur.obj->data.dict.items[idx].key = CBUF_TO_ARENA_STR(arena, s, len);
|
||||
kvi_push(stack, cur);
|
||||
cur = (ObjPopStackItem){ .obj = &cur.obj->data.dictionary.items[idx].value };
|
||||
cur = (ObjPopStackItem){ .obj = &cur.obj->data.dict.items[idx].value };
|
||||
} else {
|
||||
// stack: …, dict
|
||||
lua_pop(lstate, 1);
|
||||
@ -1154,10 +1153,10 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Arena *arena, Error *c
|
||||
kvi_push(stack, cur);
|
||||
}
|
||||
break;
|
||||
case kObjectTypeDictionary:
|
||||
*cur.obj = DICTIONARY_OBJ(((Dictionary)ARRAY_DICT_INIT));
|
||||
case kObjectTypeDict:
|
||||
*cur.obj = DICT_OBJ(((Dict)ARRAY_DICT_INIT));
|
||||
if (table_props.string_keys_num != 0) {
|
||||
cur.obj->data.dictionary = arena_dict(arena, table_props.string_keys_num);
|
||||
cur.obj->data.dict = arena_dict(arena, table_props.string_keys_num);
|
||||
cur.container = true;
|
||||
kvi_push(stack, cur);
|
||||
lua_pushnil(lstate);
|
||||
@ -1191,16 +1190,14 @@ Object nlua_pop_Object(lua_State *const lstate, bool ref, Arena *arena, Error *c
|
||||
if (is_nil) {
|
||||
*cur.obj = NIL;
|
||||
} else {
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
"Cannot convert userdata");
|
||||
api_set_error(err, kErrorTypeValidation, "Cannot convert userdata");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
type_error:
|
||||
api_set_error(err, kErrorTypeValidation,
|
||||
"Cannot convert given lua type");
|
||||
api_set_error(err, kErrorTypeValidation, "Cannot convert given Lua type");
|
||||
break;
|
||||
}
|
||||
if (!cur.container) {
|
||||
@ -1278,16 +1275,16 @@ void nlua_init_types(lua_State *const lstate)
|
||||
lua_rawset(lstate, -3);
|
||||
|
||||
LUA_PUSH_STATIC_STRING(lstate, "dictionary");
|
||||
lua_pushnumber(lstate, (lua_Number)kObjectTypeDictionary);
|
||||
lua_pushnumber(lstate, (lua_Number)kObjectTypeDict);
|
||||
lua_rawset(lstate, -3);
|
||||
lua_pushnumber(lstate, (lua_Number)kObjectTypeDictionary);
|
||||
lua_pushnumber(lstate, (lua_Number)kObjectTypeDict);
|
||||
LUA_PUSH_STATIC_STRING(lstate, "dictionary");
|
||||
lua_rawset(lstate, -3);
|
||||
|
||||
lua_rawset(lstate, -3);
|
||||
}
|
||||
|
||||
// lua specific variant of api_dict_to_keydict
|
||||
// Lua specific variant of api_dict_to_keydict
|
||||
void nlua_pop_keydict(lua_State *L, void *retval, FieldHashfn hashy, char **err_opt, Arena *arena,
|
||||
Error *err)
|
||||
{
|
||||
@ -1337,8 +1334,8 @@ void nlua_pop_keydict(lua_State *L, void *retval, FieldHashfn hashy, char **err_
|
||||
*(handle_T *)mem = nlua_pop_handle(L, arena, err);
|
||||
} else if (field->type == kObjectTypeArray) {
|
||||
*(Array *)mem = nlua_pop_Array(L, arena, err);
|
||||
} else if (field->type == kObjectTypeDictionary) {
|
||||
*(Dictionary *)mem = nlua_pop_Dictionary(L, false, arena, err);
|
||||
} else if (field->type == kObjectTypeDict) {
|
||||
*(Dict *)mem = nlua_pop_Dict(L, false, arena, err);
|
||||
} else if (field->type == kObjectTypeLuaRef) {
|
||||
*(LuaRef *)mem = nlua_pop_LuaRef(L, arena, err);
|
||||
} else {
|
||||
@ -1387,8 +1384,8 @@ void nlua_push_keydict(lua_State *L, void *value, KeySetLink *table)
|
||||
nlua_push_String(L, *(String *)mem, 0);
|
||||
} else if (field->type == kObjectTypeArray) {
|
||||
nlua_push_Array(L, *(Array *)mem, 0);
|
||||
} else if (field->type == kObjectTypeDictionary) {
|
||||
nlua_push_Dictionary(L, *(Dictionary *)mem, 0);
|
||||
} else if (field->type == kObjectTypeDict) {
|
||||
nlua_push_Dict(L, *(Dict *)mem, 0);
|
||||
} else if (field->type == kObjectTypeLuaRef) {
|
||||
nlua_pushref(L, *(LuaRef *)mem);
|
||||
} else {
|
||||
|
@ -967,8 +967,8 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
|
||||
os_exit(2);
|
||||
}
|
||||
|
||||
if (o.type == kObjectTypeDictionary) {
|
||||
rvobj.data.dictionary = o.data.dictionary;
|
||||
if (o.type == kObjectTypeDict) {
|
||||
rvobj.data.dict = o.data.dict;
|
||||
} else {
|
||||
fprintf(stderr, "vim._cs_remote returned unexpected value\n");
|
||||
os_exit(2);
|
||||
@ -977,32 +977,32 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
|
||||
TriState should_exit = kNone;
|
||||
TriState tabbed = kNone;
|
||||
|
||||
for (size_t i = 0; i < rvobj.data.dictionary.size; i++) {
|
||||
if (strequal(rvobj.data.dictionary.items[i].key.data, "errmsg")) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) {
|
||||
for (size_t i = 0; i < rvobj.data.dict.size; i++) {
|
||||
if (strequal(rvobj.data.dict.items[i].key.data, "errmsg")) {
|
||||
if (rvobj.data.dict.items[i].value.type != kObjectTypeString) {
|
||||
fprintf(stderr, "vim._cs_remote returned an unexpected type for 'errmsg'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
fprintf(stderr, "%s\n", rvobj.data.dictionary.items[i].value.data.string.data);
|
||||
fprintf(stderr, "%s\n", rvobj.data.dict.items[i].value.data.string.data);
|
||||
os_exit(2);
|
||||
} else if (strequal(rvobj.data.dictionary.items[i].key.data, "result")) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) {
|
||||
} else if (strequal(rvobj.data.dict.items[i].key.data, "result")) {
|
||||
if (rvobj.data.dict.items[i].value.type != kObjectTypeString) {
|
||||
fprintf(stderr, "vim._cs_remote returned an unexpected type for 'result'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
printf("%s", rvobj.data.dictionary.items[i].value.data.string.data);
|
||||
} else if (strequal(rvobj.data.dictionary.items[i].key.data, "tabbed")) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) {
|
||||
printf("%s", rvobj.data.dict.items[i].value.data.string.data);
|
||||
} else if (strequal(rvobj.data.dict.items[i].key.data, "tabbed")) {
|
||||
if (rvobj.data.dict.items[i].value.type != kObjectTypeBoolean) {
|
||||
fprintf(stderr, "vim._cs_remote returned an unexpected type for 'tabbed'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
tabbed = rvobj.data.dictionary.items[i].value.data.boolean ? kTrue : kFalse;
|
||||
} else if (strequal(rvobj.data.dictionary.items[i].key.data, "should_exit")) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) {
|
||||
tabbed = rvobj.data.dict.items[i].value.data.boolean ? kTrue : kFalse;
|
||||
} else if (strequal(rvobj.data.dict.items[i].key.data, "should_exit")) {
|
||||
if (rvobj.data.dict.items[i].value.type != kObjectTypeBoolean) {
|
||||
fprintf(stderr, "vim._cs_remote returned an unexpected type for 'should_exit'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
should_exit = rvobj.data.dictionary.items[i].value.data.boolean ? kTrue : kFalse;
|
||||
should_exit = rvobj.data.dict.items[i].value.data.boolean ? kTrue : kFalse;
|
||||
}
|
||||
}
|
||||
if (should_exit == kNone || tabbed == kNone) {
|
||||
|
@ -2061,20 +2061,20 @@ void f_hasmapto(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
rettv->vval.v_number = map_to_exists(name, mode, abbr);
|
||||
}
|
||||
|
||||
/// Fill a Dictionary with all applicable maparg() like dictionaries
|
||||
/// Fill a Dict with all applicable maparg() like dictionaries
|
||||
///
|
||||
/// @param mp The maphash that contains the mapping information
|
||||
/// @param buffer_value The "buffer" value
|
||||
/// @param abbr True if abbreviation
|
||||
/// @param compatible True for compatible with old maparg() dict
|
||||
///
|
||||
/// @return A Dictionary.
|
||||
static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhsrawalt,
|
||||
/// @return Dict.
|
||||
static Dict mapblock_fill_dict(const mapblock_T *const mp, const char *lhsrawalt,
|
||||
const int buffer_value, const bool abbr, const bool compatible,
|
||||
Arena *arena)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
Dictionary dict = arena_dict(arena, 19);
|
||||
Dict dict = arena_dict(arena, 19);
|
||||
char *const lhs = str2special_arena(mp->m_keys, compatible, !compatible, arena);
|
||||
char *mapmode = arena_alloc(arena, 7, false);
|
||||
map_mode_to_chars(mp->m_mode, mapmode);
|
||||
@ -2193,9 +2193,9 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
// Return a dictionary.
|
||||
if (mp != NULL && (rhs != NULL || rhs_lua != LUA_NOREF)) {
|
||||
Arena arena = ARENA_EMPTY;
|
||||
Dictionary dict = mapblock_fill_dict(mp, did_simplify ? keys_simplified : NULL,
|
||||
Dict dict = mapblock_fill_dict(mp, did_simplify ? keys_simplified : NULL,
|
||||
buffer_local, abbr, true, &arena);
|
||||
object_to_vim_take_luaref(&DICTIONARY_OBJ(dict), rettv, true, NULL);
|
||||
object_to_vim_take_luaref(&DICT_OBJ(dict), rettv, true, NULL);
|
||||
arena_mem_free(arena_finish(&arena));
|
||||
} else {
|
||||
// Return an empty dictionary.
|
||||
@ -2406,10 +2406,10 @@ void f_maplist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
replace_termcodes(lhs, strlen(lhs), &keys_buf, 0, flags, &did_simplify,
|
||||
p_cpo);
|
||||
|
||||
Dictionary dict = mapblock_fill_dict(mp, did_simplify ? keys_buf : NULL,
|
||||
buffer_local, abbr, true, &arena);
|
||||
Dict dict = mapblock_fill_dict(mp, did_simplify ? keys_buf : NULL, buffer_local, abbr, true,
|
||||
&arena);
|
||||
typval_T d = TV_INITIAL_VALUE;
|
||||
object_to_vim_take_luaref(&DICTIONARY_OBJ(dict), &d, true, NULL);
|
||||
object_to_vim_take_luaref(&DICT_OBJ(dict), &d, true, NULL);
|
||||
assert(d.v_type == VAR_DICT);
|
||||
tv_list_append_dict(rettv->vval.v_list, d.vval.v_dict);
|
||||
arena_mem_free(arena_finish(&arena));
|
||||
@ -2814,7 +2814,7 @@ fail_and_free:
|
||||
/// @param mode The abbreviation for the mode
|
||||
/// @param buf The buffer to get the mapping array. NULL for global
|
||||
/// @returns Array of maparg()-like dictionaries describing mappings
|
||||
ArrayOf(Dictionary) keymap_array(String mode, buf_T *buf, Arena *arena)
|
||||
ArrayOf(Dict) keymap_array(String mode, buf_T *buf, Arena *arena)
|
||||
{
|
||||
ArrayBuilder mappings = KV_INITIAL_VALUE;
|
||||
kvi_init(mappings);
|
||||
@ -2843,7 +2843,7 @@ ArrayOf(Dictionary) keymap_array(String mode, buf_T *buf, Arena *arena)
|
||||
}
|
||||
// Check for correct mode
|
||||
if (int_mode & current_maphash->m_mode) {
|
||||
kvi_push(mappings, DICTIONARY_OBJ(mapblock_fill_dict(current_maphash, NULL, buffer_value,
|
||||
kvi_push(mappings, DICT_OBJ(mapblock_fill_dict(current_maphash, NULL, buffer_value,
|
||||
is_abbrev, false, arena)));
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ void rpc_start(Channel *channel)
|
||||
rpc->unpacker = xcalloc(1, sizeof *rpc->unpacker);
|
||||
unpacker_init(rpc->unpacker);
|
||||
rpc->next_request_id = 1;
|
||||
rpc->info = (Dictionary)ARRAY_DICT_INIT;
|
||||
rpc->info = (Dict)ARRAY_DICT_INIT;
|
||||
kv_init(rpc->call_stack);
|
||||
|
||||
if (channel->streamtype != kChannelStreamInternal) {
|
||||
@ -500,7 +500,7 @@ void rpc_free(Channel *channel)
|
||||
xfree(channel->rpc.unpacker);
|
||||
|
||||
kv_destroy(channel->rpc.call_stack);
|
||||
api_free_dictionary(channel->rpc.info);
|
||||
api_free_dict(channel->rpc.info);
|
||||
}
|
||||
|
||||
static void chan_close_with_error(Channel *channel, char *msg, int loglevel)
|
||||
@ -610,14 +610,14 @@ static void channel_flush_callback(PackerBuffer *packer)
|
||||
packer_buffer_init_channels(packer->anydata, (size_t)packer->anyint, packer);
|
||||
}
|
||||
|
||||
void rpc_set_client_info(uint64_t id, Dictionary info)
|
||||
void rpc_set_client_info(uint64_t id, Dict info)
|
||||
{
|
||||
Channel *chan = find_rpc_channel(id);
|
||||
if (!chan) {
|
||||
abort();
|
||||
}
|
||||
|
||||
api_free_dictionary(chan->rpc.info);
|
||||
api_free_dict(chan->rpc.info);
|
||||
chan->rpc.info = info;
|
||||
|
||||
// Parse "type" on "info" and set "client_type"
|
||||
@ -641,9 +641,9 @@ void rpc_set_client_info(uint64_t id, Dictionary info)
|
||||
channel_info_changed(chan, false);
|
||||
}
|
||||
|
||||
Dictionary rpc_client_info(Channel *chan)
|
||||
Dict rpc_client_info(Channel *chan)
|
||||
{
|
||||
return copy_dictionary(chan->rpc.info, NULL);
|
||||
return copy_dict(chan->rpc.info, NULL);
|
||||
}
|
||||
|
||||
const char *get_client_info(Channel *chan, const char *key)
|
||||
@ -652,7 +652,7 @@ const char *get_client_info(Channel *chan, const char *key)
|
||||
if (!chan->is_rpc) {
|
||||
return NULL;
|
||||
}
|
||||
Dictionary info = chan->rpc.info;
|
||||
Dict info = chan->rpc.info;
|
||||
for (size_t i = 0; i < info.size; i++) {
|
||||
if (strequal(key, info.items[i].key.data)
|
||||
&& info.items[i].value.type == kObjectTypeString) {
|
||||
|
@ -40,6 +40,6 @@ typedef struct {
|
||||
Unpacker *unpacker;
|
||||
uint32_t next_request_id;
|
||||
kvec_t(ChannelCallFrame *) call_stack;
|
||||
Dictionary info;
|
||||
Dict info;
|
||||
ClientType client_type;
|
||||
} RpcState;
|
||||
|
@ -226,14 +226,14 @@ void mpack_object_inner(Object *current, Object *container, size_t container_idx
|
||||
case kObjectTypeTabpage:
|
||||
mpack_handle(current->type, (handle_T)current->data.integer, packer);
|
||||
break;
|
||||
case kObjectTypeDictionary:
|
||||
case kObjectTypeDict:
|
||||
case kObjectTypeArray: {}
|
||||
size_t current_size;
|
||||
if (current->type == kObjectTypeArray) {
|
||||
current_size = current->data.array.size;
|
||||
mpack_array(&packer->ptr, (uint32_t)current_size);
|
||||
} else {
|
||||
current_size = current->data.dictionary.size;
|
||||
current_size = current->data.dict.size;
|
||||
mpack_map(&packer->ptr, (uint32_t)current_size);
|
||||
}
|
||||
if (current_size > 0) {
|
||||
@ -270,7 +270,7 @@ void mpack_object_inner(Object *current, Object *container, size_t container_idx
|
||||
container = NULL;
|
||||
}
|
||||
} else {
|
||||
Dictionary dict = container->data.dictionary;
|
||||
Dict dict = container->data.dict;
|
||||
KeyValuePair *it = &dict.items[container_idx++];
|
||||
mpack_check_buffer(packer);
|
||||
mpack_str(it->key, packer);
|
||||
|
@ -59,7 +59,7 @@ static void api_parse_enter(mpack_parser_t *parser, mpack_node_t *node)
|
||||
}
|
||||
case MPACK_TOKEN_MAP: {
|
||||
Object *obj = parent->data[0].p;
|
||||
KeyValuePair *kv = &kv_A(obj->data.dictionary, parent->pos);
|
||||
KeyValuePair *kv = &kv_A(obj->data.dict, parent->pos);
|
||||
if (!parent->key_visited) {
|
||||
// TODO(bfredl): when implementing interrupt parse on error,
|
||||
// stop parsing here when node is not a STR/BIN
|
||||
@ -166,10 +166,10 @@ static void api_parse_enter(mpack_parser_t *parser, mpack_node_t *node)
|
||||
break;
|
||||
}
|
||||
case MPACK_TOKEN_MAP: {
|
||||
Dictionary dict = KV_INITIAL_VALUE;
|
||||
Dict dict = KV_INITIAL_VALUE;
|
||||
kv_fixsize_arena(&p->arena, dict, node->tok.length);
|
||||
kv_size(dict) = node->tok.length;
|
||||
*result = DICTIONARY_OBJ(dict);
|
||||
*result = DICT_OBJ(dict);
|
||||
node->data[0].p = result;
|
||||
break;
|
||||
}
|
||||
@ -620,7 +620,7 @@ bool unpack_keydict(void *retval, FieldHashfn hashy, AdditionalDataBuilder *ad,
|
||||
|
||||
int result = mpack_rtoken(data, size, &tok);
|
||||
if (result || tok.type != MPACK_TOKEN_MAP) {
|
||||
*error = xstrdup("is not a dictionary");
|
||||
*error = xstrdup("is not a dict");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -6438,30 +6438,29 @@ int get_sidescrolloff_value(win_T *wp)
|
||||
return (int)(wp->w_p_siso < 0 ? p_siso : wp->w_p_siso);
|
||||
}
|
||||
|
||||
Dictionary get_vimoption(String name, int scope, buf_T *buf, win_T *win, Arena *arena, Error *err)
|
||||
Dict get_vimoption(String name, int scope, buf_T *buf, win_T *win, Arena *arena, Error *err)
|
||||
{
|
||||
OptIndex opt_idx = find_option_len(name.data, name.size);
|
||||
VALIDATE_S(opt_idx != kOptInvalid, "option (not found)", name.data, {
|
||||
return (Dictionary)ARRAY_DICT_INIT;
|
||||
return (Dict)ARRAY_DICT_INIT;
|
||||
});
|
||||
|
||||
return vimoption2dict(&options[opt_idx], scope, buf, win, arena);
|
||||
}
|
||||
|
||||
Dictionary get_all_vimoptions(Arena *arena)
|
||||
Dict get_all_vimoptions(Arena *arena)
|
||||
{
|
||||
Dictionary retval = arena_dict(arena, kOptIndexCount);
|
||||
Dict retval = arena_dict(arena, kOptIndexCount);
|
||||
for (OptIndex opt_idx = 0; opt_idx < kOptIndexCount; opt_idx++) {
|
||||
Dictionary opt_dict = vimoption2dict(&options[opt_idx], OPT_GLOBAL, curbuf, curwin, arena);
|
||||
PUT_C(retval, options[opt_idx].fullname, DICTIONARY_OBJ(opt_dict));
|
||||
Dict opt_dict = vimoption2dict(&options[opt_idx], OPT_GLOBAL, curbuf, curwin, arena);
|
||||
PUT_C(retval, options[opt_idx].fullname, DICT_OBJ(opt_dict));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static Dictionary vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win,
|
||||
Arena *arena)
|
||||
static Dict vimoption2dict(vimoption_T *opt, int req_scope, buf_T *buf, win_T *win, Arena *arena)
|
||||
{
|
||||
Dictionary dict = arena_dict(arena, 13);
|
||||
Dict dict = arena_dict(arena, 13);
|
||||
|
||||
PUT_C(dict, "name", CSTR_AS_OBJ(opt->fullname));
|
||||
PUT_C(dict, "shortname", CSTR_AS_OBJ(opt->shortname));
|
||||
|
@ -230,9 +230,9 @@ int os_proc_children(int ppid, int **proc_list, size_t *proc_count)
|
||||
///
|
||||
/// @param pid Process to inspect.
|
||||
/// @return Map of process properties, empty on error.
|
||||
Dictionary os_proc_info(int pid, Arena *arena)
|
||||
Dict os_proc_info(int pid, Arena *arena)
|
||||
{
|
||||
Dictionary pinfo = ARRAY_DICT_INIT;
|
||||
Dict pinfo = ARRAY_DICT_INIT;
|
||||
PROCESSENTRY32 pe;
|
||||
|
||||
// Snapshot of all processes. This is used instead of:
|
||||
|
@ -231,7 +231,7 @@ typedef struct {
|
||||
ShadaEntryType type;
|
||||
Timestamp timestamp;
|
||||
union {
|
||||
Dictionary header;
|
||||
Dict header;
|
||||
struct shada_filemark {
|
||||
char name;
|
||||
pos_T mark;
|
||||
@ -812,7 +812,7 @@ static inline void hms_dealloc(HistoryMergerState *const hms_p)
|
||||
|
||||
/// Iterate over global variables
|
||||
///
|
||||
/// @warning No modifications to global variable dictionary must be performed
|
||||
/// @warning No modifications to global variable Dict must be performed
|
||||
/// while iteration is in progress.
|
||||
///
|
||||
/// @param[in] iter Iterator. Pass NULL to start iteration.
|
||||
@ -2911,7 +2911,7 @@ static void shada_free_shada_entry(ShadaEntry *const entry)
|
||||
xfree(entry->data.unknown_item.contents);
|
||||
break;
|
||||
case kSDItemHeader:
|
||||
api_free_dictionary(entry->data.header);
|
||||
api_free_dict(entry->data.header);
|
||||
break;
|
||||
case kSDItemChange:
|
||||
case kSDItemJump:
|
||||
@ -3230,7 +3230,7 @@ shada_read_next_item_start:
|
||||
case kSDItemHeader:
|
||||
// TODO(bfredl): header is written to file and provides useful debugging
|
||||
// info. It is never read by nvim (earlier we parsed it back to a
|
||||
// Dictionary, but that value was never used)
|
||||
// Dict, but that value was never used)
|
||||
break;
|
||||
case kSDItemSearchPattern: {
|
||||
Dict(_shada_search_pat) *it = &entry->data.search_pattern;
|
||||
|
@ -648,14 +648,14 @@ static void ui_ext_tabline_update(void)
|
||||
|
||||
Array tabs = arena_array(&arena, n_tabs);
|
||||
FOR_ALL_TABS(tp) {
|
||||
Dictionary tab_info = arena_dict(&arena, 2);
|
||||
Dict tab_info = arena_dict(&arena, 2);
|
||||
PUT_C(tab_info, "tab", TABPAGE_OBJ(tp->handle));
|
||||
|
||||
win_T *cwp = (tp == curtab) ? curwin : tp->tp_curwin;
|
||||
get_trans_bufname(cwp->w_buffer);
|
||||
PUT_C(tab_info, "name", CSTR_TO_ARENA_OBJ(&arena, NameBuff));
|
||||
|
||||
ADD_C(tabs, DICTIONARY_OBJ(tab_info));
|
||||
ADD_C(tabs, DICT_OBJ(tab_info));
|
||||
}
|
||||
|
||||
size_t n_buffers = 0;
|
||||
@ -670,13 +670,13 @@ static void ui_ext_tabline_update(void)
|
||||
continue;
|
||||
}
|
||||
|
||||
Dictionary buffer_info = arena_dict(&arena, 2);
|
||||
Dict buffer_info = arena_dict(&arena, 2);
|
||||
PUT_C(buffer_info, "buffer", BUFFER_OBJ(buf->handle));
|
||||
|
||||
get_trans_bufname(buf);
|
||||
PUT_C(buffer_info, "name", CSTR_TO_ARENA_OBJ(&arena, NameBuff));
|
||||
|
||||
ADD_C(buffers, DICTIONARY_OBJ(buffer_info));
|
||||
ADD_C(buffers, DICT_OBJ(buffer_info));
|
||||
}
|
||||
|
||||
ui_call_tabline_update(curtab->handle, tabs, curbuf->handle, buffers);
|
||||
|
@ -1199,7 +1199,7 @@ static CursorShape tui_cursor_decode_shape(const char *shape_str)
|
||||
return shape;
|
||||
}
|
||||
|
||||
static cursorentry_T decode_cursor_entry(Dictionary args)
|
||||
static cursorentry_T decode_cursor_entry(Dict args)
|
||||
{
|
||||
cursorentry_T r = shape_table[0];
|
||||
|
||||
@ -1231,8 +1231,8 @@ void tui_mode_info_set(TUIData *tui, bool guicursor_enabled, Array args)
|
||||
|
||||
// cursor style entries as defined by `shape_table`.
|
||||
for (size_t i = 0; i < args.size; i++) {
|
||||
assert(args.items[i].type == kObjectTypeDictionary);
|
||||
cursorentry_T r = decode_cursor_entry(args.items[i].data.dictionary);
|
||||
assert(args.items[i].type == kObjectTypeDict);
|
||||
cursorentry_T r = decode_cursor_entry(args.items[i].data.dict);
|
||||
tui->cursor_shapes[i] = r;
|
||||
}
|
||||
|
||||
@ -1539,7 +1539,7 @@ static void show_verbose_terminfo(TUIData *tui)
|
||||
ADD_C(args, BOOLEAN_OBJ(true)); // history
|
||||
MAXSIZE_TEMP_DICT(opts, 1);
|
||||
PUT_C(opts, "verbose", BOOLEAN_OBJ(true));
|
||||
ADD_C(args, DICTIONARY_OBJ(opts));
|
||||
ADD_C(args, DICT_OBJ(opts));
|
||||
rpc_send_event(ui_client_channel_id, "nvim_echo", args);
|
||||
xfree(str.data);
|
||||
}
|
||||
|
@ -659,7 +659,7 @@ Array ui_array(Arena *arena)
|
||||
Array all_uis = arena_array(arena, ui_count);
|
||||
for (size_t i = 0; i < ui_count; i++) {
|
||||
RemoteUI *ui = uis[i];
|
||||
Dictionary info = arena_dict(arena, 10 + kUIExtCount);
|
||||
Dict info = arena_dict(arena, 10 + kUIExtCount);
|
||||
PUT_C(info, "width", INTEGER_OBJ(ui->width));
|
||||
PUT_C(info, "height", INTEGER_OBJ(ui->height));
|
||||
PUT_C(info, "rgb", BOOLEAN_OBJ(ui->rgb));
|
||||
@ -682,7 +682,7 @@ Array ui_array(Arena *arena)
|
||||
}
|
||||
PUT_C(info, "chan", INTEGER_OBJ((Integer)ui->channel_id));
|
||||
|
||||
ADD_C(all_uis, DICTIONARY_OBJ(info));
|
||||
ADD_C(all_uis, DICT_OBJ(info));
|
||||
}
|
||||
return all_uis;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ void ui_client_attach(int width, int height, char *term, bool rgb)
|
||||
ui_client_forward_stdin = false; // stdin shouldn't be forwarded again #22292
|
||||
}
|
||||
}
|
||||
ADD_C(args, DICTIONARY_OBJ(opts));
|
||||
ADD_C(args, DICT_OBJ(opts));
|
||||
|
||||
rpc_send_event(ui_client_channel_id, "nvim_ui_attach", args);
|
||||
ui_client_attached = true;
|
||||
@ -120,17 +120,17 @@ void ui_client_attach(int width, int height, char *term, bool rgb)
|
||||
MAXSIZE_TEMP_ARRAY(args2, 5);
|
||||
ADD_C(args2, CSTR_AS_OBJ("nvim-tui")); // name
|
||||
Object m = api_metadata();
|
||||
Dictionary version = { 0 };
|
||||
assert(m.data.dictionary.size > 0);
|
||||
for (size_t i = 0; i < m.data.dictionary.size; i++) {
|
||||
if (strequal(m.data.dictionary.items[i].key.data, "version")) {
|
||||
version = m.data.dictionary.items[i].value.data.dictionary;
|
||||
Dict version = { 0 };
|
||||
assert(m.data.dict.size > 0);
|
||||
for (size_t i = 0; i < m.data.dict.size; i++) {
|
||||
if (strequal(m.data.dict.items[i].key.data, "version")) {
|
||||
version = m.data.dict.items[i].value.data.dict;
|
||||
break;
|
||||
} else if (i + 1 == m.data.dictionary.size) {
|
||||
} else if (i + 1 == m.data.dict.size) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
ADD_C(args2, DICTIONARY_OBJ(version)); // version
|
||||
ADD_C(args2, DICT_OBJ(version)); // version
|
||||
ADD_C(args2, CSTR_AS_OBJ("ui")); // type
|
||||
// We don't send api_metadata.functions as the "methods" because:
|
||||
// 1. it consumes memory.
|
||||
@ -141,7 +141,7 @@ void ui_client_attach(int width, int height, char *term, bool rgb)
|
||||
PUT_C(info, "website", CSTR_AS_OBJ("https://neovim.io"));
|
||||
PUT_C(info, "license", CSTR_AS_OBJ("Apache 2"));
|
||||
PUT_C(info, "pid", INTEGER_OBJ(os_get_pid()));
|
||||
ADD_C(args2, DICTIONARY_OBJ(info)); // attributes
|
||||
ADD_C(args2, DICT_OBJ(info)); // attributes
|
||||
rpc_send_event(ui_client_channel_id, "nvim_set_client_info", args2);
|
||||
|
||||
TIME_MSG("nvim_set_client_info");
|
||||
@ -215,7 +215,7 @@ Object handle_ui_client_redraw(uint64_t channel_id, Array args, Arena *arena, Er
|
||||
return NIL;
|
||||
}
|
||||
|
||||
static HlAttrs ui_client_dict2hlattrs(Dictionary d, bool rgb)
|
||||
static HlAttrs ui_client_dict2hlattrs(Dict d, bool rgb)
|
||||
{
|
||||
Error err = ERROR_INIT;
|
||||
Dict(highlight) dict = KEYDICT_INIT;
|
||||
|
@ -1743,14 +1743,14 @@ int do_ucmd(exarg_T *eap, bool preview)
|
||||
/// @param buf Buffer to inspect, or NULL to get global commands.
|
||||
///
|
||||
/// @return Map of maps describing commands
|
||||
Dictionary commands_array(buf_T *buf, Arena *arena)
|
||||
Dict commands_array(buf_T *buf, Arena *arena)
|
||||
{
|
||||
garray_T *gap = (buf == NULL) ? &ucmds : &buf->b_ucmds;
|
||||
|
||||
Dictionary rv = arena_dict(arena, (size_t)gap->ga_len);
|
||||
Dict rv = arena_dict(arena, (size_t)gap->ga_len);
|
||||
for (int i = 0; i < gap->ga_len; i++) {
|
||||
char arg[2] = { 0, 0 };
|
||||
Dictionary d = arena_dict(arena, 14);
|
||||
Dict d = arena_dict(arena, 14);
|
||||
ucmd_T *cmd = USER_CMD_GA(gap, i);
|
||||
|
||||
PUT_C(d, "name", CSTR_AS_OBJ(cmd->uc_name));
|
||||
@ -1814,7 +1814,7 @@ Dictionary commands_array(buf_T *buf, Arena *arena)
|
||||
}
|
||||
PUT_C(d, "addr", obj);
|
||||
|
||||
PUT_C(rv, cmd->uc_name, DICTIONARY_OBJ(d));
|
||||
PUT_C(rv, cmd->uc_name, DICT_OBJ(d));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -3005,8 +3005,7 @@ viml_pexpr_parse_end:
|
||||
break;
|
||||
case kExprNodeCurlyBracesIdentifier:
|
||||
// Until trailing "}" it is impossible to distinguish curly braces
|
||||
// identifier and dictionary, so it must not appear in the stack like
|
||||
// this.
|
||||
// identifier and Dict, so it must not appear in the stack like this.
|
||||
abort();
|
||||
case kExprNodeInteger:
|
||||
case kExprNodeFloat:
|
||||
|
@ -216,7 +216,7 @@ typedef enum {
|
||||
/// kExprNodeCurlyBracesIdentifier.
|
||||
kExprNodeUnknownFigure,
|
||||
kExprNodeLambda, ///< Lambda.
|
||||
kExprNodeDictLiteral, ///< Dictionary literal.
|
||||
kExprNodeDictLiteral, ///< Dict literal.
|
||||
kExprNodeCurlyBracesIdentifier, ///< Part of the curly braces name.
|
||||
kExprNodeComma, ///< Comma “operator”.
|
||||
kExprNodeColon, ///< Colon “operator”.
|
||||
|
@ -58,10 +58,18 @@ describe('api metadata', function()
|
||||
return by_name
|
||||
end
|
||||
|
||||
-- Remove metadata that is not essential to backwards-compatibility.
|
||||
local function filter_function_metadata(f)
|
||||
-- Remove or patch metadata that is not essential to backwards-compatibility.
|
||||
local function normalize_func_metadata(f)
|
||||
-- Dictionary was renamed to Dict. That doesn't break back-compat because clients don't actually
|
||||
-- use the `return_type` field (evidence: "ArrayOf(…)" didn't break clients).
|
||||
f.return_type = f.return_type:gsub('Dictionary', 'Dict')
|
||||
|
||||
f.deprecated_since = nil
|
||||
for idx, _ in ipairs(f.parameters) do
|
||||
-- Dictionary was renamed to Dict. Doesn't break back-compat because clients don't actually
|
||||
-- use the `parameters` field of API metadata (evidence: "ArrayOf(…)" didn't break clients).
|
||||
f.parameters[idx][1] = f.parameters[idx][1]:gsub('Dictionary', 'Dict')
|
||||
|
||||
f.parameters[idx][2] = '' -- Remove parameter name.
|
||||
end
|
||||
|
||||
@ -141,7 +149,7 @@ describe('api metadata', function()
|
||||
)
|
||||
end
|
||||
else
|
||||
eq(filter_function_metadata(f), filter_function_metadata(funcs_new[f.name]))
|
||||
eq(normalize_func_metadata(f), normalize_func_metadata(funcs_new[f.name]))
|
||||
end
|
||||
end
|
||||
funcs_compat[level] = name_table(old_api[level].functions)
|
||||
|
@ -693,7 +693,7 @@ describe('API', function()
|
||||
pcall_err(request, 'nvim_call_dict_function', "{ 'f': '' }", 'f', { 1, 2 })
|
||||
)
|
||||
eq(
|
||||
'dict argument type must be String or Dictionary',
|
||||
'dict argument type must be String or Dict',
|
||||
pcall_err(request, 'nvim_call_dict_function', 42, 'f', { 1, 2 })
|
||||
)
|
||||
eq(
|
||||
@ -1573,7 +1573,7 @@ describe('API', function()
|
||||
|
||||
it('nvim_get_vvar, nvim_set_vvar', function()
|
||||
eq('Key is read-only: count', pcall_err(request, 'nvim_set_vvar', 'count', 42))
|
||||
eq('Dictionary is locked', pcall_err(request, 'nvim_set_vvar', 'nosuchvar', 42))
|
||||
eq('Dict is locked', pcall_err(request, 'nvim_set_vvar', 'nosuchvar', 42))
|
||||
api.nvim_set_vvar('errmsg', 'set by API')
|
||||
eq('set by API', api.nvim_get_vvar('errmsg'))
|
||||
api.nvim_set_vvar('completed_item', { word = 'a', user_data = vim.empty_dict() })
|
||||
@ -2212,7 +2212,7 @@ describe('API', function()
|
||||
end)
|
||||
|
||||
describe('nvim_load_context', function()
|
||||
it('sets current editor state to given context dictionary', function()
|
||||
it('sets current editor state to given context dict', function()
|
||||
local opts = { types = { 'regs', 'jumps', 'bufs', 'gvars' } }
|
||||
eq({}, parse_context(api.nvim_get_context(opts)))
|
||||
|
||||
@ -2228,7 +2228,7 @@ describe('API', function()
|
||||
eq({ 1, 2, 3 }, eval('[g:one, g:Two, g:THREE]'))
|
||||
end)
|
||||
|
||||
it('errors when context dictionary is invalid', function()
|
||||
it('errors when context dict is invalid', function()
|
||||
eq(
|
||||
'E474: Failed to convert list to msgpack string buffer',
|
||||
pcall_err(api.nvim_load_context, { regs = { {} }, jumps = { {} } })
|
||||
|
@ -224,42 +224,39 @@ describe('luaeval(vim.api.…)', function()
|
||||
end)
|
||||
|
||||
it('correctly converts dictionaries with type_idx to API objects', function()
|
||||
eq(
|
||||
4,
|
||||
eval([[type(luaeval('vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary})'))]])
|
||||
)
|
||||
eq(4, eval([[type(luaeval('vim.api.nvim__id_dict({[vim.type_idx]=vim.types.dictionary})'))]]))
|
||||
|
||||
eq({}, fn.luaeval('vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary})'))
|
||||
eq({}, fn.luaeval('vim.api.nvim__id_dict({[vim.type_idx]=vim.types.dictionary})'))
|
||||
|
||||
eq(
|
||||
{ v = { 42 } },
|
||||
fn.luaeval(
|
||||
'vim.api.nvim__id_dictionary({v={[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
|
||||
'vim.api.nvim__id_dict({v={[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
|
||||
)
|
||||
)
|
||||
eq(
|
||||
{ foo = 2 },
|
||||
fn.luaeval(
|
||||
'vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
|
||||
'vim.api.nvim__id_dict({[vim.type_idx]=vim.types.dictionary, [vim.val_idx]=10, [5]=1, foo=2, [1]=42})'
|
||||
)
|
||||
)
|
||||
eq(
|
||||
{ v = 10 },
|
||||
fn.luaeval(
|
||||
'vim.api.nvim__id_dictionary({v={[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
|
||||
'vim.api.nvim__id_dict({v={[vim.type_idx]=vim.types.float, [vim.val_idx]=10, [5]=1, foo=2, [1]=42}})'
|
||||
)
|
||||
)
|
||||
eq(
|
||||
{ v = {} },
|
||||
fn.luaeval(
|
||||
'vim.api.nvim__id_dictionary({v={[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2}})'
|
||||
'vim.api.nvim__id_dict({v={[vim.type_idx]=vim.types.array, [vim.val_idx]=10, [5]=1, foo=2}})'
|
||||
)
|
||||
)
|
||||
|
||||
-- If API requests dictionary, then empty table will be the one. This is not
|
||||
-- If API requests dict, then empty table will be the one. This is not
|
||||
-- the case normally because empty table is an empty array.
|
||||
eq({}, fn.luaeval('vim.api.nvim__id_dictionary({})'))
|
||||
eq(4, eval([[type(luaeval('vim.api.nvim__id_dictionary({})'))]]))
|
||||
eq({}, fn.luaeval('vim.api.nvim__id_dict({})'))
|
||||
eq(4, eval([[type(luaeval('vim.api.nvim__id_dict({})'))]]))
|
||||
end)
|
||||
|
||||
it('converts booleans in positional args', function()
|
||||
@ -365,12 +362,12 @@ describe('luaeval(vim.api.…)', function()
|
||||
|
||||
eq(
|
||||
[[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'dct': Expected Lua table]],
|
||||
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_dictionary(1)")]]))
|
||||
remove_trace(exc_exec([[call luaeval("vim.api.nvim__id_dict(1)")]]))
|
||||
)
|
||||
eq(
|
||||
[[Vim(call):E5108: Error executing lua [string "luaeval()"]:1: Invalid 'dct': Expected Dict-like Lua table]],
|
||||
remove_trace(
|
||||
exc_exec([[call luaeval("vim.api.nvim__id_dictionary({[vim.type_idx]=vim.types.array})")]])
|
||||
exc_exec([[call luaeval("vim.api.nvim__id_dict({[vim.type_idx]=vim.types.array})")]])
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -186,7 +186,7 @@ describe('luaeval()', function()
|
||||
end)
|
||||
|
||||
it('issues an error in some cases', function()
|
||||
eq("Vim(call):E5100: Cannot convert given lua table: table should contain either only integer keys or only string keys",
|
||||
eq("Vim(call):E5100: Cannot convert given Lua table: table should contain either only integer keys or only string keys",
|
||||
exc_exec('call luaeval("{1, foo=2}")'))
|
||||
|
||||
startswith("Vim(call):E5107: Error loading lua [string \"luaeval()\"]:",
|
||||
|
@ -1229,7 +1229,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('vim.fn should error when calling API function', function()
|
||||
it('vim.fn errors when calling API function', function()
|
||||
matches(
|
||||
'Tried to call API function with vim.fn: use vim.api.nvim_get_current_line instead',
|
||||
pcall_err(exec_lua, 'vim.fn.nvim_get_current_line()')
|
||||
@ -1947,7 +1947,7 @@ describe('lua stdlib', function()
|
||||
eq(NIL, fn.luaeval 'vim.v.null')
|
||||
matches([[attempt to index .* nil value]], pcall_err(exec_lua, 'return vim.v[0].progpath'))
|
||||
eq('Key is read-only: count', pcall_err(exec_lua, [[vim.v.count = 42]]))
|
||||
eq('Dictionary is locked', pcall_err(exec_lua, [[vim.v.nosuchvar = 42]]))
|
||||
eq('Dict is locked', pcall_err(exec_lua, [[vim.v.nosuchvar = 42]]))
|
||||
eq('Key is fixed: errmsg', pcall_err(exec_lua, [[vim.v.errmsg = nil]]))
|
||||
exec_lua([[vim.v.errmsg = 'set by Lua']])
|
||||
eq('set by Lua', eval('v:errmsg'))
|
||||
@ -2067,7 +2067,7 @@ describe('lua stdlib', function()
|
||||
-- TODO: We still need to write some tests for optlocal, opt and then getting the options
|
||||
-- Probably could also do some stuff with getting things from viml side as well to confirm behavior is the same.
|
||||
|
||||
it('should allow setting number values', function()
|
||||
it('allows setting number values', function()
|
||||
local scrolloff = exec_lua [[
|
||||
vim.opt.scrolloff = 10
|
||||
return vim.o.scrolloff
|
||||
@ -2075,7 +2075,7 @@ describe('lua stdlib', function()
|
||||
eq(10, scrolloff)
|
||||
end)
|
||||
|
||||
pending('should handle STUPID window things', function()
|
||||
pending('handles STUPID window things', function()
|
||||
local result = exec_lua [[
|
||||
local result = {}
|
||||
|
||||
@ -2088,7 +2088,7 @@ describe('lua stdlib', function()
|
||||
eq({}, result)
|
||||
end)
|
||||
|
||||
it('should allow setting tables', function()
|
||||
it('allows setting tables', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = { 'hello', 'world' }
|
||||
return vim.o.wildignore
|
||||
@ -2096,7 +2096,7 @@ describe('lua stdlib', function()
|
||||
eq('hello,world', wildignore)
|
||||
end)
|
||||
|
||||
it('should allow setting tables with shortnames', function()
|
||||
it('allows setting tables with shortnames', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wig = { 'hello', 'world' }
|
||||
return vim.o.wildignore
|
||||
@ -2104,7 +2104,7 @@ describe('lua stdlib', function()
|
||||
eq('hello,world', wildignore)
|
||||
end)
|
||||
|
||||
it('should error when you attempt to set string values to numeric options', function()
|
||||
it('errors when you attempt to set string values to numeric options', function()
|
||||
local result = exec_lua [[
|
||||
return {
|
||||
pcall(function() vim.opt.textwidth = 'hello world' end)
|
||||
@ -2114,7 +2114,7 @@ describe('lua stdlib', function()
|
||||
eq(false, result[1])
|
||||
end)
|
||||
|
||||
it('should error when you attempt to setlocal a global value', function()
|
||||
it('errors when you attempt to setlocal a global value', function()
|
||||
local result = exec_lua [[
|
||||
return pcall(function() vim.opt_local.clipboard = "hello" end)
|
||||
]]
|
||||
@ -2122,7 +2122,7 @@ describe('lua stdlib', function()
|
||||
eq(false, result)
|
||||
end)
|
||||
|
||||
it('should allow you to set boolean values', function()
|
||||
it('allows you to set boolean values', function()
|
||||
eq(
|
||||
{ true, false, true },
|
||||
exec_lua [[
|
||||
@ -2142,7 +2142,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should change current buffer values and defaults for global local values', function()
|
||||
it('changes current buffer values and defaults for global local values', function()
|
||||
local result = exec_lua [[
|
||||
local result = {}
|
||||
|
||||
@ -2181,7 +2181,7 @@ describe('lua stdlib', function()
|
||||
eq('', result[8])
|
||||
end)
|
||||
|
||||
it('should allow you to retrieve window opts even if they have not been set', function()
|
||||
it('allows you to retrieve window opts even if they have not been set', function()
|
||||
local result = exec_lua [[
|
||||
local result = {}
|
||||
table.insert(result, vim.opt.number:get())
|
||||
@ -2196,7 +2196,7 @@ describe('lua stdlib', function()
|
||||
eq({ false, false, true, true }, result)
|
||||
end)
|
||||
|
||||
it('should allow all sorts of string manipulation', function()
|
||||
it('allows all sorts of string manipulation', function()
|
||||
eq(
|
||||
{ 'hello', 'hello world', 'start hello world' },
|
||||
exec_lua [[
|
||||
@ -2217,7 +2217,7 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
|
||||
describe('option:get()', function()
|
||||
it('should work for boolean values', function()
|
||||
it('works for boolean values', function()
|
||||
eq(
|
||||
false,
|
||||
exec_lua [[
|
||||
@ -2227,7 +2227,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should work for number values', function()
|
||||
it('works for number values', function()
|
||||
local tabstop = exec_lua [[
|
||||
vim.opt.tabstop = 10
|
||||
return vim.opt.tabstop:get()
|
||||
@ -2236,7 +2236,7 @@ describe('lua stdlib', function()
|
||||
eq(10, tabstop)
|
||||
end)
|
||||
|
||||
it('should work for string values', function()
|
||||
it('works for string values', function()
|
||||
eq(
|
||||
'hello world',
|
||||
exec_lua [[
|
||||
@ -2246,7 +2246,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should work for set type flaglists', function()
|
||||
it('works for set type flaglists', function()
|
||||
local formatoptions = exec_lua [[
|
||||
vim.opt.formatoptions = 'tcro'
|
||||
return vim.opt.formatoptions:get()
|
||||
@ -2256,7 +2256,7 @@ describe('lua stdlib', function()
|
||||
eq(true, not formatoptions.q)
|
||||
end)
|
||||
|
||||
it('should work for set type flaglists', function()
|
||||
it('works for set type flaglists', function()
|
||||
local formatoptions = exec_lua [[
|
||||
vim.opt.formatoptions = { t = true, c = true, r = true, o = true }
|
||||
return vim.opt.formatoptions:get()
|
||||
@ -2266,7 +2266,7 @@ describe('lua stdlib', function()
|
||||
eq(true, not formatoptions.q)
|
||||
end)
|
||||
|
||||
it('should work for array list type options', function()
|
||||
it('works for array list type options', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = "*.c,*.o,__pycache__"
|
||||
return vim.opt.wildignore:get()
|
||||
@ -2276,7 +2276,7 @@ describe('lua stdlib', function()
|
||||
eq('*.c', wildignore[1])
|
||||
end)
|
||||
|
||||
it('should work for options that are both commalist and flaglist', function()
|
||||
it('works for options that are both commalist and flaglist', function()
|
||||
local result = exec_lua [[
|
||||
vim.opt.whichwrap = "b,s"
|
||||
return vim.opt.whichwrap:get()
|
||||
@ -2292,7 +2292,7 @@ describe('lua stdlib', function()
|
||||
eq({ b = true, h = true }, result)
|
||||
end)
|
||||
|
||||
it('should work for key-value pair options', function()
|
||||
it('works for key-value pair options', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = "tab:> ,space:_"
|
||||
return vim.opt.listchars:get()
|
||||
@ -2304,7 +2304,7 @@ describe('lua stdlib', function()
|
||||
}, listchars)
|
||||
end)
|
||||
|
||||
it('should allow you to add numeric options', function()
|
||||
it('allows you to add numeric options', function()
|
||||
eq(
|
||||
16,
|
||||
exec_lua [[
|
||||
@ -2315,7 +2315,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow you to subtract numeric options', function()
|
||||
it('allows you to subtract numeric options', function()
|
||||
eq(
|
||||
2,
|
||||
exec_lua [[
|
||||
@ -2328,7 +2328,7 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
|
||||
describe('key:value style options', function()
|
||||
it('should handle dictionary style', function()
|
||||
it('handles dict style', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2340,7 +2340,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~,space:.', listchars)
|
||||
end)
|
||||
|
||||
it('should allow adding dictionary style', function()
|
||||
it('allows adding dict style', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2355,7 +2355,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~,space:-', listchars)
|
||||
end)
|
||||
|
||||
it('should allow adding dictionary style', function()
|
||||
it('allows adding dict style', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2369,7 +2369,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~,space:_', listchars)
|
||||
end)
|
||||
|
||||
it('should allow completely new keys', function()
|
||||
it('allows completely new keys', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2383,7 +2383,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~,space:.,tab:>>>', listchars)
|
||||
end)
|
||||
|
||||
it('should allow subtracting dictionary style', function()
|
||||
it('allows subtracting dict style', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2397,7 +2397,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~', listchars)
|
||||
end)
|
||||
|
||||
it('should allow subtracting dictionary style', function()
|
||||
it('allows subtracting dict style', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2411,7 +2411,7 @@ describe('lua stdlib', function()
|
||||
eq('', listchars)
|
||||
end)
|
||||
|
||||
it('should allow subtracting dictionary style multiple times', function()
|
||||
it('allows subtracting dict style multiple times', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2425,7 +2425,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~', listchars)
|
||||
end)
|
||||
|
||||
it('should allow adding a key:value string to a listchars', function()
|
||||
it('allows adding a key:value string to a listchars', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2439,7 +2439,7 @@ describe('lua stdlib', function()
|
||||
eq('eol:~,space:.,tab:>~', listchars)
|
||||
end)
|
||||
|
||||
it('should allow prepending a key:value string to a listchars', function()
|
||||
it('allows prepending a key:value string to a listchars', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = {
|
||||
eol = "~",
|
||||
@ -2454,7 +2454,7 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('should automatically set when calling remove', function()
|
||||
it('automatically sets when calling remove', function()
|
||||
eq(
|
||||
'foo,baz',
|
||||
exec_lua [[
|
||||
@ -2466,7 +2466,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should automatically set when calling remove with a table', function()
|
||||
it('automatically sets when calling remove with a table', function()
|
||||
eq(
|
||||
'foo',
|
||||
exec_lua [[
|
||||
@ -2478,7 +2478,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should automatically set when calling append', function()
|
||||
it('automatically sets when calling append', function()
|
||||
eq(
|
||||
'foo,bar,baz,bing',
|
||||
exec_lua [[
|
||||
@ -2490,7 +2490,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should automatically set when calling append with a table', function()
|
||||
it('automatically sets when calling append with a table', function()
|
||||
eq(
|
||||
'foo,bar,baz,bing,zap',
|
||||
exec_lua [[
|
||||
@ -2502,7 +2502,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow adding tables', function()
|
||||
it('allows adding tables', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = 'foo'
|
||||
return vim.o.wildignore
|
||||
@ -2516,7 +2516,7 @@ describe('lua stdlib', function()
|
||||
eq('foo,bar,baz', wildignore)
|
||||
end)
|
||||
|
||||
it('should handle adding duplicates', function()
|
||||
it('handles adding duplicates', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = 'foo'
|
||||
return vim.o.wildignore
|
||||
@ -2536,7 +2536,7 @@ describe('lua stdlib', function()
|
||||
eq('foo,bar,baz', wildignore)
|
||||
end)
|
||||
|
||||
it('should allow adding multiple times', function()
|
||||
it('allows adding multiple times', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = 'foo'
|
||||
vim.opt.wildignore = vim.opt.wildignore + 'bar' + 'baz'
|
||||
@ -2545,7 +2545,7 @@ describe('lua stdlib', function()
|
||||
eq('foo,bar,baz', wildignore)
|
||||
end)
|
||||
|
||||
it('should remove values when you use minus', function()
|
||||
it('removes values when you use minus', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = 'foo'
|
||||
return vim.o.wildignore
|
||||
@ -2565,7 +2565,7 @@ describe('lua stdlib', function()
|
||||
eq('foo,baz', wildignore)
|
||||
end)
|
||||
|
||||
it('should prepend values when using ^', function()
|
||||
it('prepends values when using ^', function()
|
||||
local wildignore = exec_lua [[
|
||||
vim.opt.wildignore = 'foo'
|
||||
vim.opt.wildignore = vim.opt.wildignore ^ 'first'
|
||||
@ -2580,7 +2580,7 @@ describe('lua stdlib', function()
|
||||
eq('super_first,first,foo', wildignore)
|
||||
end)
|
||||
|
||||
it('should not remove duplicates from wildmode: #14708', function()
|
||||
it('does not remove duplicates from wildmode: #14708', function()
|
||||
local wildmode = exec_lua [[
|
||||
vim.opt.wildmode = {"full", "list", "full"}
|
||||
return vim.o.wildmode
|
||||
@ -2590,7 +2590,7 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
|
||||
describe('option types', function()
|
||||
it('should allow to set option with numeric value', function()
|
||||
it('allows to set option with numeric value', function()
|
||||
eq(
|
||||
4,
|
||||
exec_lua [[
|
||||
@ -2639,7 +2639,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow to set option with boolean value', function()
|
||||
it('allows to set option with boolean value', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -2688,7 +2688,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow to set option with array or string value', function()
|
||||
it('allows to set option with array or string value', function()
|
||||
eq(
|
||||
'indent,eol,start',
|
||||
exec_lua [[
|
||||
@ -2735,7 +2735,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow set option with map or string value', function()
|
||||
it('allows set option with map or string value', function()
|
||||
eq(
|
||||
'eol:~,space:.',
|
||||
exec_lua [[
|
||||
@ -2785,7 +2785,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow set option with set or string value', function()
|
||||
it('allows set option with set or string value', function()
|
||||
local ww = exec_lua [[
|
||||
vim.opt.whichwrap = {
|
||||
b = true,
|
||||
@ -3235,11 +3235,11 @@ describe('lua stdlib', function()
|
||||
]]
|
||||
end)
|
||||
|
||||
it('should run from lua', function()
|
||||
it('runs from lua', function()
|
||||
exec_lua [[vim.wait(100, function() return true end)]]
|
||||
end)
|
||||
|
||||
it('should wait the expected time if false', function()
|
||||
it('waits the expected time if false', function()
|
||||
eq(
|
||||
{ time = true, wait_result = { false, -1 } },
|
||||
exec_lua [[
|
||||
@ -3255,7 +3255,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should not block other events', function()
|
||||
it('does not block other events', function()
|
||||
eq(
|
||||
{ time = true, wait_result = true },
|
||||
exec_lua [[
|
||||
@ -3280,7 +3280,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should not process non-fast events when commanded', function()
|
||||
it('does not process non-fast events when commanded', function()
|
||||
eq(
|
||||
{ wait_result = false },
|
||||
exec_lua [[
|
||||
@ -3303,7 +3303,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should work with vim.defer_fn', function()
|
||||
it('works with vim.defer_fn', function()
|
||||
eq(
|
||||
{ time = true, wait_result = true },
|
||||
exec_lua [[
|
||||
@ -3320,7 +3320,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should not crash when callback errors', function()
|
||||
it('does not crash when callback errors', function()
|
||||
local result = exec_lua [[
|
||||
return {pcall(function() vim.wait(1000, function() error("As Expected") end) end)}
|
||||
]]
|
||||
@ -3336,7 +3336,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow waiting with no callback, explicit', function()
|
||||
it('allows waiting with no callback, explicit', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3347,7 +3347,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should allow waiting with no callback, implicit', function()
|
||||
it('allows waiting with no callback, implicit', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3358,7 +3358,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should call callbacks exactly once if they return true immediately', function()
|
||||
it('calls callbacks exactly once if they return true immediately', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3372,7 +3372,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should call callbacks few times with large `interval`', function()
|
||||
it('calls callbacks few times with large `interval`', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3383,7 +3383,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should play nice with `not` when fails', function()
|
||||
it('plays nice with `not` when fails', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3396,7 +3396,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should play nice with `if` when success', function()
|
||||
it('plays nice with `if` when success', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3409,7 +3409,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should return immediately with false if timeout is 0', function()
|
||||
it('returns immediately with false if timeout is 0', function()
|
||||
eq(
|
||||
{ false, -1 },
|
||||
exec_lua [[
|
||||
@ -3420,7 +3420,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should work with tables with __call', function()
|
||||
it('works with tables with __call', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3430,7 +3430,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should work with tables with __call that change', function()
|
||||
it('works with tables with __call that change', function()
|
||||
eq(
|
||||
true,
|
||||
exec_lua [[
|
||||
@ -3447,7 +3447,7 @@ describe('lua stdlib', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('should not work with negative intervals', function()
|
||||
it('fails with negative intervals', function()
|
||||
local pcall_result = exec_lua [[
|
||||
return pcall(function() vim.wait(1000, function() return false end, -1) end)
|
||||
]]
|
||||
@ -3455,7 +3455,7 @@ describe('lua stdlib', function()
|
||||
eq(false, pcall_result)
|
||||
end)
|
||||
|
||||
it('should not work with weird intervals', function()
|
||||
it('fails with weird intervals', function()
|
||||
local pcall_result = exec_lua [[
|
||||
return pcall(function() vim.wait(1000, function() return false end, 'a string value') end)
|
||||
]]
|
||||
@ -3498,7 +3498,7 @@ describe('lua stdlib', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('should not run in fast callbacks #26122', function()
|
||||
it('fails in fast callbacks #26122', function()
|
||||
local screen = Screen.new(80, 10)
|
||||
screen:attach()
|
||||
exec_lua([[
|
||||
|
@ -389,7 +389,7 @@ describe(':checkhealth window', function()
|
||||
command('file my_buff')
|
||||
command('checkhealth success1')
|
||||
-- define a function that collects all buffers in each tab
|
||||
-- returns a dictionary like {tab1 = ["buf1", "buf2"], tab2 = ["buf3"]}
|
||||
-- returns a dict like {tab1 = ["buf1", "buf2"], tab2 = ["buf3"]}
|
||||
source([[
|
||||
function CollectBuffersPerTab()
|
||||
let buffs = {}
|
||||
|
@ -58,7 +58,7 @@ describe('ShaDa error handling', function()
|
||||
it('fails on search pattern item with zero length', function()
|
||||
wshada('\002\000\000')
|
||||
eq(
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dictionary',
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dict',
|
||||
exc_exec(sdrcmd())
|
||||
)
|
||||
end)
|
||||
@ -92,7 +92,7 @@ describe('ShaDa error handling', function()
|
||||
-- that cannot do this)
|
||||
wshada('\002\000\001\193')
|
||||
eq(
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dictionary',
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dict',
|
||||
exc_exec(sdrcmd())
|
||||
)
|
||||
end)
|
||||
@ -124,7 +124,7 @@ describe('ShaDa error handling', function()
|
||||
it('fails on search pattern item with NIL value', function()
|
||||
wshada('\002\000\001\192')
|
||||
eq(
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dictionary',
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: search pattern entry at position 0 is not a dict',
|
||||
exc_exec(sdrcmd())
|
||||
)
|
||||
end)
|
||||
@ -227,7 +227,7 @@ describe('ShaDa error handling', function()
|
||||
it('fails on ' .. v.name .. ' item with NIL value', function()
|
||||
wshada(v.mpack .. '\000\001\192')
|
||||
eq(
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 is not a dictionary',
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: mark entry at position 0 is not a dict',
|
||||
exc_exec(sdrcmd())
|
||||
)
|
||||
end)
|
||||
@ -301,7 +301,7 @@ describe('ShaDa error handling', function()
|
||||
it('fails on register item with NIL value', function()
|
||||
wshada('\005\000\001\192')
|
||||
eq(
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 is not a dictionary',
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: register entry at position 0 is not a dict',
|
||||
exc_exec(sdrcmd())
|
||||
)
|
||||
end)
|
||||
@ -504,7 +504,7 @@ describe('ShaDa error handling', function()
|
||||
nvim_command('set shada+=%')
|
||||
wshada('\009\000\008\146\129\161f\196\001/\192')
|
||||
eq(
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that is not a dictionary',
|
||||
'Vim(rshada):E575: Error while reading ShaDa file: buffer list at position 0 contains entry that is not a dict',
|
||||
exc_exec(sdrcmd())
|
||||
)
|
||||
end)
|
||||
|
@ -38,7 +38,7 @@ describe('b:changedtick', function()
|
||||
-- Somehow undo counts as two changes
|
||||
eq(5, changedtick())
|
||||
end)
|
||||
it('is present in b: dictionary', function()
|
||||
it('is present in b: dict', function()
|
||||
eq(2, changedtick())
|
||||
command('let d = b:')
|
||||
eq(2, api.nvim_get_var('d').changedtick)
|
||||
@ -168,7 +168,7 @@ describe('b:changedtick', function()
|
||||
)
|
||||
eq(2, changedtick())
|
||||
end)
|
||||
it('does not inherit VAR_FIXED when copying dictionary over', function()
|
||||
it('does not inherit VAR_FIXED when copying dict over', function()
|
||||
eq(2, changedtick())
|
||||
eq('', exec_capture('let d1 = copy(b:)|let d1.changedtick = 42'))
|
||||
eq('', exec_capture('let d2 = copy(b:)|unlet d2.changedtick'))
|
||||
|
@ -295,7 +295,7 @@ describe('context functions', function()
|
||||
eq(outofbounds, pcall_err(call, 'ctxget', 0))
|
||||
end)
|
||||
|
||||
it('returns context dictionary at index in context stack', function()
|
||||
it('returns context dict at index in context stack', function()
|
||||
feed('i1<cr>2<cr>3<c-[>ddddddqahjklq')
|
||||
command('edit! ' .. fname1)
|
||||
feed('G')
|
||||
@ -404,7 +404,7 @@ describe('context functions', function()
|
||||
eq(outofbounds, pcall_err(call, 'ctxset', { dummy = 1 }, 0))
|
||||
end)
|
||||
|
||||
it('errors when context dictionary is invalid', function()
|
||||
it('errors when context dict is invalid', function()
|
||||
call('ctxpush')
|
||||
eq(
|
||||
'Vim:E474: Failed to convert list to msgpack string buffer',
|
||||
@ -412,7 +412,7 @@ describe('context functions', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('sets context dictionary at index in context stack', function()
|
||||
it('sets context dict at index in context stack', function()
|
||||
api.nvim_set_var('one', 1)
|
||||
api.nvim_set_var('Two', 2)
|
||||
api.nvim_set_var('THREE', 3)
|
||||
|
@ -108,7 +108,7 @@ describe('input()', function()
|
||||
{T:1}^ |
|
||||
]])
|
||||
end)
|
||||
it('allows unequal numeric values when using {opts} dictionary', function()
|
||||
it('allows unequal numeric values when using {opts} dict', function()
|
||||
command('echohl Test')
|
||||
api.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
|
||||
feed([[:echo input(opts)<CR>]])
|
||||
@ -164,7 +164,7 @@ describe('input()', function()
|
||||
reset = true,
|
||||
}
|
||||
end)
|
||||
it('allows omitting everything with dictionary argument', function()
|
||||
it('allows omitting everything with dict argument', function()
|
||||
command('echohl Test')
|
||||
feed([[:call input({})<CR>]])
|
||||
screen:expect([[
|
||||
@ -290,7 +290,7 @@ describe('inputdialog()', function()
|
||||
{T:1}^ |
|
||||
]])
|
||||
end)
|
||||
it('allows unequal numeric values when using {opts} dictionary', function()
|
||||
it('allows unequal numeric values when using {opts} dict', function()
|
||||
command('echohl Test')
|
||||
api.nvim_set_var('opts', { prompt = 1, default = 2, cancelreturn = 3 })
|
||||
feed([[:echo input(opts)<CR>]])
|
||||
@ -346,7 +346,7 @@ describe('inputdialog()', function()
|
||||
reset = true,
|
||||
}
|
||||
end)
|
||||
it('allows omitting everything with dictionary argument', function()
|
||||
it('allows omitting everything with dict argument', function()
|
||||
command('echohl Test')
|
||||
feed(':echo inputdialog({})<CR>')
|
||||
screen:expect([[
|
||||
|
@ -911,7 +911,7 @@ describe('json_encode() function', function()
|
||||
eq('[]', eval('json_encode(v:_null_list)'))
|
||||
end)
|
||||
|
||||
it('can dump NULL dictionary', function()
|
||||
it('can dump NULL dict', function()
|
||||
eq('{}', eval('json_encode(v:_null_dict)'))
|
||||
end)
|
||||
|
||||
|
@ -36,7 +36,7 @@ describe('maparg()', function()
|
||||
lnum = 0,
|
||||
}
|
||||
|
||||
it('returns a dictionary', function()
|
||||
it('returns a dict', function()
|
||||
command('nnoremap foo bar')
|
||||
eq('bar', fn.maparg('foo'))
|
||||
eq(foo_bar_map_table, fn.maparg('foo', 'n', false, true))
|
||||
@ -54,7 +54,7 @@ describe('maparg()', function()
|
||||
eq('', fn.maparg('not a mapping'))
|
||||
end)
|
||||
|
||||
it('returns an empty dictionary when no map is present and dict is requested', function()
|
||||
it('returns an empty dict when no map is present and dict is requested', function()
|
||||
eq({}, fn.maparg('not a mapping', 'n', false, true))
|
||||
end)
|
||||
|
||||
|
@ -437,16 +437,16 @@ describe('msgpackparse() function', function()
|
||||
parse_eq({ 'ab' }, { '\196\002ab' })
|
||||
end)
|
||||
|
||||
it('restores FIXEXT1 as special dictionary', function()
|
||||
it('restores FIXEXT1 as special dict', function()
|
||||
parse_eq({ { _TYPE = {}, _VAL = { 0x10, { '', '' } } } }, { '\212\016', '' })
|
||||
eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.ext'))
|
||||
end)
|
||||
|
||||
it('restores MAP with BIN key as ordinary dictionary', function()
|
||||
it('restores MAP with BIN key as ordinary dict', function()
|
||||
parse_eq({ { a = '' } }, { '\129\196\001a\196\n' })
|
||||
end)
|
||||
|
||||
it('restores MAP with duplicate STR keys as special dictionary', function()
|
||||
it('restores MAP with duplicate STR keys as special dict', function()
|
||||
command('let dumped = ["\\x82\\xA1a\\xC4\\n\\xA1a\\xC4\\n"]')
|
||||
-- FIXME Internal error bug, can't use parse_eq() here
|
||||
command('silent! let parsed = msgpackparse(dumped)')
|
||||
@ -464,7 +464,7 @@ describe('msgpackparse() function', function()
|
||||
eq(eval('v:t_string'), eval('type(g:parsed[0]._VAL[1][0])'))
|
||||
end)
|
||||
|
||||
it('restores MAP with MAP key as special dictionary', function()
|
||||
it('restores MAP with MAP key as special dict', function()
|
||||
parse_eq({ { _TYPE = {}, _VAL = { { {}, '' } } } }, { '\129\128\196\n' })
|
||||
eq(1, eval('g:parsed[0]._TYPE is v:msgpack_types.map'))
|
||||
end)
|
||||
@ -510,7 +510,7 @@ describe('msgpackparse() function', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('fails to parse a dictionary', function()
|
||||
it('fails to parse a dict', function()
|
||||
eq(
|
||||
'Vim(call):E899: Argument of msgpackparse() must be a List or Blob',
|
||||
exc_exec('call msgpackparse({})')
|
||||
@ -764,7 +764,7 @@ describe('msgpackdump() function', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('fails to dump a dictionary', function()
|
||||
it('fails to dump a dict', function()
|
||||
eq('Vim(call):E686: Argument of msgpackdump() must be a List', exc_exec('call msgpackdump({})'))
|
||||
end)
|
||||
|
||||
@ -813,7 +813,7 @@ describe('msgpackdump() function', function()
|
||||
eq({ '\144' }, eval('msgpackdump([v:_null_list])'))
|
||||
end)
|
||||
|
||||
it('can dump NULL dictionary', function()
|
||||
it('can dump NULL dict', function()
|
||||
eq({ '\128' }, eval('msgpackdump([v:_null_dict])'))
|
||||
end)
|
||||
end)
|
||||
|
@ -170,9 +170,9 @@ describe('string() function', function()
|
||||
)
|
||||
end)
|
||||
|
||||
it('does not show errors when dumping partials referencing the same dictionary', function()
|
||||
it('does not show errors when dumping partials referencing the same dict', function()
|
||||
command('let d = {}')
|
||||
-- Regression for “eval/typval_encode: Dump empty dictionary before
|
||||
-- Regression for “eval/typval_encode: Dump empty dict before
|
||||
-- checking for refcycle”, results in error.
|
||||
eq(
|
||||
"[function('tr', {}), function('tr', {})]",
|
||||
@ -256,7 +256,7 @@ describe('string() function', function()
|
||||
end)
|
||||
|
||||
describe('used to represent dictionaries', function()
|
||||
it('dumps empty dictionary', function()
|
||||
it('dumps empty dict', function()
|
||||
eq('{}', eval('string({})'))
|
||||
end)
|
||||
|
||||
@ -267,7 +267,7 @@ describe('string() function', function()
|
||||
eq("[{}, function('tr', {})]", eval('string([d, function("tr", d)])'))
|
||||
end)
|
||||
|
||||
it('dumps non-empty dictionary', function()
|
||||
it('dumps non-empty dict', function()
|
||||
eq("{'t''est': 1}", fn.string({ ["t'est"] = 1 }))
|
||||
end)
|
||||
|
||||
|
@ -43,9 +43,9 @@ describe('vim_to_object', function()
|
||||
simple_test('converts empty string', '')
|
||||
simple_test('converts non-empty string', 'foobar')
|
||||
simple_test('converts integer 10', { [type_key] = int_type, value = 10 })
|
||||
simple_test('converts empty dictionary', {})
|
||||
simple_test('converts dictionary with scalar values', { test = 10, test2 = true, test3 = 'test' })
|
||||
simple_test('converts dictionary with containers inside', { test = {}, test2 = { 1, 2 } })
|
||||
simple_test('converts empty dict', {})
|
||||
simple_test('converts dict with scalar values', { test = 10, test2 = true, test3 = 'test' })
|
||||
simple_test('converts dict with containers inside', { test = {}, test2 = { 1, 2 } })
|
||||
simple_test('converts empty list', { [type_key] = list_type })
|
||||
simple_test('converts list with scalar values', { 1, 2, 'test', 'foo' })
|
||||
simple_test(
|
||||
|
@ -35,10 +35,10 @@ local function init_obj2lua_tab()
|
||||
end
|
||||
return ret
|
||||
end,
|
||||
[tonumber(api.kObjectTypeDictionary)] = function(obj)
|
||||
[tonumber(api.kObjectTypeDict)] = function(obj)
|
||||
local ret = {}
|
||||
for i = 1, tonumber(obj.data.dictionary.size) do
|
||||
local kv_pair = obj.data.dictionary.items[i - 1]
|
||||
for i = 1, tonumber(obj.data.dict.size) do
|
||||
local kv_pair = obj.data.dict.items[i - 1]
|
||||
ret[ffi.string(kv_pair.key.data, kv_pair.key.size)] = obj2lua(kv_pair.value)
|
||||
end
|
||||
return ret
|
||||
@ -112,8 +112,8 @@ local lua2obj_type_tab = {
|
||||
end
|
||||
end
|
||||
local len = #kvs
|
||||
local dct = obj(api.kObjectTypeDictionary, {
|
||||
dictionary = {
|
||||
local dct = obj(api.kObjectTypeDict, {
|
||||
dict = {
|
||||
size = len,
|
||||
capacity = len,
|
||||
items = ffi.cast('KeyValuePair *', api.xmalloc(len * ffi.sizeof('KeyValuePair'))),
|
||||
@ -121,7 +121,7 @@ local lua2obj_type_tab = {
|
||||
})
|
||||
for i = 1, len do
|
||||
local key, val = unpack(kvs[i])
|
||||
dct.data.dictionary.items[i - 1] = ffi.new(
|
||||
dct.data.dict.items[i - 1] = ffi.new(
|
||||
'KeyValuePair',
|
||||
{ key = ffi.gc(lua2obj(key), nil).data.string, value = ffi.gc(lua2obj(val), nil) }
|
||||
)
|
||||
|
@ -56,14 +56,14 @@ describe('build_stl_str_hl', function()
|
||||
-- @param input_stl The format string for the statusline
|
||||
-- @param expected_stl The expected result string for the statusline
|
||||
--
|
||||
-- @param arg Options can be placed in an optional dictionary as the last parameter
|
||||
-- @param arg Options can be placed in an optional dict as the last parameter
|
||||
-- .expected_cell_count The expected number of cells build_stl_str_hl will return
|
||||
-- .expected_byte_length The expected byte length of the string (defaults to byte length of expected_stl)
|
||||
-- .file_name The name of the file to be tested (useful in %f type tests)
|
||||
-- .fillchar The character that will be used to fill any 'extra' space in the stl
|
||||
local function statusline_test(description, statusline_cell_count, input_stl, expected_stl, arg)
|
||||
-- arg is the optional parameter
|
||||
-- so we either fill in option with arg or an empty dictionary
|
||||
-- so we either fill in option with arg or an empty dict
|
||||
local option = arg or {}
|
||||
|
||||
local fillchar = option.fillchar or ' '
|
||||
|
Loading…
Reference in New Issue
Block a user