calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
Joe 2021-01-16T00:15:13.056800Z

Thank you! Tangentially related: If I have an alias :calva in my project deps.edn, and I jack in using that, the REPL is launched with

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.6"} clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}' -A:calva
but if I have an identical alias :calva-user in my user deps.edn, and jack in using that, the REPL is launched with
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.6"} clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}' -A:calva-user -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
I think that the things after calva-user there are causing it to overwrite some of the main-opts in the alias, is that right? This is the alias in full
{:extra-deps {nrepl/nrepl {:mvn/version "0.8.3"}
                       cider/cider-nrepl {:mvn/version "0.25.6"}
                       clj-kondo/clj-kondo {:mvn/version "2020.04.05"}
                       vlaaad/reveal {:mvn/version "1.2.185"}}
          :jvm-opts   ["-Dvlaaad.reveal.prefs={:font-size,48}"]
          :main-opts ["-m" "nrepl.cmdline"
                      "--middleware" "[vlaaad.reveal.nrepl/middleware,cider.nrepl/cider-middleware]"]}

bringe 2021-01-16T00:34:35.057100Z

Hmm I'm not really sure. Can you send your full deps.edn?

Joe 2021-01-16T00:47:23.057300Z

this is ~/.clojure/deps.edn

bringe 2021-01-16T02:00:16.057700Z

So you're saying when you name that calva-user alias just calva the jack-in command is different? I feel I remember something to do with hyphenated alias names. I'm going to defer to @pez on this. Maybe he has some more info.

Joe 2021-01-16T02:57:59.062700Z

I will definitely check the name thing, but the distinction i meant is where the alias is defined. The one I called calva is defined in the deps.edn of the project, and the one I called calva-user is defined in the user deps.edn file. What I’m not sure about is why the REPL launch string is any different, I was surprised Calva even realized there was a difference.

pez 2021-01-16T09:32:43.066400Z

Calva doesn't even know the user deps.edn exists. So the difference there is probably one of not having the alias defined vs having it defined. To tell Calva about aliases it should use at Jack in, I think the menuSelections property in custom connect settings is the only way. https://calva.io/connect-sequences/

practicalli-john 2021-01-16T10:50:40.067Z

I added a link to several configuration options to the PR incase they are of interest https://github.com/practicalli/clojure-deps-edn/blob/live/deps.edn#L507-L542

practicalli-john 2021-01-16T10:56:12.067300Z

@allaboutthatmace1789 I had a bug when using hyphenated names for aliases specifically when adding the alias via calva.replConnectSequences , but adding the same alias into the deps.edn local to the Clojure project works with hyphenated names (sorry, should have raised an issue)

1👍
pez 2021-01-16T11:05:15.067500Z

Ah, yes, that too.

pez 2021-01-16T11:06:20.067700Z

Does any of those ^ help you, @jarvinenemil?

practicalli-john 2021-01-16T11:27:52.070600Z

Does the output of running unit tests in Calva only show in the repl output window? I am sure I have seen a notification popup in the bottom right corner that shows test results? Was that Clover rather than Calva or did I miss a trick in configuring Calva?

Christian 2021-01-16T14:32:23.070800Z

It has happened again. I opened vs code, changed something in the project.clj, jacked in, and this is the output:

Joe 2021-01-16T15:57:25.071600Z

It definitely does do that in Clover.

1👍
agold 2021-01-16T16:22:49.075800Z

With Calva 2.0.151, linter is flagging this: #_:clj-kondo/ignore (defrecord Slug [rowid src target supp lrd-from lrd-to nseen]) with the error Unused declaration: Slug clojure-lsp(unused-public) Slug is in fact used in the program via the conversion function ->Slug When I use the command-line clj-kondo --lint on this file, however, it lints OK with no errors. How do I suppress the error message in Calva?

borkdude 2021-01-16T16:24:50.076400Z

Apparently that warning isn't coming from clj-kondo, but from clojure-lsp

agold 2021-01-20T14:58:45.188700Z

@ericdallo I’ve just noticed that when clojure-lsp reports an unused declaration on a defn called in another file, closing and re-opening the file being edited will sometimes make the error disappear.

ericdallo 2021-01-20T15:00:05.188900Z

Yes, I already saw that, I think the clj-kondo pr integration that we are working should fix that, otherwise I''ll take a look

ericdallo 2021-01-20T15:00:17.189100Z

I hope we merge the PR this week

borkdude 2021-01-20T15:00:45.189300Z

🤞

ericdallo 2021-01-20T17:58:40.200300Z

@agold just found the issue and it's a bug that always existed on clojure-lsp 😅 I opened this issue and hope fix it soon: https://github.com/clojure-lsp/clojure-lsp/issues/264

1👍
agold 2021-01-16T16:25:40.076800Z

How do I suppress it?

ericdallo 2021-01-16T16:35:40.077Z

Not sure we can disable that as probably is a bug in clojure-lsp

ericdallo 2021-01-16T16:35:49.077200Z

But you can try setting linters :unused-namespace-declarations

ericdallo 2021-01-16T16:36:06.077400Z

Check linters for more info here: https://clojure-lsp.github.io/clojure-lsp/settings/

agold 2021-01-16T16:36:14.077700Z

Thanks, will try.

Joe 2021-01-16T16:58:23.077900Z

I tried without hyphen, i.e. called the alias just calva in .clojure/deps.edn. It's still launching with the same args:

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.6"} clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}' -A:calva -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" 

Joe 2021-01-16T17:02:25.078100Z

Should mention, I'm launching it by adding :calva to the Calva: My Clj Aliases setting

pez 2021-01-16T17:04:00.078300Z

Which args do you want it to launch with?

Joe 2021-01-16T17:08:17.078500Z

When I launch it with that alias in the project deps file, it launches with this;

clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.6"} clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}' -A:calva
i.e. the same thing without -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" . I might be wrong, but it seems like those extra things are overriding the arguments in the alias - specifically the reveal middleware. I'm just not clear on why those extra things are being added

pez 2021-01-16T17:15:36.078700Z

They start the nrepl server so that Calva can provide its services. Since the alias you provide has it’s own main options, Calva does not add its default main options to the command line. There can only be one main. 😃

Joe 2021-01-16T17:20:26.078900Z

I'm sorry, I'm not following. I get that there can only be one main, what I don't get is why -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]" is being added in one case (where the alias lives in .clojure/deps.edn) and not where the identical alias lives in the project deps file

pez 2021-01-16T17:22:23.079100Z

That is because Calva does not read the alias definition in the user profile, so it can’t see that there is a main option there. There used to be docs about this. Not sure when we lost them…

Joe 2021-01-16T17:24:11.079300Z

Ahhh. So if it's in the project deps, Calva can figure out that the alias has main opts, and chooses not to add it's own. But if it's in the user deps, it can't get to it, so it thinks it needs to add them.

pez 2021-01-16T17:28:26.079500Z

Yes. Well worded. If you feel up to, I’d welcome a PR to the docs so that this behaviour is not as secret as it is today.

Joe 2021-01-16T17:29:03.079700Z

Thanks, if I get a chance later today I will give it a go

practicalli-john 2021-01-16T17:49:29.084400Z

Is there a reason Calva uses a single ; for comment lines? Or am I doing something wrong and comment lines do start with the usual ;; double semi-colon ? I didn't find a way to customise the line comment, except by hacking `.vscode > extensions >betterthantomorrow.calva-2.0.151 > clojure.tmLanguage.json

"repository": {
		"comment": {
			"begin": "(?<!\\\\);;",
			"beginCaptures": {
				"0": {
					"name": "punctuation.definition.comment.clojure"
				}
			},
			"end": "$",
			"name": "comment.line.semicolon.clojure"
		},

pez 2021-01-16T17:56:43.085700Z

No particular reason except that if it starts with ;; it also starts with ;. I don’t think I quite follow when this is significant?

pez 2021-01-17T21:38:38.112400Z

Calva formatting, which uses cljfmt, doesn't move comments at all. It's not clear to me how that causes formar changes.

practicalli-john 2021-01-18T09:15:38.113Z

Okay, sounds like you are happy doing comments differently

pez 2021-01-18T09:25:56.113200Z

I think it is rather that we don’t understand how we are doing it differently. We don’t treat comments semantically. Which it seems you are expecting us to do?

practicalli-john 2021-01-18T20:03:29.151200Z

Cider does. Cider will indent any single ; to half way in the page if it's a line comment. This will can cause friction between cider and Calva developers All the Clojure code I have worked with in the last decade always used double ;; for comments. It's one of the first things I remember learning about Clojure. I am quite surprised everyone doesn't know this

practicalli-john 2021-01-18T20:06:01.151400Z

Code with single ; for comments just looks wired and feels very wrong to look at, even though semantic I appreciate some may think this trivial.

pez 2021-01-16T17:59:06.085800Z

It is only shown in the Output window. I don’t think we have ever shown it in some other way. Though @marc-omorain once started a PR where the results where shown in the side bar. Today I think we would write a TestExplorer integration to achieve that.

Marc O'Morain 2021-01-16T18:02:32.087300Z

The problem that I hit in my PR was the lack of docs for the cider / nREPL / clojure.tests integration.

Marc O'Morain 2021-01-16T18:02:57.087900Z

It added the results to the Test Explorer pane.

3👍
bringe 2021-01-16T19:26:56.088400Z

https://github.com/BetterThanTomorrow/calva/issues/953 Added this for the future :simple_smile:

2👍
bringe 2021-01-16T19:33:35.089100Z

@agold Would you mind creating an issue in the clojure-lsp repo for this scenario?

bringe 2021-01-16T19:33:55.089300Z

At least, I think @ericdallo would agree 😄

ericdallo 2021-01-16T19:34:37.089500Z

Yeah, when @snoe finish the 100% clj-kondo integration, we could probably ignore that on clj-kondo level, but ATM it's clojure-lsp linter

1👍
ericdallo 2021-01-16T19:34:58.089700Z

BTW, did my suggestion above work @agold?

borkdude 2021-01-16T19:36:30.090Z

Is there an option to disable the clojure-lsp linting via a config? They can always just enable the clj-kondo extension I guess

borkdude 2021-01-16T19:36:44.090200Z

(I have a feeling I asked this earlier this week ;))

bringe 2021-01-16T19:37:05.090400Z

Haha, no there is not. If this continues to be an issue I may add that

ericdallo 2021-01-16T19:37:29.090700Z

Yes ☝️

ericdallo 2021-01-16T19:38:05.090900Z

It's a code that should be removed as soon we merge clj-kondo 100% integration so we should avoid improving it unless the merge takes too long

bringe 2021-01-16T19:38:23.091100Z

I see, makes sense

borkdude 2021-01-16T19:38:25.091300Z

Is there anything that is currently missing to accomplish this? Let me know

ericdallo 2021-01-16T19:39:34.091500Z

I think there's nothing on clj-kondo side, @snoe it's WIP on this: https://github.com/clojure-lsp/clojure-lsp/pull/176

bringe 2021-01-16T19:51:51.091800Z

Does kondo inform of unused publics? I remember that being a difference in it and what clojure-lsp offered. Like if I have (def x 1) in ns foo and it was not referenced anywhere in the code base, clojure-lsp would say unused public, but if it was referenced in ns bar it would not warn. And from what I remember kondo did not check references outside of the current file? Maybe I'm mistaken

ericdallo 2021-01-16T19:53:17.092Z

I think is something @snoe was working on clj-kondo, maybe @borkdude can tell us

borkdude 2021-01-16T20:05:06.092200Z

@brandon.ringe clj-kondo doesn't do this by default, since it works with an open world view: it doesn't have a concept of "I now know everything about your project". But you can easily use clj-kondo's analysis output to do this. Here is an example: https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md#unused-vars

borkdude 2021-01-16T20:06:11.092600Z

The references outside the current file: it does have this concept, e.g. you get arity errors about vars in other namespaces.

borkdude 2021-01-16T20:07:33.092800Z

There is an issue I'm working on right now to detect references that are unresolved in other namespaces. e.g. set/onion

bringe 2021-01-16T20:10:29.093Z

So clojure-lsp would need to keep providing at least these specific diagnostics if it wanted to keep them, right? If it stopped providing all diagnostics in favor of only kondo diagnostics, I think this specific case, at least, would be lost.

bringe 2021-01-16T20:11:37.093300Z

CC @ericdallo. Just hoping not to lose something 😄

ericdallo 2021-01-16T20:12:19.093500Z

Yeah, the idea is not lose these diagnostics! we should use the kondo analysis to make that work

agold 2021-01-16T20:15:46.093700Z

@ericdallo No, your suggestion didn’t work. I am using a workaround: (when nil (form that uses the supposedly undeclared thing))

ericdallo 2021-01-16T20:16:35.093900Z

thanks, I'll check that later, open a issue on clojure-lsp could help to track that

agold 2021-01-16T20:17:22.094200Z

Thanks!

paulbutcher 2021-01-16T22:48:15.097700Z

I’ve just noticed that I’m getting a clj-kondo warning saying that my -main function is an unused declaration. This certainly wasn’t happening a while ago, but I’m not sure when it did start. I’ve recently moved away from building with Leiningen and am now building with deps.edn which might be the cause? Or perhaps it’s something that’s changed within Calva? I’d welcome a nudge in the right direction.

borkdude 2021-01-16T22:49:15.098Z

this is probably not clj-kondo, but clojure-lsp saying this

paulbutcher 2021-01-16T22:50:17.098800Z

Ah! Yes “Peek problem” says “clojure-lsp(unused-public)”

paulbutcher 2021-01-16T22:51:25.099400Z

Nevertheless, it’s definitely new? Any idea why I’ve started getting the warning? And how to quieten it?

paulbutcher 2021-01-16T22:56:08.101300Z

Thanks. And now that I know where to look, I can see that clojure-lsp was introduced into Calva last month, which explains why I’m getting the warning when I wasn’t before.

ericdallo 2021-01-16T22:56:18.101500Z

Yes, good news is that we are working on that PR and we ll try to merge it ASAP 🙂 https://github.com/clojure-lsp/clojure-lsp/pull/261

1👍