Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lua): add :verbose support for lua config #15079

Merged
merged 2 commits into from
Mar 1, 2022

Conversation

shadmansaleh
Copy link
Contributor

@shadmansaleh shadmansaleh commented Jul 13, 2021

Currently :verbose doesn't show enough information when keymap/options are set from lua . It either shows 'last set from lua' or just 'last set from filename' without line no when that file is sourced . Which also becomes inacurate when you require a file that sets the option from the sourced file .

This solves that . Now proper location is show with :verbose.

To get the verbose info you need tp start neovim with atleast verbose level 1 nvim -V1 . Lua debug calls are quite slow so it's made optin.

src/nvim/lua/executor.c Outdated Show resolved Hide resolved
src/nvim/lua/executor.h Outdated Show resolved Hide resolved
@shadmansaleh shadmansaleh changed the title feat(runtime): Show proper verbose output for lua keymaps [WIP]feat(runtime): Show proper verbose output for lua keymaps Jul 13, 2021
@shadmansaleh

This comment has been minimized.

@shadmansaleh shadmansaleh changed the title [WIP]feat(runtime): Show proper verbose output for lua keymaps [WIP]feat(runtime): Show proper verbose output for lua keymaps and options Jul 14, 2021
@shadmansaleh shadmansaleh force-pushed the feat/verbose_lua branch 8 times, most recently from 989950d to 9840b78 Compare July 14, 2021 16:33
@shadmansaleh

This comment has been minimized.

@bfredl
Copy link
Member

bfredl commented Jul 14, 2021

you could also mark it as a draft :)

@clason
Copy link
Member

clason commented Jul 14, 2021

I keep forgetting which actions are set to run on draft PRs and which aren't. Maybe we can document this in Contributing.md?

@shadmansaleh shadmansaleh reopened this Jul 14, 2021
@shadmansaleh shadmansaleh marked this pull request as draft July 14, 2021 23:53
@shadmansaleh

This comment has been minimized.

@shadmansaleh shadmansaleh marked this pull request as ready for review July 15, 2021 03:20
@shadmansaleh shadmansaleh changed the title [WIP]feat(runtime): Show proper verbose output for lua keymaps and options [RFC]feat(lua): Show proper :verbose info for lua config Jul 15, 2021
@shadmansaleh
Copy link
Contributor Author

shadmansaleh commented Jul 15, 2021

@bfredl Now it's ready for review . You can take a look when you have time :]

Also is there anyway to differentiate between api function called through lua vim.api or from some other language useing rpc ?

I think it would have been great if we could make nvim_exec execute with SID_LUA instead of SID_STR when executing from lua .

@shadmansaleh shadmansaleh changed the title [RFC]feat(lua): Show proper :verbose info for lua config [RFC] feat(lua): Fix :verbose info for lua config Jul 15, 2021
@shadmansaleh shadmansaleh force-pushed the feat/verbose_lua branch 3 times, most recently from a132910 to ab94768 Compare July 15, 2021 14:49
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 28, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in some places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 28, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in some places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 28, 2022
Support showing line numbers for Vim script sourced anonymously via :source (no
args) and nvim_exec.

Do not offset the line number shown from anonymous scripts with the line number
of an enclosing script. For example, this could produce incorrect numbers in
situations where we have escaped NLs:

```vim
echo "hi"
call nvim_exec("\n\n\nset cul", 1)
verbose set cul?
```
Would print "line 6" (preferably "line 5"), but it's actually on line 2...

TODO: ideally, we should say something instead, like:
"Last set from anonymous :source (script id X) line 4 in script.vim line 2"

TODO: see verbose_spec.lua comment, anonymous sources in Lua need to be fixed so
they can be <SID>ed like regular anon sources, but neovim#15079 broke that...
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 28, 2022
TODO: the nlua_set_sctx stuff is more bugged than i thought...

Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special mask SID_MASK_LUA to identify scripts from Lua
contexts. Encoding it this way avoids the need to store such information in
an allocated script item or elsewhere.
(Though it does produce some ugly script IDs...)

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID. Add tests.

Also, remove find_sid (unused leftover stuff from the autocmd API PR) and change
sid_T's type to int64_t.
seandewar pushed a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in some places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offset SID_FROM_LUA to identify scripts from Lua
contexts. Encoding it this way avoids the need to store such information in an
allocated script item or elsewhere.
However, this does produce ugly script IDs, so only do this when Lua :verbose
logging is enabled ('verbose' >= 1).

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offset SID_FROM_LUA to identify scripts from Lua
contexts. Encoding it this way avoids the need to store such information in an
allocated script item or elsewhere.
However, this does produce ugly script IDs, so only do this when Lua :verbose
logging is enabled ('verbose' >= 1).

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar pushed a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offset SID_FROM_LUA to identify scripts from Lua
contexts. Encoding it this way avoids the need to store such information in an
allocated script item or elsewhere.
However, this does produce ugly script IDs, so only do this when Lua :verbose
logging is enabled ('verbose' >= 1).

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar pushed a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 29, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offset SID_FROM_LUA to identify scripts from Lua
contexts. Encoding it this way avoids the need to store such information in an
allocated script item or elsewhere.
However, this does produce ugly script IDs, so only do this when Lua :verbose
logging is enabled ('verbose' >= 1).

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar pushed a commit to seandewar/neovim that referenced this pull request Mar 30, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 30, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 30, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offset SID_FROM_LUA to identify scripts from Lua
contexts in which nlua_set_sctx can be used. Encoding it this way avoids the
need to store such information in an allocated script item or elsewhere.

However, SID_FROM_LUA produces ugly script IDs, so it's only used when :verbose
logging for Lua is enabled. As a result, it's now even more strongly recommended
to start nvim as `nvim -V1` rather than to set verbose=1 in the middle of a
session, otherwise tracing for previously sourced Lua scripts before verbose
was set will not work (as they won't have the SID_FROM_LUA offset).

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old verbose Lua
approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar pushed a commit to seandewar/neovim that referenced this pull request Mar 31, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 31, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request Mar 31, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offsets to identify scripts from Lua contexts in
which nlua_set_sctx can be used. Encoding it this way avoids the need to store
such information in an allocated script item or elsewhere.

However, this approach produces ugly script IDs, so it's only used when :verbose
logging for Lua is enabled. As a result, it's now even more strongly recommended
to start nvim as `nvim -V1` rather than to set verbose=1 in the middle of a
session, otherwise tracing for previously sourced Lua scripts before verbose
was set will not work.

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old verbose Lua
approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar pushed a commit to seandewar/neovim that referenced this pull request May 12, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request May 12, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request May 12, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offsets to identify scripts from Lua contexts in
which nlua_set_sctx can be used. Encoding it this way avoids the need to store
such information in an allocated script item or elsewhere.

However, this approach produces ugly script IDs, so it's only used when :verbose
logging for Lua is enabled. As a result, it's now even more strongly recommended
to start nvim as `nvim -V1` rather than to set verbose=1 in the middle of a
session, otherwise tracing for previously sourced Lua scripts before verbose
was set will not work.

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old verbose Lua
approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
seandewar pushed a commit to seandewar/neovim that referenced this pull request May 13, 2022
Followup to da9b0ab neovim#15994.
`scriptitem_T` was lifted out of ex_cmds2.c but it's not needed, so keep it
private.

Also clean up some comments from neovim#15079 and rename a few functions.
Add a test for ensuring different anon execs in the same Lua file still have
unique SIDs with tracing enabled.
seandewar added a commit to seandewar/neovim that referenced this pull request May 13, 2022
Always assign unique SID for anonymous sources, but defer allocation of script
items and vars until script var access.

Because all anonymous scripts always have SIDs now, <SID> and s: scope (also
defined in functions, autocmds, commands, etc.) will work.

Because a SID may not yet (or ever) map to an item, use a hash map for
script_items and ga_scripts (now script_vars).

Add file_sids; a sorted growarray of SIDs associated with a script file (used
for :scriptnames, profiling, do_source, etc.).

Replace SCRIPT macros with script_item and script_sv functions.
Remove SCRIPT_VARS as it isn't very useful now.

Use PRIdSCID to format scid_T in places that were missing it.

This also fixes an issue since neovim#15079 that resulted in duplicate file name
entries in :scriptnames output; test for this.

Adjust more tests to use anonymous :source.
Note that as prior s: or <SID> access is no longer needed for scripts to be
given a SID, <SNR>s in tests that already use anonymous :sources such as
echo_spec.lua need to be adjusted.

Also note that we can potentially support adding profiling support for anonymous
scripts now. :)
seandewar added a commit to seandewar/neovim that referenced this pull request May 13, 2022
Unfortunately, even after our changes that allow for <SID> to be always usable
in anonymous Vim scripts, the changes in neovim#15079 break this for Lua scripts due
to the use of SID_LUA over a unique SID in places such as nvim_exec.

Instead, use the special SID offsets to identify scripts from Lua contexts in
which nlua_set_sctx can be used. Encoding it this way avoids the need to store
such information in an allocated script item or elsewhere.

However, this approach produces ugly script IDs, so it's only used when :verbose
logging for Lua is enabled. As a result, it's now even more strongly recommended
to start nvim as `nvim -V1` rather than to set verbose=1 in the middle of a
session, otherwise tracing for previously sourced Lua scripts before verbose
was set will not work.

Remove the previous LastSet sctx dancing logic when accessing "s:" scope. It's
no longer needed as anonymous Lua scripts now get a unique SID.

Add some tests that would previously fail due to bugs with the old verbose Lua
approach.

Also, remove find_sid (unused leftover from the autocmd API PR) and change
sid_T's type to a fixed-width type (int64_t).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lua stdlib
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants