5

TL;博士

当我有兴趣修复实际问题而不仅仅是删除坏插件时,如何找到确切的位置vim或错误开始的位置(哪个文件?)?nvim有什么比strace猜测更能找到错误来源的吗?

问题

我经常在我的vimnvim配置中添加一个插件,最终在钩子上出现错误(缓冲区打开、关闭、写入):

"test.py" [New] 0L, 0C written
Error detected while processing function 343[12]..272:
line    8:
E716: Key not present in Dictionary: _exec
E116: Invalid arguments for function get(a:args, 'exec', a:1['_exec'])
E15: Invalid expression: get(a:args, 'exec', a:1['_exec'])

问题是,我不知道这些来自哪里,只得到一些未知文件的行号,我知道这不是我的vim/ nvimconfig 文件。

4

1 回答 1

7

在某个地方,您有一个定义了字典的插件anonymous-functions(查看与此标签相关的帮助)。

对于好奇的人,它是这样完成的:

let d = {}
function! d.whatever() abort
   throw "blah"
endfunction

当你执行这个函数时,你会得到你当前观察到的那种错误。这就是为什么我停止以这种方式工作以更喜欢:

let d = {}
function s:whatever() abort
   throw "blah"
endfunction
let d.whatever = function('s:whatever') " a workaround is required for older versions of vim
" At least this way I'll get a `<SNR>42_whatever` in the exception throwpoint, and thus a scriptname.

这就是为什么。现在,回到您的问题,AFAIK,您唯一能知道的是已调用的两个函数:

  • 在第 12 行:function {343}调用了
  • :function {272}其中包含第 8 行的错误。

多亏了这两个命令(可能以 为前缀:verbose,我记不清了),您将获得这两个函数的源代码,您应该能够使用它们来 grep 插件以了解它出现的位置。

于 2016-10-05T17:46:37.947 回答