From ebfe083337701534887ac3ea3d8e7ad47f7a206a Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Sat, 8 Jan 2022 00:39:44 +0600 Subject: feat(lua): show proper verbose output for lua configuration `:verbose` didn't work properly with lua configs (For example: options or keymaps are set from lua, just say that they were set from lua, doesn't say where they were set at. This fixes that issue. Now `:verbose` will provide filename and line no when option/keymap is set from lua. Changes: - compiles lua/vim/keymap.lua as vim/keymap.lua - When souring a lua file current_sctx.sc_sid is set to SID_LUA - Moved finding scripts SID out of `do_source()` to `get_current_script_id()`. So it can be reused for lua files. - Added new function `nlua_get_sctx` that extracts current lua scripts name and line no with debug library. And creates a sctx for it. NOTE: This function ignores C functions and blacklist which currently contains only vim/_meta.lua so vim.o/opt wrappers aren't targeted. - Added function `nlua_set_sctx` that changes provided sctx to current lua scripts sctx if a lua file is being executed. - Added tests in tests/functional/lua/verbose_spec.lua - add primary support for additional types (:autocmd, :function, :syntax) to lua verbose Note: These can't yet be directly set from lua but once that's possible :verbose should work for them hopefully :D - add :verbose support for nvim_exec & nvim_command within lua Currently auto commands/commands/functions ... can only be defined by nvim_exec/nvim_command this adds support for them. Means if those Are defined within lua with vim.cmd/nvim_exec :verbose will show their location . Though note it'll show the line no on which nvim_exec call was made. --- runtime/doc/options.txt | 4 ++-- runtime/doc/various.txt | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'runtime') diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 56c65394f3..82214a2527 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6716,8 +6716,8 @@ A jump table for the options with a short description can be found at |Q_op|. global When bigger than zero, Vim will give messages about what it is doing. Currently, these messages are given: - >= 1 When the shada file is read or written. - >= 2 When a file is ":source"'ed. + >= 1 Lua assignments to options,keymaps etc. + >= 2 When a file is ":source"'ed and when the shada file is read or written.. >= 3 UI info, terminal capabilities >= 4 Shell commands. >= 5 Every searched tags file and include file. diff --git a/runtime/doc/various.txt b/runtime/doc/various.txt index e1b87f60ad..19e429fde2 100644 --- a/runtime/doc/various.txt +++ b/runtime/doc/various.txt @@ -461,10 +461,11 @@ g8 Print the hex values of the bytes used in the *:verbose-cmd* When 'verbose' is non-zero, listing the value of a Vim option or a key map or an abbreviation or a user-defined function or a command or a highlight group -or an autocommand will also display where it was last defined. If it was -defined manually then there will be no "Last set" message. When it was -defined while executing a function, user command or autocommand, the script in -which it was defined is reported. +or an autocommand will also display where it was last defined. If they were +defined in Lua they will only be located if 'verbose' is set. So Start +nvim with -V1 arg to see them. If it was defined manually then there +will be no "Last set" message. When it was defined while executing a function, +user command or autocommand, the script in which it was defined is reported. *K* [count]K Runs the program given by 'keywordprg' to lookup the -- cgit