jwiegley / use-package

A use-package declaration for simplifying your .emacs
https://jwiegley.github.io/use-package
GNU General Public License v3.0
4.39k stars 259 forks source link

How to start python-mode, eglot and company the use-package way? #975

Closed buhtz closed 1 year ago

buhtz commented 2 years ago

Sorry for asking via an Issue but I couldn't find another channel. But I am highly interested in feedback from the use-package maintainers and/or professionals. This is an X-Post.

I want to use Emacs (27) in-build python-mode. The language server eglot and the company-mode should start also when an Python file is opened.

This config works but I am not sure if this is a good solution. And there is also an element I do not understand.

; ....
; language server (replacement for lsp-mode)
(use-package eglot)

(use-package python-mode
  :ensure nil  ; makes sure that Emacs in-build python-mode is used
  :hook
  (python-mode . eglot-ensure)  ; connect to language server when py-file is opened
  :custom
  (python-shell-interpreter "python3")
  )

(use-package company
  :after eglot  ; this line alone does not help to start company
  :hook (eglot-managed-mode . company-mode)  ; starts company when eglot is started
)

(use-package company-box
  :hook (company-mode . company-box-mode))

; .....

Do I understand this code correct?

  1. When python-mode is started it starts also eglot via the :hook.
  2. The company-mode is started when eglot starts because of the :hook on eglot-managed-mode.

Why do I need the :after eglot in (use-package company...?

skangas commented 1 year ago

This is more a general support question on how to configure individual packages than a bug report. If you need help with that, this is unfortunately not the best forum. Maybe Reddit r/emacs can help.

You can find help for :after in the README.