Fork me on GitHub
#lsp
<
2022-01-26
>
jacob.maine01:01:06

I’m working in the clojure-lsp repo with a local build of the clojure-lsp executable. The cache never loads. The logs show “Could not load project cache from DB” and https://github.com/juji-io/datalevin/issues/73 is being thrown. Anyone else seen this? Any thoughts on how to debug it? I’ve tried compiling with Java 8, 11 and 17. And I’ve tried running the b/compile-clj step with the --add-opens java opts mentioned in the attached Issue. I’m NOT on an M1 machine, FWIW. At worst I can just ignore it. It just means it’s really slow to restart the LSP server.

jacob.maine01:01:01

Oh, I also tried upgrading datalevin to 0.5.28

ericdallo01:01:13

@U07M2C8TT that's odd, this happens when you use jdk17 and doesn't add the --add-opens

ericdallo01:01:25

I use jdk11 most of the time

ericdallo01:01:46

And we can't add --add-opens because it doesn't work with jdk8

ericdallo01:01:37

https://github.com/clojure-lsp/clojure-lsp/issues/703`transit` branch, that will fix all those weird errors, maybe it's worth wait for that

ericdallo01:01:28

maybe you can rebase your changes on transit for now

ericdallo01:01:51

(and take the opportunity to help test that branch 😛)

jacob.maine04:01:35

Ah, OK, I’ll give that a shot. Thanks for the idea!

jacob.maine05:01:52

That does fix the caching. 🎉 I haven’t played with it much, but I will

jacob.maine05:01:56

The transit branch is a bit behind master. I had to merge master into it before I could rebase my changes onto it. I’ll refrain from pushing anything based on it so it isn’t merged prematurely. Having the cache working is helpful for debugging though. Thanks!

ericdallo12:01:44

Nice, I intend to merge that branch soon this week

ericdallo12:01:52

Merged master on transit meanwhile

👍 1
ericdallo23:01:58

@U07M2C8TT merged transit on master 🎉

jacob.maine23:01:50

Nice! I think that’s a nice simplification. I’ll update my branch.

ericdallo23:01:28

Yes, I saw lots of wins with that migration

ericdallo23:01:52

Will work on graalvm 22.0.0.2 migration now 🤞

jacob.maine00:01:00

My branch parse-at-whitespace-or-comment is updated (rebased and force pushed, in case you’ve already started testing it)

ericdallo00:01:50

I intend to start testing tomorrow!

ericdallo12:01:20

What do you think about calling clean-ns automatically after choosing any code action or refactor that changes a ns like Add missing require ? Considering adding that behind a flag enabled as default

practicalli-johnny13:01:42

I group my requires by purpose, so this would be very invasive for me. I would prefer it disabled by default. Thanks.

ericdallo13:01:13

but this would work only for code actions that already add something to the ns, I'm afraid you don't use those ATM right? as it always add at the end of the ns already not matching your sort

practicalli-johnny14:01:52

If the code actions only add requires to the end, then it's not matching any sort, surely.

👍 1
practicalli-johnny14:01:19

Seems I'm more likely to use yasnippets to add a require (or clojure lsp snippets when they work in my setup). So it seems there no need to adopt the particular code actions that change the namespace form.

ericdallo14:01:06

Hum, but if you type: str/split , clojure-lsp will show a Add missing clojure.string require, how you would do that with yasnippets automatically?

practicalli-johnny15:01:19

With Yasnippets, I wouldnt. I add a library within the ns form using the reqiure snippet, typing the name of that library and a meaningful alias. I would not like to used str as the alias for clojure.string either, but assume that is besides the point. I will have another look at this code action and see if its useful to adopt. I am curious as if there are specific alias names defined for libraries or if I can use a naming convention I prefer.

ericdallo15:01:07

yeah, this was just a example, string/split would work as well :)

ericdallo15:01:57

clojure-lsp has a lot of rules to suggest requires, like if you have a namespace foo.bar.baz and you type: bar.b/something it will suggest to require that namespace

ericdallo15:01:33

besides some know alias that it suggests as well like io - > , edn -> clojure.data.edn etc

ericdallo15:01:50

also, it checks if the alias was already imported anywhere in the project, which is pretty useful, suppose you have in some other namespace (:require [my.custom.ns :as bla]) if you type in other ns bla/something it will be available the code action Add missing my.custom-ns :as bla

ericdallo15:01:06

I think this is one of my favorite features of whole clojure-lsp :)

ericdallo15:01:19

Code actions are pretty useful most of the time (and they are totally optional for user :D )

Lukas Domagala15:01:38

yeah, I really love all the code actions. great work on those @ericdallo!

gratitude 1
jacob.maine21:01:15

I’d vote yes for a setting, enabled by default

👍 1
Noah Bogart12:01:13

I'm okay with that. I pretty much do that already

👍 1
practicalli-johnny14:01:23

I created some :additional-snippets for Clojure LSP in the following repo to complement the built in snippets. https://github.com/practicalli/clojure-lsp-config Unfortunately I cant get additional snippets to work in various setups yet, so appreciate any feedback on these. i.e. do they work okay. The snippets are also documented here: https://practical.li/spacemacs/snippets/clojure-lsp/practicalli-snippets.html

ericdallo14:01:53

Cool, IMO we could consider moving some of those to built-in snippets WDYT? I can test those later, thanks for that!

Lukas Domagala15:01:09

@U05254DQM what setup do you currently have? I’m working on fixing LSP snippets in Calva currently

practicalli-johnny15:01:39

Happy to have any of them included in the built-in snippets

practicalli-johnny15:01:26

@U02EMBDU2JU I've tried Doom Emacs and Spacemacs. Its been a while since I used Calva, but could do some testing with that too. I occasionally used Calva for the VS Code Live session sharing, so good to have snippets working there too.

Lukas Domagala15:01:26

It won’t work right now, still trying to fix it. But I’ll also try with your config

👍 1
Lukas Domagala01:01:14

@U05254DQM theres a bug in the customsnippets load code. Once that’s fixed your snippets will work in calva. Well once my calva fix PR is merged as well 😉

👍 1
ericdallo13:01:53

The issue I found with addictional-snippets is that they doesn't work on top-level form, let me record to make it clear the understanding:

👍 1
ericdallo13:01:15

The best would be to solve that

Lukas Domagala13:01:07

ah makes sense. I think thats a fix for you though, I haven’t looked into the clj-rewrite zipper stuff yet

Lukas Domagala13:01:27

and you are right, the additional snippets work in calva as well once I’m inside a list

ericdallo13:01:35

yeah, the issue is that there are custom snippets that can use current-form variable, this one is mandatory to have a form

ericdallo13:01:41

but all other ones should not require that

ericdallo13:01:24

@U02EMBDU2JU made a fix on master, could you try later please?

Lukas Domagala13:01:11

sure, thanks for the quick bug fix, as always 🙂

👍 1
Lukas Domagala13:01:41

just built it, its working! 🚀

ericdallo13:01:36

Good, @U05254DQM it should work for you too :)

Lukas Domagala13:01:38

now you just need to help me with the final little thing in the snippet PR to get it working for calva 😅

ericdallo13:01:06

sure, I intend to start reviewing your and Jacob PR tonight

❤️ 1
ericdallo16:01:30

@U02EMBDU2JU could you do a final rebase so I can try your PR and understand it why it's not working?

practicalli-johnny22:01:33

With the current Clojure LSP release the snippets are working within a (comment ,,,) form. I often write new code in a comment form anyway, especially when experimenting with data and function design. So I can use that approach until a new release of clojure-lsp comes out with the fix for top level snippets. Thanks.

papachan15:01:39

Can we skip some specific file like user.clj file with clean-ns?

ericdallo15:01:17

You can add to the top ns something like:

#_:clj-kondo/ignore
without changing your code, no

1
ericdallo15:01:31

this is something I'd like to have to configure via clj-kondo, @U04V15CAJ is aware of that I think

ericdallo15:01:29

A way to configure kondo linters for specific namespaces

borkdude15:01:22

indeed, there is an issue for it

👍 1
jacob.maine19:01:21

A similar question… what about a setting to format the range (or the whole buffer) after refactorings? Of course, ideally the refactorings would always generate well-formatted code.

ericdallo20:01:00

yeah, the issue is that we have some performance issues with cljfmt ATM, that flag would need to be off by default for sure

jacob.maine23:01:02

Gotcha, makes sense

ericdallo22:01:11

I usually do that to test a single integration-test

ericdallo22:01:17

I should fix it soon

jacob.maine23:01:29

👌 That’s what I suspected.