aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-12-08 01:39:41 -0500
committerJustin M. Keyes <justinkz@gmail.com>2025-12-15 13:55:15 -0500
commit31dfecb458308cd07770af596b4aa36f44ff7d08 (patch)
tree24fd4b4eca3e60186bd77b7b25f7d542d3657c4d /src/nvim/api/vim.c
parent8165427b4d92e55be5644bdf9270eb49b99d6dcc (diff)
downloadrneovim-31dfecb458308cd07770af596b4aa36f44ff7d08.tar.gz
rneovim-31dfecb458308cd07770af596b4aa36f44ff7d08.tar.bz2
rneovim-31dfecb458308cd07770af596b4aa36f44ff7d08.zip
docs: misc, editorconfig
fix https://github.com/neovim/neovim/issues/36858
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c29
1 files changed, 20 insertions, 9 deletions
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