diff options
author | Michal Liszcz <liszcz.michal@gmail.com> | 2023-03-11 04:22:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-11 11:22:22 +0800 |
commit | 674e23f19c509381e2476a3990e21272e362e3a4 (patch) | |
tree | 5c14e0497c12e5caad1965f3793031974eb1a405 /src | |
parent | 8cb5b995b6e4d86035e6950d92c0c68ab4e46787 (diff) | |
download | rneovim-674e23f19c509381e2476a3990e21272e362e3a4.tar.gz rneovim-674e23f19c509381e2476a3990e21272e362e3a4.tar.bz2 rneovim-674e23f19c509381e2476a3990e21272e362e3a4.zip |
vim-patch:9.0.0244: cannot easily get the list of sourced scripts (#22596)
Problem: Cannot easily get the list of sourced scripts.
Solution: Add the getscriptinfo() function. (Yegappan Lakshmanan,
closes vim/vim#10957)
https://github.com/vim/vim/commit/f768c3d19c518822d89dec4cc3947ddeea249316
Cherry-pick usr_41.txt change from a later runtime update.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.lua | 1 | ||||
-rw-r--r-- | src/nvim/generators/gen_eval.lua | 1 | ||||
-rw-r--r-- | src/nvim/runtime.c | 23 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index ae10a7e035..66032adbaf 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -189,6 +189,7 @@ return { gettabinfo={args={0, 1}, base=1}, gettabvar={args={2, 3}, base=1}, gettabwinvar={args={3, 4}, base=1}, + getscriptinfo={}, gettagstack={args={0, 1}, base=1}, gettext={args=1, base=1}, getwininfo={args={0, 1}, base=1}, diff --git a/src/nvim/generators/gen_eval.lua b/src/nvim/generators/gen_eval.lua index baed6a74c2..fb1dd82a26 100644 --- a/src/nvim/generators/gen_eval.lua +++ b/src/nvim/generators/gen_eval.lua @@ -48,6 +48,7 @@ hashpipe:write([[ #include "nvim/menu.h" #include "nvim/move.h" #include "nvim/quickfix.h" +#include "nvim/runtime.h" #include "nvim/search.h" #include "nvim/sign.h" #include "nvim/testing.h" diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index a6ed95ec64..7a3efc5760 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -2337,6 +2337,29 @@ linenr_T get_sourced_lnum(LineGetter fgetline, void *cookie) : SOURCING_LNUM; } +/// "getscriptinfo()" function +void f_getscriptinfo(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) +{ + tv_list_alloc_ret(rettv, script_items.ga_len); + + list_T *l = rettv->vval.v_list; + + for (int i = 1; i <= script_items.ga_len; i++) { + scriptitem_T *si = SCRIPT_ITEM(i); + + if (si->sn_name == NULL) { + continue; + } + + dict_T *d = tv_dict_alloc(); + tv_list_append_dict(l, d); + tv_dict_add_str(d, S_LEN("name"), si->sn_name); + tv_dict_add_nr(d, S_LEN("sid"), i); + // Vim9 autoload script (:h vim9-autoload), not applicable to Nvim. + tv_dict_add_bool(d, S_LEN("autoload"), false); + } +} + /// Get one full line from a sourced file. /// Called by do_cmdline() when it's called from do_source(). /// |