Fork me on GitHub
#calva
<
2021-04-26
>
mjosefs10:04:28

Hi! It seems like my :lint-as specifications in .clj-kondo/config.edn aren’t picked up in .cljs files, though it works fine in .clj and .cljc files. Unsure whether it’s a Calva or clj-kondo issue, but should I specify or set this up separately somehow?

borkdude10:04:25

@marcus.josefsson please be more specific

mjosefs10:04:38

Sure! By “`:lint-as` specifications in .clj-kondo/config.edn” I mean a bunch of stuff along the lines of:

{:lint-as {my-ns/deftest clojure.core/def
           my-ns/def     schema.core/def
           my-ns/defn    schema.core/defn
           ...}
Now, in .cljs files, writing e.g. (my-ns/defn my-fn …) gives a linting error Unresolved symbol: my-fn clj-kondo(unresolved-symbol). When just starting out with Calva this used to happen in .clj and .cljc files as well, but the :lint-as specifications fixed that (as per the “unrecognized macros” instructions in the user guide) - so my guess is they’re somehow not picked up in the case of .cljs files.

borkdude10:04:17

@marcus.josefsson I don't see why that wouldn't work specifically for .cljs unless the namespace is called differently in your ns form in the .cljs file

borkdude10:04:25

@marcus.josefsson Can you test this with clj-kondo on the command line?

borkdude10:04:40

And if the problem persists there, please make a repository I can clone locally to reproduce the problem

mjosefs10:04:40

Thanks - yep, the namespaces are called in the same way, so I’ll try that.

mjosefs10:04:10

@borkdude no errors or warnings when checking with the command line tool, so would appear it’s not picking up the config when in VS Code, for .cljs

borkdude10:04:32

@marcus.josefsson have you tried restarting vscode? perhaps lsp isn't refreshing your config correctly?

mjosefs10:04:29

I’ve tried restarting it a couple of times, but no errors visible on startup at least. Anything specific I could try to check the config?

borkdude10:04:59

At this point I must defer the problem to @pez and @ericdallo / @snoe

mjosefs11:04:01

Ok - thank you!

pez11:04:39

A minimal reproduction project would be great, @marcus.josefsson.

ericdallo12:04:26

Yes ☝️ also you could try rm -rf .lsp (even if this should work without doing that) and restart server

pez12:04:49

Restart server is probably Command Palette -&gt; Developer: Reload Window.

Tomas Brejla13:04:12

Hello. I see that ericdallo suggested removing .lsp and restarting to server for some other issue ^^^. By a coincidence, I managed to get my Calva to some weird state today and I ended up deleting that folder too. And it actually seemed to help. But it may have been a coincidence. Here's how my Calva behaved: 1. in my core.clj file, I wasn't able to perform deletion via either Del or Backspace keys. No metter where I placed my cursor, Del/Backspace did nothing. I think I was able to "delete" expressions by selecting them and then pressing some key (space or any character key). I tried restarting REPL, restarting Calva (vs code), didn't help. 2. as a last resort, I tried deleting .lspfolder then performing calva restart. Once I connected my REPL again, everything worked fine. I believe similar thing (not being able to del/backspace) already happened to me once in the past, but it somehow fixed itself. This time I had to delete the .lsp folder - not sure if this really helped, but it's posible it did. Any idea what to check if it ever happens again?

ericdallo13:04:56

thanks for the explanation, but I don't think LSP could block your input in anyway :thinking_face: Maybe this is related with other calva feature?

Tomas Brejla13:04:01

I'm not sure if LSP server was able to fully start up or not. Perhaps it somehow got stuck while initializing and Calva was waiting for it or something like that. But it's just a wild speculation, I'm definitely not pointing any fingers 🙂. It felt really weird, especially the fact that restarting didn't help. Hopefully next time it happens I'll be able to get more details.

ericdallo13:04:44

Np, it's something Calva should check indeed, as block user input is not good in any way 🙂

pez15:04:23

I feel a bit guilty for hoping it will happen to you again @U01LFP3LA6P. 😃 Joking, but really, sounds awful and if you have it, I get worried that others are experiencing as well. I’m trying to think what could be going on. The fact that it was del/backspace that died gives us some clue, as those are bound to commands in Calva. If you experience it again, see if alt+backspace works.

bringe20:04:47

Yeah, nothing should be blocked like that during clojure-lsp startup, as we've made that async. And nothing should be blocked if it fails to start either. But we'll have to see what's going on if you can find a repro in the future.

Tomas Brejla07:04:29

I actually hope to see that issue again as well, so that I could investigate it in more detail. Unfortunately I didn't have time for that yesterday, so I was trying all the things to quickly get over the issue. Maybe a question from the other way around.. Under which conditions del/`backspace` gets "ignored" in normal conditions? It's somehow related to paredit and the fact that if expressions would end up in unbalanced, the deletion doesn't get performed, right? If so, what moving part would have to break so that it could lead to the behavior I have seen? Probably nothing related to lsp and clj-kondo (?). Perhaps some expression parsing ? due to incorrect identation / unbalanced expressions etc? It's entirely possible I might have had some issues in my code. This specific one is quite a long scratch-pad really and my "identation" sometimes gets broken after copy-pasting. I also might have had some unsaved changes etc.

pez08:04:21

I’m not sure about this, but I think the general protection against deleting balancing things never behave in a “nothing at all happens” way. The cursor is moved past the bracket instead. In case of complete unbalance of all the things this could maybe happen, even if I doubt it. Under the hood Calva keeps a “mirror” document for each editor document. It is this mirror that is used for determining, and updating, the structure (this two-way nature of it makes the term “mirror” is a broken metaphor). Some operations can throw the mirror out of whack. Like if you change the line ending of the file from windows to unix style or vice versa). Then, maybe, what you experienced could happen. But you should also see Calva Highlight paint a lot of closing brackets red in that case. And, for sure, restarting VS Code should fix it. What is more likely to me is that the Calva command bound to backspace, never gets registered. The binding is static and declarative. The registration is dynamic and imperative. Maybe the best thing to do is to run that project in Calva dev mode. Then if this happens again, use the debugger to try find where it fails.

Tomas Brejla14:05:59

@pez Ha, guess what, it happened again. Unfortunately I'm not in calva dev mode 😞

Tomas Brejla14:05:31

anything to try before I restart code/calva?

pez14:05:48

See if you can see anything in the Development console.

pez14:05:00

And see if you can delete stuff using alt+enter.

Tomas Brejla14:05:40

alt-del or alt-backspace you mean, right?

pez14:05:01

Yeah, sorry. In a bit of a hurry here and getting sloppy. 😃

pez14:05:24

But you can enter text?

Tomas Brejla14:05:25

hmm actually it seems that I can't do anything, not just deletion.

Tomas Brejla14:05:31

I can enter text, yes

pez14:05:01

Can you select text and then delete it?

Tomas Brejla14:05:57

no, not using del/backspace.. I can only select the text and then overwrite it by pressing some regular key, such as A,B,C...

Tomas Brejla14:05:04

but no matter what text editor I open, whenever it's .clj, I'm not able to do any calva-specific actions. I can't indent, i can't execute code.. nothing

Tomas Brejla14:05:37

even if I create a completely new clj file, open it, write a basic hello-world form, I'm not able to perform any usual calva action

Tomas Brejla14:05:14

even expanding selection via alt+shift+right_arrow...

pez14:05:25

Anything in the dev console?

Tomas Brejla14:05:44

perhaps something stucks some global action-handling code in calva.

Tomas Brejla14:05:50

re console: i'll check

pez14:05:15

Yes. something is either stuck or not initialized as it should.

Tomas Brejla14:05:20

which console?

pez14:05:39

Help Menu -> Toggle Developer Tools.

Tomas Brejla14:05:09

oh, this is beautiful, didn't know about this one 🙂

pez14:05:20

I think the best path is to always run Calva in dev mode and then hope that you can catch it with the debugger.

Tomas Brejla14:05:39

WARN UNRESPONSIVE extension host, 'betterthantomorrow.calva' took 93% of 5149.568ms, saved PROFILE here: 'file:///tmp/exthost-59fb4f.cpuprofile' Array(2)

pez14:05:35

Grab that profile and attach it to an issue on github. File issue using that Help menu and we will get some system context attached.

pez14:05:22

I need to run now, have a Clojure presentation to deliver. Sorry for abandoning you!

👍 3
Tomas Brejla14:05:52

awesome, fingers crossed ! And don't be nervous, there's no reason for that, Calva is great stuff !

pez14:05:07

Try figure if it might be a particular file that sends Calva into this spin.

☝️ 3
pez14:05:48

Last time I did this my live coding ended in a bug I couldn’t fix. We’ll see how I fare this time. 😃

🤞 3
👏 6
Tomas Brejla08:05:55

@pez FYI I created the issue here https://github.com/BetterThanTomorrow/calva/issues/1167 & included the console log + cpuprofile file

Tomas Brejla08:05:35

btw hope your live coding session went well 😉

pez09:05:02

Thanks! Yes it went well this time. Not saying I am safe from fuckups now, but I did learn something from the last one at least. 😃

👏 6
💪 3
mjosefs14:04:22

Thanks for the suggestions pez and ericdallo - while trying to make a minimal reproduction I found that it wasn’t after all related to the file types: my workspace is composed of several projects and unlike the others this one didn’t have its own .clj-kondo/config.edn file. I thought it was reading from a parent folder’s .clj-kondo/config.edn (which also exists) but apparently not so. (Coincidentally, the others were .clj/`.cljc`-based and this one was .cljs-based). So I have a few duplications of that file now, but it seems to work.

🎉 2