aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2022-03-01 13:13:11 +0100
committerGitHub <noreply@github.com>2022-03-01 13:13:11 +0100
commit0a9b00913f1c2f88e27c32bd60b51ced5a0770f3 (patch)
tree6545d4c07d45f76552708d422d4b8e8454c3988c /src/nvim/eval.c
parent37a86a2f964b5d6f9dbfae8b78acaa3a71f981bb (diff)
parent7b6ee3ef0a2d64657c8ca25f440e010c6dc75408 (diff)
downloadrneovim-0a9b00913f1c2f88e27c32bd60b51ced5a0770f3.tar.gz
rneovim-0a9b00913f1c2f88e27c32bd60b51ced5a0770f3.tar.bz2
rneovim-0a9b00913f1c2f88e27c32bd60b51ced5a0770f3.zip
Merge pull request #15079 from shadmansaleh/feat/verbose_lua
feat(lua): add :verbose support for lua config
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 0322898827..d95b9560c2 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9369,10 +9369,31 @@ static hashtab_T *find_var_ht_dict(const char *name, const size_t name_len, cons
} else if (*name == 'l' && funccal != NULL) { // local variable
*d = &funccal->l_vars;
} else if (*name == 's' // script variable
- && (current_sctx.sc_sid > 0 || current_sctx.sc_sid == SID_STR)
+ && (current_sctx.sc_sid > 0 || current_sctx.sc_sid == SID_STR
+ || current_sctx.sc_sid == SID_LUA)
&& current_sctx.sc_sid <= ga_scripts.ga_len) {
// For anonymous scripts without a script item, create one now so script vars can be used
- if (current_sctx.sc_sid == SID_STR) {
+ if (current_sctx.sc_sid == SID_LUA) {
+ // try to resolve lua filename & line no so it can be shown in lastset messages.
+ nlua_set_sctx(&current_sctx);
+ if (current_sctx.sc_sid != SID_LUA) {
+ // Great we have valid location. Now here this out we'll create a new
+ // script context with the name and lineno of this one. why ?
+ // for behavioral consistency. With this different anonymous exec from
+ // same file can't access each others script local stuff. We need to do
+ // this all other cases except this will act like that otherwise.
+ const LastSet last_set = (LastSet){
+ .script_ctx = current_sctx,
+ .channel_id = LUA_INTERNAL_CALL,
+ };
+ bool should_free;
+ // should_free is ignored as script_sctx will be resolved to a fnmae
+ // & new_script_item will consume it.
+ char_u *sc_name = get_scriptname(last_set, &should_free);
+ new_script_item(sc_name, &current_sctx.sc_sid);
+ }
+ }
+ if (current_sctx.sc_sid == SID_STR || current_sctx.sc_sid == SID_LUA) {
new_script_item(NULL, &current_sctx.sc_sid);
}
*d = &SCRIPT_SV(current_sctx.sc_sid)->sv_dict;