emacs

ag 2025-04-03T20:46:04.843669Z

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.

ericdallo 2025-04-04T12:28:02.732779Z

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

ag 2025-04-04T18:45:18.802779Z

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

ericdallo 2025-04-04T18:46:46.137079Z

you mean python or clojure?

ag 2025-04-04T18:49:24.297999Z

clojure-lsp specifically. I haven't even opened a "big python" anything just yet.

ericdallo 2025-04-04T18:50:46.252989Z

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

ag 2025-04-04T18:55:39.112569Z

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!" πŸ™‚

πŸ˜‚ 1
ericdallo 2025-04-04T18:57:14.078639Z

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

ericdallo 2025-04-04T18:57:53.998309Z

then you can have cool metrics like this :)

ericdallo 2025-04-03T20:52:00.746299Z

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?

ag 2025-04-03T20:53:04.652559Z

Darn, turns out python-lsp-server doesn't even support workspace/symbols https://github.com/python-lsp/python-lsp-server/issues/237 facepalm

πŸ€·β€β™‚οΈ 1
ericdallo 2025-04-03T20:54:16.453789Z

there is textDocument/symbol too, but it's for a single file, not that useful for you probably

ag 2025-04-03T20:54:23.857139Z

And people with no Clojure experience be like: "but... but... lein, boot and deps... so much fragmentation... " laughcry

ericdallo 2025-04-03T20:57:33.965479Z

True

ag 2025-04-03T20:57:38.406899Z

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?

ag 2025-04-03T20:59:13.722539Z

I guess the "one and obvious way to do it" is to struggle and cry, hoping it will get better

xificurC 2025-04-03T21:01:41.584109Z

after some cursory search I'd say try pyright, it seems to be the zen one

xificurC 2025-04-03T21:04:45.793679Z

your problems started the moment you mentioned Python, which is (nth (words (first thread-posts)) 5)

Alex Miller (Clojure team) 2025-04-03T21:05:16.037979Z

the one way to do it is to fix it by making another one, obviously

πŸ“ˆ 4
xificurC 2025-04-03T21:05:38.622229Z

obligatory https://xkcd.com/927/

1
ag 2025-04-03T21:08:18.182179Z

> 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?

πŸ˜„ 1
Alex Miller (Clojure team) 2025-04-03T21:12:57.575069Z

shots fired ;)

ag 2025-04-03T21:16:05.265919Z

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.

2025-04-03T21:19:11.688149Z

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.

ag 2025-04-03T21:48:16.352269Z

goddammit... I can't get workspace/symbol to work with pyright either.

πŸ˜‚ 1
2025-04-03T23:10:48.628179Z

there's also pyrightbased, fwiw

ag 2025-04-03T23:35:44.914099Z

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.

πŸ‘ 1
2025-04-03T23:57:29.657899Z

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

πŸ™ 2
ag 2025-04-04T01:35:15.296169Z

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.