Elpy: Disabling company-mode drop downs

Created on 16 Oct 2017  路  4Comments  路  Source: jorgenschaefer/elpy

Hi everyone, Is there a way to disable company-mode drop-down completion hints ? I wold like to use completion occasionally and "in a controlled fashion" i.e. I am not used to IDEs so the suddenly appearing drop-downs really distract me.

If it is not possible to disable only he drop-downs then disabling completion completely would also be OK.

Question

All 4 comments

This is a problem I ran into as well.
For the moment, their is no customization for that.

One solution is to completely deactivate elpy-company module (here: (customize-variable 'elpy-modules)), and to use the classical company customization to handle company behavior : (customize-group 'company).

Another solution to be able to enjoy elpy sane defaults for company is to overwrite the elpy-module-company function to remove the modification of company-idle-delay, like this:

(defun elpy-module-company (command &rest args)
  "Module to support company-mode completions."
  (pcase command
    (`global-init
     (require 'company)
     (elpy-modules-remove-modeline-lighter 'company-mode)
     (define-key company-active-map (kbd "C-d")
       'company-show-doc-buffer))
    (`buffer-init
     ;; REMOVED THIS
     ;; ;; We want immediate completions from company.
     ;; (set (make-local-variable 'company-idle-delay)
     ;;      0.01)
     ;; And annotations should be right-aligned.
     (set (make-local-variable 'company-tooltip-align-annotations)
          t)
     ;; Also, dabbrev in comments and strings is nice.
     (set (make-local-variable 'company-dabbrev-code-everywhere)
          t)
     ;; Add our own backend and remove a bunch of backends that
     ;; interfere in Python mode.
     (set (make-local-variable 'company-backends)
          (cons 'elpy-company-backend
                (delq 'company-semantic
                      (delq 'company-ropemacs
                            (delq 'company-capf
                                  (mapcar #'identity company-backends))))))
     (company-mode 1)
     (when (> (buffer-size) elpy-rpc-ignored-buffer-size)
       (message
    (format
     (concat "Buffer larger than elpy-rpc-ignored-buffer-size (%d)."
         " Elpy will turn off completion.")
     elpy-rpc-ignored-buffer-size))))
    (`buffer-stop
     (company-mode -1)
     ;; REMOVED THIS
     ;; (kill-local-variable 'company-idle-delay)
     (kill-local-variable 'company-tooltip-align-annotations)
     (kill-local-variable 'company-backends))
    ))

@galaunay is absolutely correct. Elpy is rather opinionated on how things should run, and does not try to be "everything for everyone". If you do not like what Elpy does with company-mode, disable Elpy's company-mode customization altogether by changing elpy-modules and configure company-mode however you like yourself :-)

Thanks for the answers! Used the second solution, @galaunay , thanks again :)

Great :-) Glad this works for you, and enjoy Elpy!

Was this page helpful?
0 / 5 - 0 ratings