How to properly setup Jedi with elpy in emacs?

血红的双手。 提交于 2021-02-06 20:13:18

问题


I am using emacs with elpy as mode for working with python code. I have also installed Jedi for, mainly, two things: go to definition functionality it provides and autocompletion.

However, I have run into the following problems with this setup:

  1. Jedi completion is not triggered by key commands. It appears automatically, but sometimes too late for my tastes, and i would prefer to try and invoke it earlier. However, despite there being a Jedi: Key complete option in customisation pages, it does not seem to have any effect. From the other hand, elpy's company-mode's shortcut does that on C-M-i.
  2. When both Jedi and company-mode are on, sometimes two completion lists appear (with same contents; i have also company jedi backend installed) - but only one of them allows changing selection (completion list from Jedi), but on Enter selection from company is used. This is not usable.

Is there any way to setup things so that i will have autocompletion from a single source with jedi backend and jedi's go to definition?

This is how i currently setup jedi in my init.el:

(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)

回答1:


According to the document of elpy, you just need to install elpy package. Then use the config below

(elpy-enable)  
(setq elpy-rpc-backend "jedi")  

That's all. You can visit https://github.com/jorgenschaefer/elpy for more information.



来源:https://stackoverflow.com/questions/29809061/how-to-properly-setup-jedi-with-elpy-in-emacs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!