Fork me on GitHub
#announcements
<
2019-12-01
>
borkdude11:12:07

There is a new way of running clj-kondo in IntelliJ which also works with the community edition: https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md#lsp-server

p-himik12:12:55

The LSP workflow doesn't require saving a file before running the linter on it, right? Would it be possible to run the LSP server via clj just so that I can add the RELEASE version to my user's deps.edn and stop worrying about the latest version?

borkdude13:12:03

@ good idea. Can you try with:

/usr/local/bin/clojure -Sdeps '{:deps {clj-kondo/lsp-server {:mvn/version "RELEASE"} clj-kondo {:mvn/version "RELEASE"}}}' -Sforce -m clj-kondo.lsp-server.main

borkdude13:12:07

as the command

borkdude13:12:41

(I think you need -Sforce else to checking of the latest release)

borkdude13:12:32

If that works for you, I'll add it to the README

p-himik13:12:24

Seems to work, but I had to increase the init timeout to a minute. Otherwise, I was getting

LanguageServer for definition
 rawCommand : /usr/local/bin/clojure -Sdeps '{:deps {clj-kondo/lsp-server {:mvn/version "RELEASE"} clj-kondo {:mvn/version "RELEASE"}}}' -Sforce -m clj-kondo.lsp-server.main
not initialized after 10s
Check settings
So, I'm not sure about the -Sforce flag. I think with RELEASE, clojure still checks for the latest version. Although, even if you don't specify the flag, the timeout will still probably happen when a new version of clj-kondo is released. Maybe it's worth mentioning the timeout and how to increase it. Another small thing - the guide says the path to the relevant settings section is just at Preferences / Language Server Protocol / Server definitions. The actual path, as given by IDEA itself, is File | Settings | Languages & Frameworks | Language Server Protocol | Server Definition (you can copy it via the context menu of the breadcrumbs section of the settings window).

borkdude13:12:07

Are you on Windows?

borkdude13:12:31

That might be a difference between mac and linux

p-himik13:12:40

Hmm, yeah - didn't realize that.

p-himik13:12:53

So you don't have the Languages & Frameworks part?

borkdude13:12:04

The uberjarred version has faster startup. Can you confirm that by trying it?

p-himik13:12:16

Oh yeah, it's definitely faster.

borkdude13:12:51

oh yes, I do. I will correct it.

borkdude13:12:05

ok, then I think that will still be the recommended way

borkdude13:12:37

but if you make a bash script that downloads the latest one and just replaces the existing by the same name, then you should have what you want

p-himik13:12:25

There are pros and cons to each way of setting this up, I guess. One gives faster startup, although it happens only once at IDEA startup; the other is able to download the latest version for you but requires an additional tuning of the init timeout value.

p-himik13:12:37

Regarding the script - well, if download takes a long time, it will be the same issue.

p-himik13:12:24

clj is slow only when it needs to recompute the classpath. Without the -Sforce flag, the timeout doesn't happen.

borkdude14:12:04

yes, but the cache is based on a hash of the deps.edn file I think

borkdude14:12:15

I already had a caching issue when using RELEASE

borkdude14:12:36

that's why you need -Sforce to make it work reliably

borkdude14:12:04

officially RELEASE isn't even supported anymore by a future version of maven

p-himik14:12:15

Huh, interesting. I'll keep an eye on it then. Because I'm almost certain that I've seen it download a new version all by itself when I didn't change the deps file.

p-himik14:12:56

The absence of RELEASE in Maven isn't really relevant for tools.deps because, I think, it doesn't use Maven. RELEASE can just be a spepcial value for the :mvn/version key. But that's a topic for a different discussion. πŸ™‚

borkdude14:12:10

yes, but the cache depends on the contents of the deps.edn file

borkdude14:12:18

and RELEASE is just a constant string

borkdude14:12:29

anyway, feel free to use it with -Sforce, I just added it because I did have a caching problem just now when I came up with this solution

p-himik14:12:33

Ah, almost forgot to say - thank you for making this workflow possible. Using the file watcher was creating just too much churning.

borkdude14:12:27

Sure πŸ™‚

p-himik16:12:15

I just noticed that this folder got created:

lsp
β”œβ”€β”€ conf
β”‚Β Β  └── clojure.json
└── log
    β”œβ”€β”€ clojure_err_20191202.log
    └── clojure_out_20191202.log
The JSON file is empty. I couldn't find any reference to it in the source code of clj-kondo. Where does it come from? Can I safely add the whole folder to gitignore?

borkdude16:12:00

I think that is created by the LSP Support plugin.

borkdude16:12:07

I saw it too on my machine

borkdude16:12:13

maybe you can find something about it in their docs

borkdude16:12:24

I added it to .gitignore

p-himik16:12:14

Thanks! Yeah, they explicitly say that they create the lsp folder in the project's root.

p-himik08:12:01

Just to correct myself - turns out, the LSP server shuts down each time you close all relevant files, not when you exit IDEA. In this situation, having a high init time is indeed much more detrimental.

borkdude09:12:55

I think so too.

tkjone15:12:56

Wrote a little something about starting with Clojure Text Editors and how one might choose between all the options available: https://betweentwoparens.com/clojure-text-editors

tkjone15:12:17

Thoughts are very welcome πŸ™‚

vemv15:12:48

Nice one, nuanced. Emacs user here, but I celebrate diversity of choices, particularly to accomodate people coming from different backgrounds. As a random thought, I'd love for people to champion IDE-agnostic tooling. I often see people asking "how do I format|refactor|grep in $editor", when a better approach would be "how to x from the REPL" https://github.com/clojure-emacs/refactor-nrepl is perfectly invokable from the repl for example, and yet probably 90% of its userbase are emacs users.

tkjone15:12:07

100% agreed @! I think building a culture of education and understanding goes a long way to getting to your point πŸ™‚

vemv15:12:53

Exactly :) More broadly, Clojure / Lisps have ways that are deeply different from practically all other mainstream languages. So ones sees the frequent mistake of people doing clj software engineering the same exact way they would in Ruby, or Java... That's pretty wrong, but at the same time one ought to demonstrate some patience and empathy.

ghadi16:12:16

That’s a brilliant domain name

mauricio.szabo23:12:21

@ one of the things I think is missing is documentation. If we could document these features better, it would probably be easier for people to invoke then from the REPL, and also easier to integrate on editor's plug-ins too

mauricio.szabo23:12:56

Just published Clover. It is a very experimental package for Socket REPLs on VSCode, based on the same machinery that powers Chlorine (for Atom): https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover

pez00:12:16

Very cool! I must try it of course. Do you know how compatible the extension is with Calva? I’m thinking since there is a lot of general Clojure editing things in Calva, it would be nice if Clover users could benefit from them. I’ll give Clover some spins and see what I find.

mauricio.szabo01:12:40

I didn't check this compatibility, but it should work fine. Clover does not have any editing, so it would really be nice to benefit from it πŸ™‚