Exafunction / codeium.el

Free, ultrafast Copilot alternative for Emacs
https://www.codeium.com
MIT License
412 stars 13 forks source link

Suggestion: Mention integration with Elpy in troubleshooting resources #59

Open Firewolf34 opened 10 months ago

Firewolf34 commented 10 months ago

Elpy.el is one of the premier Emacs extensions for Python, which a lot of new Python devs in Emacs may be using.

If they, like me, encountered an issue where /when Elpy is enabled, the Codeium.el company integration does not work/, they will need to prevent Elpy from removing their Codeium.el company-capf backend.

Cause: When Elpy is running, if it has it's "Company Module" enabled, this section of code will remove the company-capf backend to prevent "unwanted interference" with the elpy-company-backend: https://github.com/jorgenschaefer/elpy/blob/7ff8ffa918411887d165764f7a5a12bc46646e73/elpy.el#L2820

To avoid this, one can add the company-capf backend back into their company-backends buffer-local-variable, in a python hook, at a high-priority (e.g. 99). This way, Elpy will remove the company-capf, but then the new hook will just add it back. And it will be at the front of the list, so that Codeium.el gets highest company backend priority (runs first). Though I think this will stop most of the elpy suggestions which may not be ideal.

Using the example from the Readme.md of this project:

;; we recommend using use-package to organize your init.el
(use-package codeium
    ;; if you use straight
    ;; :straight '(:type git :host github :repo "Exafunction/codeium.el")
    ;; otherwise, make sure that the codeium.el file is on load-path

    :init
    ;; use globally
    (add-to-list 'completion-at-point-functions #'codeium-completion-at-point)
    ;; or on a hook
    ;; (add-hook 'python-mode-hook
    ;;     (lambda ()
    ;;         (setq-local completion-at-point-functions '(codeium-completion-at-point))
;; <---------- Begin modified section ------------>
               (setq-local company-backends (cons 'company-capf company-backends))) ;;Add capf to front of company-backends list
              99) ;;set the priority to highest.

I hope this helps anyone who may have this issue!

I understand that you can use cape as well and that may be a better solution.

My suggestion is to add a note to this README.md that specifies that this may happen to avoid troubleshooting confusion. Thanks for the awesome emacs extension, Codeium developers!

Firewolf34 commented 10 months ago

Is the only way to get Codeium and Elpy backends to run simultaneously (currently) to use cape?