emacsorphanage / company-jedi

Company backend for Python jedi
100 stars 12 forks source link

Function Signatures are not displayed in mini-buffer #24

Open jack836 opened 6 years ago

jack836 commented 6 years ago

Could not get function signatures to be displayed in mini buffer as shown here

Some points of concern

My .emacs

(add-hook 'python-mode-hook 'company-mode)
(company-quickhelp-mode 1)

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'my/python-mode-hook)
(setq jedi:complete-on-dot t) 
(setq jedi:tooltip-method 'pos-tip)
;; (setq jedi:tooltip-method nil) 

I tried setting jedi:tooltip-method to both nil and pos-tip, nothing changed.

The output of jedi:show-setup-info is as follows

`; Emacs Lisp version: (:emacs-version "27.0.50" :jedi-version "0.2.7" :python-environment-version "0.0.2alpha0") ;; Python version: ((:version "3.5.3 (default, Jan 19 2017, 14:11:04) \n[GCC 6.3.0 20170118]" :file nil :name "sys") (:version "0.12.0" :file "/home/svi/.emacs.d/.python-environments/default/lib/python3.5/site-packages/jedi/init\ .py" :name "jedi") (:version "0.0.5" :file "/home/svi/.emacs.d/.python-environments/default/lib/python3.5/site-packages/epc/init__.\ py" :name "epc") (:version "0.0.3" :file "/home/svi/.emacs.d/.python-environments/default/lib/python3.5/site-packages/sexpdata.py" \ :name "sexpdata")) ;; Command line: (:virtualenv "/home/svi/.virtualEnvs/python3/bin/virtualenv" :virtualenv-version "15.2.0\n") ;; Customization: ((jedi:complete-on-dot . t) (jedi:doc-display-buffer . display-buffer) (jedi:doc-hook view-mode) (jedi:doc-mode . rst-mode) (jedi:environment-root) (jedi:environment-virtualenv) (jedi:get-in-function-call-delay . 1000) (jedi:get-in-function-call-timeout . 3000) (jedi:goto-definition-config (nil nil nil) (t nil nil) (nil definition nil) (t definition nil) (nil nil t) (t nil t) (nil definition t) (t definition t)) (jedi:goto-definition-marker-ring-length . 16) (jedi:imenu-create-index-function . jedi:create-nested-imenu-index) (jedi:import-python-el-settings . t) (jedi:install-imenu) (jedi:install-python-jedi-dev-command "pip" "install" "--upgrade" "git+https://github.com/davidhalter/jedi.git@dev\

egg=jedi")

(jedi:key-complete . [C-tab]) (jedi:key-goto-definition . [67108910]) (jedi:key-goto-definition-pop-marker . [67108908]) (jedi:key-related-names . "^Cr") (jedi:key-show-doc . "^Cd") (jedi:server-args) (jedi:server-command "/home/svi/.emacs.d/.python-environments/default/bin/jediepcserver") (jedi:setup-keys) (jedi:tooltip-method pos-tip popup) (jedi:use-shortcuts) (python-environment-default-root-name . "default") (python-environment-directory . "~/.emacs.d/.python-environments") (python-environment-virtualenv "virtualenv" "--system-site-packages" "--quiet")) `

When I open a python file i receive a warning and Eldoc is loaded as shown below

screen shot 2018-05-08 at 20 01 10

Once it starts autocomplete, Eldoc disappears (probably due to limited space)

screen shot 2018-05-08 at 19 53 22

Finally no signatures completion when inside function paranthesis

screen shot 2018-05-08 at 20 05 42

I love this feature and would be great if if works. Any help is highly appreciated.

chameco commented 6 years ago

I'm having the same issue. Calling jedi:get-in-function-call with point inside the parentheses yields

deferred error : (error "\"AttributeError(\\\"'Definition' object has no attribute 'get_code'\\\",)\"")

which makes me think the problem is possibly inside Jedi itself.

jack836 commented 6 years ago

I get the same error too when running jedi:get-in-function-call. But I get it (function signatures) to work when I use elpy as a front-end to Jedi by setting (setq elpy-rpc-backend "jedi"). So I am confused now???

jack836 commented 6 years ago

I came to know that, this issue has been already dealt with; see 294 and 296. I manually modified 3 lines in jediepcserver.py (as shown in the above links) and it works now.

srustamo commented 6 years ago

@jack836 did you need to re-run the setup? I changed those three lines, with no effect.

srustamo commented 6 years ago

I re-run the setup, and got things running. Where do you see (supposed to see) the function sigs? Minibuffer? Tooltip? I see the sig as a tooltip in the buffer itself (see screenshot).

screenshot 2018-07-05 21 08 54
ghost commented 5 years ago

@jack836, would it be possible to paste the three lines you modified please?

Islam0mar commented 5 years ago

@noelfarrugia09

line 103: params=[p.name for p in call_def.params], 

line 105:  call_name=call_def.name,

line 179:   return list(map(get_names_recursively, jedi.api.names(*args))) 

then reinstall server "for me I have to delete then install".

ghost commented 5 years ago

Thanks! The modification seems to work when tested using the function jedi:get-in-function-call. However, it's not working as expected. When I call the function jedi:get-in-function-call with the cursor between the braces of a function I get the parameters shown in the mini-buffer as shown in the figure below; however, as soon as I start typing, the function arguments are hidden.

My question is how can I get the function signature to show automatically and keep it in the mini-buffer?

My current setup for company and jedi:

;; Installing company mode
(use-package company
  :ensure t
  :config
  (add-hook 'after-init-hook 'global-company-mode)
  (setq company-idle-delay 0)  ;; Disable the delay
  (company-tng-configure-default))  ;; Enable tab style completion

(global-set-key (kbd "C-c c") 'company-complete)

;; Installing company quick help
(use-package company-quickhelp
  :ensure t
  :config
  (company-quickhelp-mode))

;;; Company jedi
(use-package company-jedi
  :ensure t)

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))

(add-hook 'python-mode-hook 'my/python-mode-hook)

(setq jedi:environment-root "default")  ; or any other name you like
(setq jedi:environment-virtualenv
      (append python-environment-virtualenv
              '("--python" "/usr/bin/python3")))
(setq jedi:complete-on-dot t)
(setq jedi:tooltip-method nil)
(setq jedi:get-in-function-call-delay 0)

image

Thanks in advance!

Islam0mar commented 5 years ago

You have to enable jedi-mode. Change this:

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi))

To

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi)
  (lambda () (setq jedi-mode t))))

When you idle for a while, it would display it again.

ghost commented 5 years ago

@CatchMeFastFat Thanks a lot!!!!!!! I had to enable jedi-mode. Your code did not work but managed to make it work using the following code:

(defun my/python-mode-hook ()
  (add-to-list 'company-backends 'company-jedi)
  (jedi-mode))

Thanks again! :+1:

dvincentwest commented 5 years ago

Confirming that the above fixes are working for me running latest emacs on Windows 10 x64. Does this mean that this is a bug (maybe because Jedi API has been updated or something to that effect) and this needs to be fixed? Modifying 3 lines seems a fairly small ask, but does it break something else?