lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
Mitja 2021-06-06T10:24:14.125500Z

https://twitter.com/borkdude/status/1388193273630576640 you can navigate to re-frames sub and events. Is this something that could work with Calva as well? As far as I understand it is using both clojure-lsp and clj-kondo, so in theory it should, but I wasn't able to get it to work. One thing I noticed is that @borkdude is using namespaced event names in the linked tweet, is that necessary for this to work? I also checked the PR that adds support for this for clj-kondo and from the https://github.com/clj-kondo/clj-kondo/pull/1266/files#diff-f591b825c81f488c7fa9426a07ba9dd30f948cc52e445be929d5fd8299bc7ddeR1646 you have to import the re-frame's functions directly from re-frame? So using you own wrappers around these functions would probably not work?

borkdude 2021-06-06T10:40:38.126400Z

@mitja.bezensek Correct, you have to use the re-frame functions

borkdude 2021-06-06T10:41:00.126700Z

But you can always do find-references on any keyword

Mitja 2021-06-07T09:43:11.148300Z

@brandon.ringe yes, I used the Server info command to get those logs and it led me towards finding the solution

๐Ÿ‘ 1
Mitja 2021-06-06T10:59:49.126800Z

yeah, that's what I'm using right now just quickly tried to replace references so that I used re-frame.core ones but it's still not working will try to start an new project to rule out issues with our configuration

Mitja 2021-06-06T11:18:06.127Z

created a new project using lein new re-frame lsp-test +kondo this template uses re-frame functions directly and also uses namespaced events / subs, but I'm still not able to get it to work

borkdude 2021-06-06T11:22:26.127500Z

did you create a .clj-kondo directory in the root of the project?

Mitja 2021-06-06T11:25:54.127700Z

yeah, it's there

Mitja 2021-06-06T11:25:59.127900Z

Mitja 2021-06-06T11:26:03.128300Z

borkdude 2021-06-06T11:26:39.128700Z

is there also a sqlite db in your .lsp dir?

Mitja 2021-06-06T11:27:02.128900Z

yes there is

Mitja 2021-06-06T11:27:04.129100Z

borkdude 2021-06-06T11:29:38.129500Z

ok I will try locally

borkdude 2021-06-06T11:32:16.129700Z

I see the issue. It works after I visit the events.cljs namespace.

borkdude 2021-06-06T11:32:33.129900Z

The reason for this is probably that there is no deps.edn or project.clj in this project

borkdude 2021-06-06T11:32:41.130100Z

And so lsp doesn't know what files to scan

borkdude 2021-06-06T11:33:16.130300Z

cc @ericdallo

Mitja 2021-06-06T11:40:27.130500Z

for me it doesn't work after visiting that namespace go to definition for other function does work though

Mitja 2021-06-06T11:40:33.130700Z

borkdude 2021-06-06T11:41:00.131100Z

for me it did work

borkdude 2021-06-06T11:41:14.131300Z

I recommend moving your deps to deps.edn for now

borkdude 2021-06-06T11:41:22.131500Z

and tell shadow to look for the deps over there

Mitja 2021-06-06T12:35:26.131700Z

couldn't get it to work. might be just me incorrectly setting things up though ๐Ÿ˜… do you have an example repo where it should work?

borkdude 2021-06-06T12:47:42.131900Z

I just followed your lein new command

borkdude 2021-06-06T12:50:15.132100Z

To reproduce again:

lein new re-frame lsp-test +kondo
cd lsp-test
echo '{}' > deps.edn
Then start editing your code in this new project. Navigation to the re-frame event works immediately

Mitja 2021-06-06T13:04:34.132300Z

must be something else, this does not work for me

borkdude 2021-06-06T13:05:39.132500Z

I bet it's an LSP config issue. Are you in emacs?

Mitja 2021-06-06T13:07:14.132700Z

vscode + calva

Mitja 2021-06-06T13:07:55.132900Z

Mitja 2021-06-06T13:08:22.133300Z

this is the clojure-lsp server info

borkdude 2021-06-06T13:09:43.133500Z

I'll defer you to @ericdallo or @pez now because I can only speak for clj-kondo and/or emacs.

๐Ÿ‘ 1
Mitja 2021-06-06T13:10:21.133800Z

thanks for help! hopefully we can figure it out ๐Ÿ™‚

Mitja 2021-06-06T13:10:38.134Z

I see that clj-kondos version is 2021.04.23, could that be an issue?

borkdude 2021-06-06T13:11:27.134200Z

could be!

borkdude 2021-06-06T13:12:32.134400Z

it seems you still have an old lsp server

Mitja 2021-06-06T13:17:59.134600Z

updated both, no luck unfortunately

Mitja 2021-06-06T13:18:13.135Z

will see if @ericdallo or @pez might know more, thanks again!

Mitja 2021-06-06T13:20:46.135200Z

hm, I did update clj-kondo and clojure-lsp via scoop but seems like calva is still using the older versions here's the server info after the update

Mitja 2021-06-06T13:20:49.135400Z

Mitja 2021-06-06T13:20:54.135800Z

looking into how to update it

pez 2021-06-06T13:23:34.136Z

Calva uses its own clojure-lsp, there is a Calva setting for selecting which version it should download.

Mitja 2021-06-06T13:26:06.136200Z

WORKS!

๐ŸŽ‰ 1
Mitja 2021-06-06T13:26:36.136400Z

based on your suggestion I added this to vscode's settings.jsons "calva.clojureLspVersion":ย "2021.06.01-16.19.44",

Mitja 2021-06-06T13:26:59.136600Z

thanks to both of you!

โค๏ธ 2
borkdude 2021-06-06T13:45:11.137500Z

@pez why was Calva using an old one

borkdude 2021-06-06T13:45:35.138300Z

Question mark (ffing phone)

pez 2021-06-06T13:46:49.138500Z

We havenโ€™t bumped the version since a while. Maybe we should have a settings for following latest, @brandon.ringe?

ericdallo 2021-06-06T15:27:32.138700Z

Looks a good idea @pez

bringe 2021-06-06T18:48:23.138900Z

@mitja.bezensek By the way, there is a command in Calva to get just the server info. I'm not sure if you were using that or not. Calva Diagnostics: Clojure-lsp Server Info.

๐Ÿ‘ 2
bringe 2021-06-06T18:53:33.139200Z

@pez @ericdallo Do you mean adding a setting that would allow the user to opt-in to Calva always using the latest clojure-lsp version? I'm not sure if that's a good idea, or at the very least, it should default to not automatically using the latest version. Sometimes (though hopefully not often), things may not work well between Calva and the latest clojure-lsp - but if the auto update is opt-in, maybe this is not that big of a deal - the user decides they want this risk for the benefit of always using the latest clojure-lsp. The version setting serves this purpose, but just makes it more of a manual opt-in process. I think right now I'm in favor of keeping it this way, but I'll update the default version used by Calva to the latest.

borkdude 2021-06-06T18:54:38.139400Z

I'd say Calva could include something in its build to update clojure-lsp to the latest before release. Being a couple of releases behind seems like a bad default.

ericdallo 2021-06-06T18:55:31.139700Z

Yeah, or maybe make it clearer for users that they have outdated clojure-lsp

pez 2021-06-06T19:00:04.139900Z

I think that the current scheme assumes that we Calva devs โ€œvetโ€ the clojure-lsp versions and decide when they work well enough with Calva to be included as default. But in reality we donโ€™t have this capacity. We bump the clojure-lsp version more based on exciting new features. ๐Ÿ˜ƒ

pez 2021-06-06T19:00:52.140100Z

And only if we happen to pick up on the news of such features.

bringe 2021-06-06T19:01:10.140300Z

> I think that the current scheme assumes that we Calva devs โ€œvetโ€ the clojure-lsp versions and decide when they work well enough with Calva to be included as default. Yes, though admittedly we don't vet every feature. Maybe we just make sure it starts up fine and a few things work.

pez 2021-06-06T19:02:18.140500Z

Anyway, we donโ€™t need to make latest the default. But giving the users that options seems cool to me.

pez 2021-06-06T19:03:59.140700Z

And, really, the root problem here is making it more obvious that Calva is using its own clojure-lsp. Iโ€™ve seen quite a few trouble shooting reports, including @mitja.bezensekโ€™s above, where brew (or the equivalent) is tried.

borkdude 2021-06-06T19:04:46.140900Z

Is Calva using another version of clojure-lsp, on top of what the user chooses to use?

pez 2021-06-06T19:05:01.141100Z

Not easy at allโ€ฆ Maybe we should have a clojure-lsp status bar button side by side with the nREPL one? Then we can have tool tips and menus and stuff.

borkdude 2021-06-06T19:05:05.141300Z

I think it would be time-saving for all of us if the user knows they're not using the latest lsp/kondo somehow

bringe 2021-06-06T19:05:45.141500Z

This sort of relates to using libraries in a project though, I feel. Would you always want your build tool to install the latest version of your deps when you build your project? I would think not for the sake of determinism. But, of course, this is a bit different.

pez 2021-06-06T19:05:46.141700Z

Itโ€™s not wether they use latest. It is that they are using something Calva maintains.

bringe 2021-06-06T19:06:20.141900Z

But either way I do agree we need to make it more clear that Calva is not using their installed version of clojure-lsp

bringe 2021-06-06T19:06:37.142100Z

Unless they use the path setting to make Calva use it

pez 2021-06-06T19:06:40.142300Z

@brandon.ringe I am fully ready to not make latestthe default. Iโ€™m just suggesting making it an option.

borkdude 2021-06-06T19:06:53.142500Z

Calva should probably explicitly print these versions in the welcome message if it doesn't already do so

bringe 2021-06-06T19:07:06.142700Z

I get that, I was more directing that toward @borkdude. Just curious on his thoughts there.

pez 2021-06-06T19:07:16.142900Z

I donโ€™t think anyone reads those welcome messages.

pez 2021-06-06T19:07:56.143100Z

Or, anyone, is not right. But most people donโ€™t.

borkdude 2021-06-06T19:08:06.143300Z

at least you can ask them to copy-paste what it says there in case of an issue like this. that would have saved me time today ;)

pez 2021-06-06T19:08:34.143500Z

Ah, thatโ€™s of course very nice to be able to ask for.

bringe 2021-06-06T19:08:46.143700Z

Well that's what the server info command is for, and that's documented ๐Ÿ˜„

ericdallo 2021-06-06T19:09:09.143900Z

That was my point, just some window with basic info of clojure-lsp/calva version so most issues we just ask the info from that window

ericdallo 2021-06-06T19:09:26.144100Z

Yeah, maybe the server command is good enough

ericdallo 2021-06-06T19:09:32.144300Z

We just need to ask that first

pez 2021-06-06T19:09:35.144500Z

The welcome message is probably very good for this.

bringe 2021-06-06T19:09:37.144700Z

Yeah

ericdallo 2021-06-06T19:09:42.144900Z

Maybe add to the issue template as well

๐Ÿค˜ 1
bringe 2021-06-06T19:09:50.145100Z

We can put it in the welcome output window message too

๐Ÿ‘ 2
๐Ÿค˜ 1
pez 2021-06-06T19:10:43.145500Z

We will prove @bozhidar wrong when he says you canโ€™t decomplect using documentation. ๐Ÿ˜ƒ

borkdude 2021-06-06T19:11:21.145800Z

Instead of "did you try turning it off and on again" we can say: "please post your welcome message"

โ˜๏ธ 1
borkdude 2021-06-06T19:12:07.146200Z

or we can even write a bot for it! ๐Ÿ˜ผ

๐Ÿ˜„ 1
pez 2021-06-06T19:12:20.146400Z

copying โ€ฆ wait, this says โ€ฆ you know what guys? I solved it myself. ๐Ÿ˜ƒ

๐Ÿ˜„ 2
bringe 2021-06-06T19:58:50.146900Z

Calva v2.0.200 is out now, which uses the latest clojure-lsp. I also added a note near the top of the clojure-lsp doc about Calva determining the version by default, the server info command, and how to change the version used. Also added that Calva does not use the version of clojure-lsp installed, unless it was set to do so. https://calva.io/clojure-lsp/

1
2
๐ŸŽ‰ 4
bringe 2021-06-06T20:00:02.147400Z

I'll leave the updating of the welcome message up to @pez