omeow · 2022-06-15 08:36
I am trying out different packages around python development in emacs. I must confess I haven't had a lot of success getting everything to work and I am somewhat confused. So I am looking for some suggestions.
# Elpy
Elpy seems to come with a lot of features out of the box and I am able to get it to work. However, I have noticed a noticeable lag when typing code.
It may be due to `flymake`. I am wondering if someone has found a good workaround this?
# LSP mode
I couldn't get it to work. My modeline says `LSP[Disconnected]`. I found this old [thread](https://github.com/emacs-lsp/lsp-mode/issues/523) but it wasn't very helpful. Does anyone have a solution for this?
# Eglot mode
I could get it to work and it worked pretty well out of the box. I am wondering how to get `elpy` like features: quick code navigation, testing, opening interpreter for the buffer?
tldr:
- Is there a noticeable lag in elpy? Is the lag just to `flymake`? Is there some customization that gets rid of the lag (or `flymake`)?
- Can Eglot be customized to get elpy like features: code navigation, IDE like behaviors?
- How to get `lsp-mode` to connect to the server or (debug this issue)? Is it possible to customize it with features similar to elpy?
Thank you for your time and suggestions!
yyoncho · 2022-06-15 08:58
> LSP mode
I couldn't get it to work. My modeline says LSP[Disconnected]. I found this old thread but it wasn't very helpful. Does anyone have a solution for this?
Most likely you are calling `M-x lsp-mode` not `M-x lsp`
[deleted] · 2022-06-15 14:41
Though I haven't used Elpy, I have used anaconda-mode, lsp-mode, and eglot. I eventually stuck with eglot because it feels more simplistic than the others.
What sort of code navigation are you looking for? You can get a lot of mileage out of these commands:
* M-. (go to definition)
* M-, (go back)
* C-x p g (grep in project)
I use this function to pop a Python interpreter in the project root:
(defun run-python-in-project-root ()
"Executes run-python in the project root."
(interactive)
(let ((default-directory (cdr (project-current))))
(run-python)))
omeow · 2022-06-15 22:28
I saw some thread about that. I will double check again. Are there elpy like code navigation options in \`lsp-mode\` ?
omeow · 2022-06-15 22:30
Here is an example: [https://elpy.readthedocs.io/en/latest/editing.html](https://elpy.readthedocs.io/en/latest/editing.html)
project based navigation is fine with projectile.
redguardtoo · 2022-06-16 00:44
If you are using Emacs 26.2+, flymake is actually setup by native "python-mode.el`.
If you plan to continue using `flymake-mode`, `(setq flymake-no-changes-timeout nil)` to disable `flymake-after-change-function` or set `flymake-no-changes-timeout` to a bigger value.
Or you can use https://github.com/redguardtoo/lazyflymake instead of `flymake-mode`. `lazyflymake` only checks code when saving current buffer. You need turn off `flymake-mode` before using `lazyflymake`.
BUT, knowledge of Lisp and command line tools is required.
- `elpy` turns on `flymake-mode`, so you need turn it off manually
- You also need know how to install the command line linter `pyflakes` or `flake8`. See `python-flymake-command`.
yyoncho · 2022-06-16 04:34
Not a 100% familiar with elpy but I would say yes.
aiguofer · 2022-11-27 19:56
Came here looking for insight from others as I want to consider trying `lsp-mode`. I've been using `elpy` for a long time and it offers all the features I'm looking for, but I'd like to have a bit more consistency when working with different languages so I'm considering giving `lsp-mode` a go.
I do find `elpy` a little slow sometimes, but I really like the features. Main things I love:
* code navigation (including go-to-def/assignment)
* autodoc, especially for reminding me params (and which param I'm currently in)
* code completion
* shell integration (for sending code snippets)
* pdb integration (especially appreciate seeing which line is on when stepping through)
They have a section in their docs [to replace flymake with flycheck](https://elpy.readthedocs.io/en/latest/customization_tips.html):
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))