elpy
elpy copied to clipboard
It seems impossible to prevent automatic completion after a dot, regardless of company settings
Summary
I don't like company and eldoc popups to be triggered automatically. I much prefer triggering them manually with a kbd when I need them. This is how I have configured company and it works perfectly everywhere... except for elpy which seems to override my company settings.
My my config, I have:
(setq company-idle-delay nil)
(setq company-minimum-prefix-length 10)
The first one should be sufficient to stop company from auto-completing without being manually triggered (and it works well elsewhere). The 2nd one is thus not useful, but I am adding it here to show that elpy does not follow these settings.
Whenever I use a dot in a python-mode buffer, the company auto-completion popup pops up automatically, even if there is only one character (e.g. t.
) and even if it shouldn't popup in the first place.
So my questions are:
- Why isn't elpy respecting my company settings?
- What could I do to have company behave in my python buffers the way it does everywhere else?
Of course, I could disable company in python-mode and that would solve those annoying popups when I don't want them. But then, of course, I wouldn't be able to trigger them with a kbd when I do want them.
Thanks!!!!
My configuration
OS
Arch Linux (5.15.13-arch1-1)
Result of (elpy-config)
Emacs.............: 27.2
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: python 3.10.1 (/usr/bin/python)
RPC virtualenv....: rpc-venv (/home/marie/.emacs.d/elpy/rpc-venv)
Python...........: python 3.10.1 (/usr/bin/python)
Jedi.............: 0.18.1
Autopep8.........: Not found (1.6.0 available)
Yapf.............: Not found (0.32.0 available)
Black............: Not found (21.12b0 available)
Syntax checker....: flake8 (/usr/bin/flake8)
Elpy configuration in my init.el
(elpy-enable)
(setq elpy-modules
'(elpy-module-company elpy-module-eldoc elpy-module-pyvenv elpy-module-highlight-indentation
elpy-module-yasnippet elpy-module-django elpy-module-sane-defaults))
Note: I suspect that the problem has to do with the dot. After dot, there is automatic completion, regardless of company settings.
company-jedi has a variable about auto-completion after dot that can be set to nil to prevent this behaviour. Maybe a similar variable could be added into elpy???
Thanks!!!
The issue here is around elpy.el:2809 where the package quite rudely overrules your preferences. Just a few lines before, it sets a hook to override your preference for company-minimum-prefix-length. IMO, packages shouldn't override your customizations like this.
To work around this behavior, you can patch elpy.el or, I assume, you can put a hook somewhere to reset these variables to your preferred values after elpy clobbers them.
Does running the company settings in elpy-mode-hook
help with this?
(add-hook 'elpy-mode-hook '(lambda () (setq company-idle-delay nil) (setq company-minimum-prefix-length 10))
Yep, that hook seems to work to restore the original values for me.
On Fri, Mar 10, 2023 at 9:51 AM Gopar @.***> wrote:
Does running the company settings in elpy-mode-hook help with this?
(add-hook 'elpy-mode-hook '(lambda () (setq company-idle-delay nil) (setq company-minimum-prefix-length 10))
— Reply to this email directly, view it on GitHub https://github.com/jorgenschaefer/elpy/issues/1958#issuecomment-1464006792, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACIURZBHU32LAH5QHDNJ63W3NEYTANCNFSM5L2N26UA . You are receiving this because you commented.Message ID: @.***>
Closing this as resolved, since settings can be put in elpy-mode-hook