-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
This comment has been minimized.
This comment has been minimized.
5b9508f
to
e2db8be
Compare
989950d
to
9840b78
Compare
This comment has been minimized.
This comment has been minimized.
you could also mark it as a draft :) |
I keep forgetting which actions are set to run on draft PRs and which aren't. Maybe we can document this in Contributing.md? |
This comment has been minimized.
This comment has been minimized.
1c87e05
to
8e52e2b
Compare
8e52e2b
to
3722893
Compare
@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 I think it would have been great if we could make nvim_exec execute with |
a132910
to
ab94768
Compare
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. :)
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. :)
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...
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.
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.
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. :)
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).
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. :)
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).
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.
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. :)
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).
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.
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. :)
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).
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.
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. :)
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).
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.
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. :)
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).
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.
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. :)
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).
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.
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. :)
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).
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.