diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-02-26 07:40:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-25 23:40:21 +0000 |
commit | e2aca58bcc4f0aff8da9683194e4dc857a56118f (patch) | |
tree | d077b324c29de6d53ca42f9496efb9451fc40b05 /src/nvim/lua/executor.c | |
parent | af0a2157ad2958b6c1e3c374ac247726c252c219 (diff) | |
download | rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.tar.gz rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.tar.bz2 rneovim-e2aca58bcc4f0aff8da9683194e4dc857a56118f.zip |
fix(lua): don't override script ID from :source (#32626)
Problem: When setting an option, mapping etc. from Lua without -V1, the
script ID is set to SID_LUA even if there already is a script
ID assigned by :source.
Solution: Don't set script ID to SID_LUA if it is already a Lua script.
Also add _editor.lua to ignorelist to make script context more
useful when using vim.cmd().
Diffstat (limited to 'src/nvim/lua/executor.c')
-rw-r--r-- | src/nvim/lua/executor.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 17009446e4..c4c6c19439 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -2110,7 +2110,8 @@ bool nlua_execute_on_key(int c, char *typed_buf) // @param[out] current void nlua_set_sctx(sctx_T *current) { - if (p_verbose <= 0 || current->sc_sid != SID_LUA) { + if (p_verbose <= 0 || (current->sc_sid > 0 && current->sc_lnum > 0) + || !script_is_lua(current->sc_sid)) { return; } lua_State *const lstate = global_lstate; @@ -2119,6 +2120,7 @@ void nlua_set_sctx(sctx_T *current) // Files where internal wrappers are defined so we can ignore them // like vim.o/opt etc are defined in _options.lua char *ignorelist[] = { + "vim/_editor.lua", "vim/_options.lua", "vim/keymap.lua", }; @@ -2153,7 +2155,8 @@ void nlua_set_sctx(sctx_T *current) if (sid > 0) { xfree(source_path); } else { - new_script_item(source_path, &sid); + scriptitem_T *si = new_script_item(source_path, &sid); + si->sn_lua = true; } current->sc_sid = sid; current->sc_seq = -1; |