From 31dfecb458308cd07770af596b4aa36f44ff7d08 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 8 Dec 2025 01:39:41 -0500 Subject: docs: misc, editorconfig fix https://github.com/neovim/neovim/issues/36858 --- src/nvim/api/vim.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src/nvim/api') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 2c844dc767..9bc0013f27 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -497,18 +497,29 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, Bool return cstr_as_string(ptr); } -/// Execute Lua code. Parameters (if any) are available as `...` inside the -/// chunk. The chunk can return a value. +/// Executes Lua code. Arguments are available as `...` inside the chunk. The chunk can return +/// a value. /// -/// Only statements are executed. To evaluate an expression, prefix it -/// with `return`: return my_function(...) +/// Only statements are executed. To evaluate an expression, prefix it with "return": `return +/// my_function(...)` /// -/// @param code Lua code to execute -/// @param args Arguments to the code -/// @param[out] err Details of an error encountered while parsing -/// or executing the Lua code. +/// Example: +/// ```lua +/// local peer = vim.fn.jobstart({ vim.v.progpath, '--clean', '--embed' }, { rpc=true }) +/// vim.print(vim.rpcrequest(peer, 'nvim_exec_lua', [[ +/// local a, b = ... +/// return ('result: %s'):format(a + b) +/// ]], +/// { 1, 3 } +/// ) +/// ) +/// ``` /// -/// @return Return value of Lua code if present or NIL. +/// @param code Lua code to execute. +/// @param args Arguments to the Lua code. +/// @param[out] err Lua error raised while parsing or executing the Lua code. +/// +/// @return Value returned by the Lua code (if any), or NIL. Object nvim_exec_lua(String code, Array args, Arena *arena, Error *err) FUNC_API_SINCE(7) FUNC_API_REMOTE_ONLY -- cgit