Fork me on GitHub

I'm also excited about this and currently reviewing PRs to clj-kondo which will make the static analysis via clojure-lsp even more awesome (it is using clj-kondo as a lib). The funding by Clojurists Together is affecting all of these projects at the same time :)

👍 6
clj-kondo 6

Yes, and the assistance we have gotten from the clojure-lsp team is totally lovely. We've been able to work fast and iterate together. And I think most of Brandon's (the Calva guy who's funded currently) work has been on the clojure-lsp. In Calva we get a lot of this for almost free since vscode is LSP home turf.


It is extra nice with the combo of static and dynamic. So now Calva is a really useful tool for opening and examining a project w/o starting it. Then the analysis gets even better when the repl is connected. And it is then better than it was with only the repl connection. I think we can venture deeper here. If we start using clojure-lsp for linting we will reach clj-kondo's linting powers that way and could add CodeActions to offer fixes for some of the stuff that don't spark joy.


have you talked to @bozhidar about clojure-lsp and cider integrations?


I have not had that good an experience with clojure-lsp and Emacs, so far. There is lots of cross-over which leads to conflict in the UI. It seems to require switching off all the conflicting features and unfortunately that has not been documented well as yet.


I beleive people have it working, but I dont really understand clojure-lsp terminology enough to understand what is going on. I am also weary of adding IntelliJ-like back-ground processing, which seems bad in Emacs when I tried it a few months ago as it was blocking the Emacs thread.


Right. I guess my main concern is that the find-usages static analysis is so much better than the dynamic one.


As the dynamic one (currently in Cider) doesn’t seem to include the line-numbers.


Not something I think I use, I seem to rely on the really effective Emacs tools for finding things and refactoring.


Hopefully someone will actually demonstrate what you are describing. Its something I never understood, even when using IntelliJ


So in a jacked in emacs, I can press C-c C-? r when on a Clojure symbol. This brings up a buffer with all the references to that symbol. Each occurrence has a “button” to push which gets you to the function in which the symbol is used. In Calva and Intellij, this gets me to the line where the symbol is used. I could achieve something similar I guess with cunning uses of grep, (especially because we tend to always use aliases, and don’t refer). My grep-fu stops when I have a fn called id in a ns named ardoq.core, Then I would have to figure out all the ways we alias ardoq.core (which as it happens is only core) and then build a grep pattern which finds id both as a qualified symbol (`core/id` ) and as a unqualified symbol (`id`), because I’d have to find the references in ardoq.core as well. Now, this fn could be used in a higher order context like (map core/id xs) and it might be used in a normal context (core/id foo), and both of these qualified (as here) or unqualified.


I’d be happy to elaborate more if that’s useful.


I'm well aware of the shortcomings of the current approach in CIDER, although clj-refactor.el already does something quite similar to what clojure-lsp does. Integrating clojure-lsp in CIDER makes little sense directly, as CIDER was designed to be REPL-powered and clojure-lsp opted for the static analysis route. That's also the main reason why I avoided implementing find-references with static analysis in the past as well - I wanted to stick to the core idea and avoid having to deal with the complexity added by the static analysis (e.g. keeping in sync the code and the ast, the initial project indexing and so on). I think the best way to add static analysis to CIDER is how clj-refactor did it (via middleware), but unfortunately the project hasn't been actively maintained for a while now. I'm guessing that it also makes some sense to using clojure-lsp until you jack in, but then again - if find-references are the only major advantage, you can obtain them in a simpler fashion (e.g. by using or a similar approach). When I need to look up references I simply use projectile-grep and it gets the job done pretty well for me. 😄


In general - it's not hard to come up with a better find-references for CIDER, but it's hard to find time to work on this.

❤️ 9

Anyways, if you have any concrete ideas about improving the usage of CIDER alongside clojure-lsp feel free to share them here


@slipset If I understand correctly, the static analysis helps with accurate refactoring ? I find it easy to refactor across projects using Emacs tools, e.g. helm-swoop then C-c C-e to edit search results which will save changes back to the original files when finished. I always using meaningful names, so this works very well in my projects. I dont really understand why people write weak and inconsistently named code, its like they don't really care about anyone working with it. I hope that clojure-lsp doest encourage more weak naming of things


@bozhidar I do find anakondo far more usable with CIDER than clojure-lsp (which requires knowing which things to turn off to avoid conflict). I started using anacondo in 2020 I think and the only reason I stopped was it killed startup time. My Emacs setup uses layouts which automatically opens a dozen or so Clojure projects and means any LSP server will reanalyze the projects on startup. This least to over a minute to start Emacs. This would be very bad for live demos should Emacs crash.


@bozhidar I have consistently failed in having expez work on clj-refactor again. Even though he has 10% time to do so at work 😕


I guess there’s a level of bitrot on that project that doesn’t quite suite his palate.


I guess so. The project started off strong, but it's slow degraded and now it needs a lot of love, as some functionality has been broken for ages.


I'm tackling a few smaller problems there now and then, but I don't even use clj-refactor, so my incentive to spend time on the project, when I'm buried with issues in the other projects is fairly small.


I hear ya.


@slipset everything I know about lsp with Emacs so far is in this issue Some of the documentation concerns are to be addressed, although I am unaware of what time frame that will be (I did ask about 8 months ago it seems).


Hmm, this is starting to look really good, @pez. I will have to do a serious round of configuring calva keybindings to my liking.


Oh, add missing require is there 🙂


find occurences too.


I know @jr0cket is working with VSpaceCode keybindings. Not sure if that is your cup of tea, but anyway.


I’ll jump on over to #calva with some immediate questions


There are some here as well. Probably quite out-dated.


A Cider dude walks into a bar ... he should have ducked ... welcome @bozhidar


@slipset invoked a powerful incantation that ended up summoning me here straight from the pub! 😄

❤️ 6
🍻 3

Cheers! calva