reddit / emacs
How can I turn Emacs into a good Python IDE?
SteveTheGreate · 2022-12-25 10:59
So I'm using the excellent Doom Emacs, and I use it for a wide array of things. Text editor, journal, calendar, and most importantly, as my Python IDE of choice.
However, I still feel that my configuration is somewhat lacking for Python. I'm using python mode, the PYLS LSP server, and yas-snippet, yet I feel it's still missing a lot of good features that IDEs like VS Code provide.
​
I've tried many other things, like Eglot, Pyright, and Elpy, but they all come with many problems of their own. What packages would you recommend so I can make Emacs into a truly great IDE for Python?
grimscythe_ · 2022-12-25 11:02
What are the features you're missing?
kkvi115 · 2022-12-25 11:07
I want to beef up my setting for Python Dev!
SteveTheGreate · 2022-12-25 11:07
Well one thing is that LSP mode is quite slow in Emacs, on my desktop it's okay, but on my older Thinkpad it means that there is a significant slowdown.
Another thing would be the autocomplete suggestions, I just find that VSCode in particular has just far better ones than the ones I see with LSP-mode in Emacs.
I think those are the two major things I'm currently lacking.
etuu · 2022-12-25 11:11
LSP can depend very much on which server it talks to. I'm not big on python, however from experience with other languages it's been worth to try some different ones.
If you want something more lightweight I recommend looking into eglot, it's just another frontend for LSP. I find it great.
grimscythe_ · 2022-12-25 11:13
The slowness can usually be resolved by using the native json parser in Emacs 28. If by chance you're on older Emacs on your ThinkPad, upgrading it might be a significant change. There are also other tips and tricks about performance on the Emacs-LSP docs page.
The suggestions is a weird one since both VSCode and Emacs use the same thing under the hood. If anything would be different, it would be the order of suggestions.
Now, Pycharm might have different suggestions because it uses its own indexing and has its own "system" so to speak.
SteveTheGreate · 2022-12-25 11:25
Yeah I've already applied most of these tweaks, although they did make a slight difference, it's still quite slow on my laptop.
What I found really interesting was that other LSP servers, like Pyright, were EXTREMELY fast, but they have other problems. Pyright for example doesn't add parentheses if you autocomplete a function, which is very strange, and I found no way to fix that.
grimscythe_ · 2022-12-25 11:29
Some do or don't implement certain features. There's no other way or saying this in any other way than: it's all pretty messy, as is majority of software.
SteveTheGreate · 2022-12-25 11:32
Eglot is useful, but it does come with some problems of its own. I know it sounds like a small complaint, but for example when you autocomplete a function, it doesn't automatically add parentheses, it's small stuff like that which make the experience on IDEs like VSCode so great.
koalillo · 2022-12-25 12:41
Note that VS Code uses the proprietary Pylance as its LSP provider, which is likely not what the OP uses on Emacs.
I use Elpy, which is based on Jedi. It works quite well, although I run it in on relative fast machines (a Carbon Gen 3, i5; a beefy T490s).
TheIsletOfLangerhans · 2022-12-25 12:46
I used anaconda-mode and company-anaconda a while back and found it to be a good setup that didn't require much configuration.
SteveTheGreate · 2022-12-25 13:15
I'll check it out, thank you.
cradlemann · 2022-12-25 14:52
When I was working with python I used pyright for sure.
MWatson · 2022-12-25 15:44
I still run with python-mode. Just the basics like load file, redefine functions, pretty good REPL are good enough for me.
BTW, I use Emacs about 50% of the time, and PyCharm and VSCode each about 25% of the time. Python mostly when a program is single-file based, and I am in hacking mode.
gry3000 · 2022-12-25 17:20
Try `LSP-Bridge`,
I've been using it for just a week. It's blazing fast. and I don't think that I'll go back to `eglot` or `LSP` for anytime soon.
Imaginary_Ad307 · 2022-12-25 17:53
I use prelude, with a minimal personal config.
GeekSync · 2022-12-25 18:09
I am using eglot and python-mode. So far good and some random hiccups as it freezes. However, I am a noob developer so your requirements may be more than mine.
Awkward_Tradition · 2022-12-25 18:25
>python~~-mode~~
>pretty good REPL
Choose one
AngryFilament · 2022-12-25 19:05
Tbh if you're working on a large project and you would like things to 'just work', it might be better to just move to pycharm. It's built specifically for this use case and min-maxed in a way that emacs can't be without significant time investment.
GreenSubstantial4469 · 2022-12-25 20:25
> it's small stuff like that which make the experience on IDEs like VSCode so great.
Funny. That's the kind of thing that I usually turn off, because most often they're put in the wrong places/contexts and aren't too difficult to type.
SteveTheGreate · 2022-12-25 20:46
Pyright is by far the fastest LSP server I've used, but I find that it's autocomplete is very very lacking. It doesn't add parentheses for example after functions.
SteveTheGreate · 2022-12-25 20:48
That looks very interesting. I'll check it out and tell you my thoughts!
SteveTheGreate · 2022-12-25 20:51
I know it sounds silly, but I love Emacs so much that I'd rather stick with it even if it means losing out on some things like Python development.
I just have everything in Emacs, it's so convenient.
SteveTheGreate · 2022-12-25 20:53
Different strokes for different folks!
GreenSubstantial4469 · 2022-12-25 20:55
To each their own, but AFAICT, this isn’t an LSP configuration, more a default that can (and should be changed). On doom emacs, this is probably either done in company-mode or in the LSP configuration itself.
AngryFilament · 2022-12-26 00:52
Definitely not silly, if you're willing to make it happen in emacs, then that's the way forward.
The other commenters have pretty much covered everything I could contribute to python in emacs, so I don't have anything else to add here 🫥
ndpian · 2022-12-27 15:17
I was in the same boat as you - I stuck to Emacs for 2 years for python development, but eventually gave up and started using VSCode. Primarily b/c the remote development in VSCode is very stable and fast. I still have every other stuff in Emacs (journalling, email, etc) but for serious remote development I think I'll stick to VSCode for now, until some new package comes up deprecating TRAMP.
TheIsletOfLangerhans · 2022-12-30 19:11
Out of curiosity, did you find something that fit what you were looking for?
SteveTheGreate · 2022-12-30 19:40
Not really. Pyls and the python-language-server seem to be the best options for my needs. But I won't stop looking for anything better :)