I'm having to start writing Python again, and already got a brain hemorrhage with all the options. First - I couldn't figure out which lsp-server option to use. Searched for Microsoft.Python.LanguageServer - found an old, archived repo. Then checked pyright - the project doesn't even state that it's an lsp-server, it just says: "Static Type Checker for Python", and I'm not sure what features of lsp I'd be missing there.
I settled on http://github.com/python-lsp/python-lsp-server, installed it, and started looking through configuration options and OMG. How do I decide which things I want and need - black or yapf or ruff, flake8, rope, mypy, pydocstyle, pylint, jedi; what is 'preload' plugin - the docstring for lsp-pylsp-plugins-preload-enabled just says "Enable or disable the plugin"
Holy fuck, and people have audacity to complain about Clojure tooling? At least we don't have dozens of linters with overlapping features.
Anyway, my main headache right now is that consult-lsp-symbols doesn't work and I'm not sure what's supposed to be feeding the data into it. Would love someone's insight on that specifically, and more broadly - I would like to borrow some Python-related things from your awesome Emacs config.
the LSP protocol has some fields that can be boolean or more complex objects to add more capabilities, https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceSymbolOptions, it means it supports workspace symbol + work done progress for that, which is those notifications like when clojure-lsp is initializing and prints "analyzing classpath", "discovering classpath", so when a feature has that, it can send this kind of notification to user, clojure-lsp only has that for the initialize request as all other features are pretty fast after initialized
Speaking of initialization, has anyone ever complained about it "being too slow"? I mean, it still is faster than I remember from my days of using IntelliJ. I was so happy for a few years not to deal with that all the time, and now with lsp-mode, I'm like "oh, god... this shit followed me here too" lolcry
you mean python or clojure?
clojure-lsp specifically. I haven't even opened a "big python" anything just yet.
indeed startup is the slowest thing in clojure-lsp, because it's when analyzes with clj-kondo, there were multiple improvements in the past and I'm always trying to improve it, but overall it's good enough to me even on huge projects, there are lots of caches too, for next times starts which helps a lot
Yes, that is my experience too - the initialization is such a small price to pay for all the other features you get from it. I can't really imagine how people do manage without it. I've forced my teammates to stop everything and setup lsp "THIS IS AN EMERGENCY!!! DO IT NOW!" π
yeah, we are in a stage where we are starting to get metrics from dev to use LSP, you may be interested on https://clojure-lsp.io/settings/#opentelemetry-integration, which we are using to get metrics of devs using clojure-lsp
then you can have cool metrics like this :)
I faced this same "what LSP to use" problem with python, ts and rust too, glad we have only one for clojure hehe.
Yeah, those LS expect you know deeply about the language tools like formatters and linters which is bad.
not sure it's a that good advice, but consult-lsp-symols use workspace/symbol LSP request, so maybe greping for it on the ls code and checking what tool it delegates?
Darn, turns out python-lsp-server doesn't even support workspace/symbols https://github.com/python-lsp/python-lsp-server/issues/237 facepalm
there is textDocument/symbol too, but it's for a single file, not that useful for you probably
And people with no Clojure experience be like: "but... but... lein, boot and deps... so much fragmentation... " laughcry
True
I fucking hate this already... How the fuck the entire community who talks so much about "The Zen of Python" and "There should be one - and preferably only one - obvious way to do it."... simply decided to turn it into npm-like-shit-hole?
I guess the "one and obvious way to do it" is to struggle and cry, hoping it will get better
after some cursory search I'd say try pyright, it seems to be the zen one
your problems started the moment you mentioned Python, which is (nth (words (first thread-posts)) 5)
the one way to do it is to fix it by making another one, obviously
> the one way to do it is to fix it by making another one, obviously And slap some "-alpha" in the name, so nobody complains that the thing is lacking some features?
shots fired ;)
Honestly, I couldn't care less if they had "-alpha", "-beta" or "-upsilon" in the name, as long it worked. That "most mature lsp-server implementation" doesn't even do the basic thing you'd expect from an lsp-server.
I'll add to the rant....
Python didn't standardize a file format for dependencies until 2020 https://peps.python.org/pep-0621/ and still very little adoption, there's all kinds of project files, even if you're lucky enough to see a pyproject.toml, you'll see a ton of different structures and little consistency.
goddammit... I can't get workspace/symbol to work with pyright either.
there's also pyrightbased, fwiw
pyrightbased is a stripped-down version of pyright (turns out, not really), if the thing doesn't work with the full-fledged thing already, I'm not sure it would really work with the subset, but I'll give it a try - it worked.
Iβm also in the Python ecosystem and have a setup that works pretty well. Iβve also developed some REPL-specific Clojure inspired features to emacs. I wrote a post about the latest things Iβve been working on, and thereβs links to earlier posts with setup guides and of course the emacs config. (Also: I donβt use LSP, but use elpy) https://davidvujic.blogspot.com/2025/03/are-we-there-yet.html
Ooofff. @ericdallo - I got consult-lsp-symbols to work. @jasonjckn I was wrong about basedpyright - turns out - https://www.reddit.com/r/emacs/comments/1i8ywwk/newish_python_lsp_server_which_works_with_emacs/ "a stripped down version of pyright"
It took me a bit of digging, I tried: (pp (lsp--server-capabilities)), for clojure-lsp and basedpyright, first gives me :workspaceSymbolProvider t, second - :workspaceSymbolProvider (:workDoneProgress t).
I don't know what this workDoneProgress means, but it works. With a caveat though - it doesn't pre-populate the list. When I run the command in Clojure - the list has some values, I just need to type something to narrow (there's no guessing). For Python - the list initially is empty, but you start typing, and voila - things start showing up.
_
Thank you everybody for your insights.