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_definition
和get_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
不會對跳轉文件進行修改。