I've seen this before too but haven't been able to repro consistently. If you can repro consistently it may be much easier for you to fix if you did find the time. No worries if not though. :simple_smile:
For the record, my assessment was about adding the filtering. š
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?
@marcus.josefsson please be more specific
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.@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
@marcus.josefsson Can you test this with clj-kondo
on the command line?
And if the problem persists there, please make a repository I can clone locally to reproduce the problem
Thanks - yep, the namespaces are called in the same way, so Iāll try that.
@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
@marcus.josefsson have you tried restarting vscode? perhaps lsp isn't refreshing your config correctly?
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?
At this point I must defer the problem to @pez and @ericdallo / @snoe
Ok - thank you!
A minimal reproduction project would be great, @marcus.josefsson.
Yes āļø also you could try rm -rf .lsp
(even if this should work without doing that) and restart server
Restart server is probably Command Palette -> Developer: Reload Window.
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 .lsp
folder 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?
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.
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.
@pez Ha, guess what, it happened again. Unfortunately I'm not in calva dev mode š
anything to try before I restart code/calva?
See if you can see anything in the Development console.
And see if you can delete stuff using alt+enter.
alt-del or alt-backspace you mean, right?
can't
Yeah, sorry. In a bit of a hurry here and getting sloppy. š
But you can enter text?
hmm actually it seems that I can't do anything, not just deletion.
I can enter text, yes
Can you select text and then delete it?
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...
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
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
even expanding selection via alt+shift+right_arrow...
Anything in the dev console?
perhaps something stucks some global action-handling code in calva.
re console: i'll check
Yes. something is either stuck or not initialized as it should.
which console?
Help Menu -> Toggle Developer Tools.
oh, this is beautiful, didn't know about this one š
I think the best path is to always run Calva in dev mode and then hope that you can catch it with the debugger.
WARN UNRESPONSIVE extension host, 'betterthantomorrow.calva' took 93% of 5149.568ms, saved PROFILE here: 'file:///tmp/exthost-59fb4f.cpuprofile' Array(2)
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.
I need to run now, have a Clojure presentation to deliver. Sorry for abandoning you!
awesome, fingers crossed ! And don't be nervous, there's no reason for that, Calva is great stuff !
Try figure if it might be a particular file that sends Calva into this spin.
Last time I did this my live coding ended in a bug I couldnāt fix. Weāll see how I fare this time. š
@pez FYI I created the issue here https://github.com/BetterThanTomorrow/calva/issues/1167 & included the console log + cpuprofile file
btw hope your live coding session went well š
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. š
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?
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.
Np, it's something Calva should check indeed, as block user input is not good in any way š
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.
I feel a bit guilty for hoping it will happen to you again @brdloush. š 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.
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.