In nvim 0.7, We can now pass a lua function as a callback to create_autocmd
now.
This is good for writing code, but I found it is not that easy to debug the contents (get the location of where it defines/what it is happening) of autocmd if it is written by others.
Taken an example, :redir > autocmd.txt | au | redir END
will write the existed autocmds to autocmd.txt,
and if the autocmd is defined via vimL, we can see clearly what the contents is, but if it is written
in lua callback, I don’t know what the content is, making the debug more tough.
Is there an easy way to get to located where/how the autocmd is defined (in source code)?
An excerption of the autocmd.txt
cmp_nvim_lsp InsertEnter
* lua require'cmp_nvim_lsp'._on_insert_enter()
gitsigns_blame InsertEnter
* <Lua function 47>
We clearly see that, if the autocmd is written in vimL, I know that the autocmd does: calling cmp_nvim_lsp._on_insert_enter()
, then it is easy to go to the source code to find what is happening.
But for the autocmd defined by gitsigns_blame
, I don’t know what the function is at all, and it is hard to find the corresponding source code.