coc.nvm 升级后提示jedi版本太旧解决方案

coc.nvim升级后,大概是coc-python版本在1.2.10以上时,在使用函数功能跳转时,会提示jedi version %s too old, requires >= 0.17.0。这个问题在github上显示已解决,解决方案是安装指定版本的coc-python

CocInstall [email protected]

但是这个方法并没有解决我的问题。这个版本的coc-python也是要求jedi版本大于0.17.0的。

因此我将jedi版本更新到了要求版本。

pip3 install jedi
# conda 如果只能安装0.16.0版本的话,可以先pip3安装,然后copy到conda的site-package文件夹下

但是依然报错,信息如下:

is_definition() got an unexpected keyword argument ‘include_setitem’, get_definition() got an unexpected keyword argument ‘include_setitem’

你只需要到你的conda的jedi库文件夹中,找到syntax_tree.py,和filter.py这两个文件,修改相应的is_definitionget_definition即可。

inference/syntax_tree.py
667:    node = tree_name.get_definition(import_name_always=True, include_setitem=True)

inference/filters.py
66:            name for name in names if name.is_definition(include_setitem=True)

删除include_setitem=True即可。


此外,推荐一个python函数跳转的插件jedi-vim
vim-plug安装方法:

Plug 'davidhalter/jedi-vim'

相关配置如下:

let g:jedi#goto_command = "<leader>d"
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#goto_stubs_command = "<leader>s"
"let g:jedi#goto_definitions_command = "gd"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>n"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>r"

这个跳转要比coc自带的要好一些,coc函数跳转默认你对文件进行了修改,当你使用Ctrl-O返回原文件时,需要保存一下跳转文件或者返回一次修改(按一下u)。但是jedi-vim不会对跳转文件进行修改。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章