0

In order to solve various probelms with eglot and completions, I made sure that both python and pip are set respectively within emacs to ~/.pyenv/shims/ipython and ~/.pyenv/shims/pip, as they are in my terminal.

But now, I have another problem: whenever there is output in the shell, there is no newline after it (see below).

I tried advising comint-preoutput-filter and comint-output-filter but none of this helped.

However, the problem disappears if I (setq python-shell-interpreter "/opt/homebrew/bin/ipython") instead of "~/.pyenv/shims/ipython".

I use -i and --simple-prompt as arguments in both cases of course.

No newline after output

1 Answer 1

1

I don't know a 'direct' solution to your problem, but generally you don't have to run the language server in a virtual environment. Instead, you should configure the server to use some virtual environment (for the completions). For eglot, the usual way to do this is via a directory local variable (see here). Also, to configure a virtual environment for the python shell (M-x run-python), I think you should configure the python-shell-virtualenv-root variable.

For example, for the python language server you should configure jedi to use some virtual environment by creating a .dir-locals.el file with something like the following lines (these lines also set your python-shell-virtualenv-root, of course this might result in the 'no newline' problem you are describing but I don't know how to fix that problem. Maybe just use the standard python interpreter)

((nil (python-shell-virtualenv-root . "~/path/to/root/of/virtualenv")
      (test-test . python-shell-virtualenv-root) 
      (eglot-workspace-configuration
       :pylsp (:plugins
               (:jedi
                (:environment "~/path/to/root/of/virtualenv"))))))

see here.

If you are using pyright, then you can find more info here.

The lines above should work for pylsp, but consult the eglot docs for how to configure eglot more specifically.

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.