Merge #34722 from justinmk/release

This commit is contained in:
Justin M. Keyes
2025-07-01 04:34:05 -07:00
committed by GitHub
12 changed files with 31 additions and 10 deletions

View File

@ -2357,6 +2357,8 @@ A jump table for the options with a short description can be found at |Q_op|.
in the |trust| list. Use |:trust| to manage trusted files. See also
|vim.secure.read()|.
To get its own location, Lua exrc files can use |debug.getinfo()|.
Compare 'exrc' to |editorconfig|:
- 'exrc' can execute any code; editorconfig only specifies settings.
- 'exrc' is Nvim-specific; editorconfig works in other editors.

View File

@ -2040,7 +2040,8 @@ expand({string} [, {nosuf} [, {list}]]) *expand()*
<SID> "<SNR>123_" where "123" is the
current script ID |<SID>|
<script> sourced script file, or script file
where the current function was defined
where the current function was defined.
Use |debug.getinfo()| in Lua scripts.
<stack> call stack
<cword> word under the cursor
<cWORD> WORD under the cursor

View File

@ -2015,6 +2015,8 @@ vim.bo.et = vim.bo.expandtab
--- in the `trust` list. Use `:trust` to manage trusted files. See also
--- `vim.secure.read()`.
---
--- To get its own location, Lua exrc files can use `debug.getinfo()`.
---
--- Compare 'exrc' to `editorconfig`:
--- - 'exrc' can execute any code; editorconfig only specifies settings.
--- - 'exrc' is Nvim-specific; editorconfig works in other editors.

View File

@ -1801,7 +1801,8 @@ function vim.fn.exp(expr) end
--- <SID> "<SNR>123_" where "123" is the
--- current script ID |<SID>|
--- <script> sourced script file, or script file
--- where the current function was defined
--- where the current function was defined.
--- Use |debug.getinfo()| in Lua scripts.
--- <stack> call stack
--- <cword> word under the cursor
--- <cWORD> WORD under the cursor

View File

@ -62,7 +62,7 @@ Object nvim_execute_lua(String code, Array args, Arena *arena, Error *err)
FUNC_API_DEPRECATED_SINCE(7)
FUNC_API_REMOTE_ONLY
{
return nlua_exec(code, args, kRetObject, arena, err);
return nlua_exec(code, NULL, args, kRetObject, arena, err);
}
/// Gets the buffer number

View File

@ -514,7 +514,7 @@ Object nvim_exec_lua(String code, Array args, Arena *arena, Error *err)
FUNC_API_REMOTE_ONLY
{
// TODO(bfredl): convert directly from msgpack to lua and then back again
return nlua_exec(code, args, kRetObject, arena, err);
return nlua_exec(code, NULL, args, kRetObject, arena, err);
}
/// Calculates the number of display cells occupied by `text`.

View File

@ -2342,7 +2342,8 @@ M.funcs = {
<SID> "<SNR>123_" where "123" is the
current script ID |<SID>|
<script> sourced script file, or script file
where the current function was defined
where the current function was defined.
Use |debug.getinfo()| in Lua scripts.
<stack> call stack
<cword> word under the cursor
<cWORD> WORD under the cursor

View File

@ -1507,17 +1507,20 @@ int typval_exec_lua_callable(LuaRef lua_cb, int argcount, typval_T *argvars, typ
/// Used for nvim_exec_lua() and internally to execute a lua string.
///
/// @param[in] str String to execute.
/// @param[in] chunkname Chunkname, defaults to "<nvim>".
/// @param[in] args array of ... args
/// @param[in] mode Whether and how the the return value should be converted to Object
/// @param[in] arena can be NULL, then nested allocations are used
/// @param[out] err Location where error will be saved.
///
/// @return Return value of the execution.
Object nlua_exec(const String str, const Array args, LuaRetMode mode, Arena *arena, Error *err)
Object nlua_exec(const String str, const char *chunkname, const Array args, LuaRetMode mode,
Arena *arena, Error *err)
{
lua_State *const lstate = global_lstate;
if (luaL_loadbuffer(lstate, str.data, str.size, "<nvim>")) {
const char *name = (chunkname && chunkname[0]) ? chunkname : "<nvim>";
if (luaL_loadbuffer(lstate, str.data, str.size, name)) {
size_t len;
const char *errstr = lua_tolstring(lstate, -1, &len);
api_set_error(err, kErrorTypeValidation,

View File

@ -26,7 +26,7 @@ typedef struct {
} nlua_ref_state_t;
#define NLUA_EXEC_STATIC(cstr, arg, mode, arena, err) \
nlua_exec(STATIC_CSTR_AS_STRING(cstr), arg, mode, arena, err)
nlua_exec(STATIC_CSTR_AS_STRING(cstr), NULL, arg, mode, arena, err)
#define NLUA_CLEAR_REF(x) \
do { \

View File

@ -958,7 +958,7 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
ADD_C(a, CSTR_AS_OBJ(connect_error));
ADD_C(a, ARRAY_OBJ(args));
String s = STATIC_CSTR_AS_STRING("return vim._cs_remote(...)");
Object o = nlua_exec(s, a, kRetObject, NULL, &err);
Object o = nlua_exec(s, NULL, a, kRetObject, NULL, &err);
kv_destroy(args);
if (ERROR_SET(&err)) {
fprintf(stderr, "%s\n", err.msg);
@ -2059,7 +2059,8 @@ static void do_exrc_initialization(void)
str = nlua_read_secure(VIMRC_LUA_FILE);
if (str != NULL) {
Error err = ERROR_INIT;
nlua_exec(cstr_as_string(str), (Array)ARRAY_DICT_INIT, kRetNilBool, NULL, &err);
nlua_exec(cstr_as_string(str), "@"VIMRC_LUA_FILE, (Array)ARRAY_DICT_INIT, kRetNilBool, NULL,
&err);
xfree(str);
if (ERROR_SET(&err)) {
semsg("Error detected while processing %s:", VIMRC_LUA_FILE);

View File

@ -2668,6 +2668,8 @@ local options = {
in the |trust| list. Use |:trust| to manage trusted files. See also
|vim.secure.read()|.
To get its own location, Lua exrc files can use |debug.getinfo()|.
Compare 'exrc' to |editorconfig|:
- 'exrc' can execute any code; editorconfig only specifies settings.
- 'exrc' is Nvim-specific; editorconfig works in other editors.

View File

@ -1140,6 +1140,7 @@ describe('user config init', function()
string.format(
[[
vim.g.exrc_file = "%s"
vim.g.exrc_path = debug.getinfo(1, 'S').source:sub(2)
]],
exrc_path
)
@ -1150,6 +1151,7 @@ describe('user config init', function()
string.format(
[[
let g:exrc_file = "%s"
" let g:exrc_path = ??
]],
exrc_path
)
@ -1213,6 +1215,12 @@ describe('user config init', function()
))
clear { args_rm = { '-u' }, env = xstateenv }
if string.find(exrc_path, '%.lua$') then
eq(
vim.fs.normalize(vim.fs.abspath(filename)),
vim.fs.normalize(vim.fs.abspath(eval('g:exrc_path')))
)
end
-- The 'exrc' file is now trusted.
eq(filename, eval('g:exrc_file'))
end)