Fork me on GitHub
#spacemacs
<
2021-02-19
>
practicalli-johnny17:02:29

I hope to take another look at Clojure LSP with Spacemacs at the weekend. I have a basic configuration but have a few challenges to solve, especially auto-formatting and aligning arguments and forms. I have switched off some of the cljfmt rules. LSP does seem to change some of the key bindings too, so a bit of a learning curve there. I am not sure how much benefit I will eventually get from LSP, but its an interesting journey.

πŸ‘ 6
clojure-lsp 3
jumar05:02:45

I would be very interested to hear more details later and have "bulletproof guide how to use LSP in Spacemacs" if that's possible πŸ™‚

lread14:02:25

Lassooing in @UKFSJSM38 - he’ll likely have tips and guidance for your adventure!

catjam 3
ericdallo14:02:14

Good to hear @U05254DQM πŸ˜„ This could help you: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/ I'm doom-emacs user not a spaceemacs user, but I heard that there is no way to use lsp and cider together in spaceemacs because of its config, it'd be nice to confirm that or fix that on spaceemacs side πŸ™‚

practicalli-johnny18:02:33

@UKFSJSM38 Thanks. I am using Spacemacs which does have LSP for Clojure (added in November 2020). LSP is the default backend for Clojure in Spacemacs if the lsp layer is added. https://github.com/syl20bnr/spacemacs/commit/6d39cd5548768bed63cc18d51b74efb78f39963d There are certainly conflicts with the additional configuration I use for my Clojure setup. This was due to aggressive-intend which I had hooked into clojure-mode. This conflicts with the cljfmt that LSP continually runs. As I've been using my setup for several years, I have disabled cljfmt until I can configure it to give the same results. Even without the conflict with aggressive-indent, I would have disabled some of the rules of cljfmt as they dont provide the readability I need for my code.

πŸ‘ 3
practicalli-johnny18:02:36

The biggest challege is finding the parts of lsp that I find useful. This seems mostly in the configuration of the lsp UI and the automatic formatting (I like to align forms). Having not used an IDE for most of the last decade I have enjoyed clutter free editing. I do find the default UI configuration very noisy and am spending some time surfacing just those parts of the lsp ui that give the most value. The biggest challenge with using clojure-lsp with CIder is deciding which tool is going to do what. There is a lot of cross-over in functionality, so hope to create an lsp config that complements the features of Cider without over-riding features I have relied on for a long time. Where there are improvements on the Cider features from LSP, then I would use LSP. It just takes a bit of time to understand what those parts are.

practicalli-johnny18:02:31

@U06BE1L6T I think LSP is pretty reliable, I havent experience any issues recently. I think it really comes down to knowing what you want (and do not want) to experience with LSP (and CIDER). Much of the journey for me is trying to understand what the features of LSP are and how they can be helpful.

ericdallo18:02:40

Exactly @U05254DQM, I use LSP for almost every feature and Cider for runing tests/eval things

ericdallo18:02:50

I stopped using clj-refactor as it turns out that LSP replaced the features that I used

ericdallo18:02:58

About align-forms, There is a open feature request for that on cljfmt so the recommended way to do that is still using clojure-align from clojure-mode (I use that too πŸ˜…)

ericdallo18:02:40

I agree lsp-ui is noisy, we from lsp-mode are thinking in ways to improve that too, with better defaults maybe

practicalli-johnny19:02:06

Happy to share my minimal defaults when I figure them out. Could be useful to have 2-3 example configs, one very minimal, one with everything and one with the most common - if that is known.

yes 3
practicalli-johnny19:02:00

I agree that clj-refactor should not be used (or needed) if using LSP. I stopped using clj-refactor a while ago though. Clojure-mode has a few useful refactorings. I use helm-ag and iedit to refactor across projects, although this is a candidate for LSP instead, to reduce the steps required. clj-refactor hotloading of libraries was a very useful feature, although I believe its still broken. However, its easy to do hotloading with add-libs if using Clojure CLI tools.

ericdallo19:02:54

Yes! Just FYI, we added support for a nice iedit integration too on lsp-mode: https://emacs-lsp.github.io/lsp-mode/page/integration/iedit/ It merge the power of iedit with LSP πŸ˜„