0

emacs version: 28.2 eglot version: 20221020.1010

After successfully using eglot with eglot-jl for some time when programming in julia, I now have to use python for a few small tasks, and I was looking to replicate the workflow.

After reading around, I tried many different things but I cannot get this working with use-package. I want to use the pyright language server, but I cannot see how to configure it for that - everywhere I read where people say they are configuring for that purpose, they just leave it as is, which led me to assume it's the default eglot config, but I checked eglot-server-programs and it listed some byte compiled stuff (which I assume can be a version of pyright).

Additionally, I am also confused with the package names "python" for the in-built python mode and "python-mode" from melpa, as there seems to be naming conflicts at play here.

For reference, here's my configuration for julia:

  (use-package julia-mode
    :mode "\\.jl\\'"
    :interpreter ("julia" . julia-mode)
    :init
    (setenv "JULIA_NUM_THREADS" "4")
    :config
    (add-hook 'julia-mode-hook 'company-mode)
    (add-hook 'julia-mode-hook #'yas-minor-mode)
    (add-hook 'julia-mode-hook 'julia-repl-mode)
    (add-hook 'julia-mode-hook (lambda () (setq julia-repl-set-terminal-backend 'vterm)))
    (add-hook 'julia-mode-hook 'eglot-jl-init)
    (add-hook 'julia-mode-hook 'eglot-ensure)
    (add-hook 'julia-mode-hook (lambda () (setq eglot-connect-timeout 120)))
    (add-hook 'julia-mode-hook (lambda () (setq eglot-autoshutdown t)))
    )

I've tried both leaving it unconfigured (and running M-x eglot manually) as it's supposed to work out of the box and the following:

  (use-package python
    :config
    (add-hook 'python-hook (lambda ()
                                  (setq
                                   python-indent-guess-indent-offset-verbose
                                   nil)
                                  )
              )
    (add-hook 'python-mode-hook 'company-mode)
    (add-hook 'python-mode-hook #'yas-minor-mode)
    (add-hook 'python-mode-hook 'eglot-ensure)
    (add-hook 'python-mode-hook (lambda () (setq eglot-connect-timeout 120)))
    (add-hook 'python-mode-hook (lambda () (setq eglot-autoshutdown t)))
    )

Both land me "[eglot] Sorry, couldn't guess for `python-mode'! Enter program to execute (or :):"

Do I actually need to install the pyright server by myself? Not even the pyright repository readme seems to imply this.

1 Answer 1

0

After I specified the interpreter with

:interpreter ("python3" . python-mode)

and manually installed pyright with

pip install pyright

it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.