Fork me on GitHub
#calva
<
2022-08-04
>
Max15:08:11

Does calva/lsp have the ability to update namespace names and references when you move a file? I know it’ll do it for renaming files, but I can’t seem to get it to work for moving files.

lilactown15:08:04

I get this behavior when using emacs and lsp. I assume it's clojure-lsp behavior

ericdallo15:08:38

Clojure-lsp supports that, but clients need to opt-in

Max16:08:47

Is this something that’d have to be turned on in Calva?

ericdallo16:08:07

nope, I think if Calva is already using a vscode-language-client that supports this request, it should work already c/c @U9A1RLFNV

bringe17:08:34

Calva / the lsp client lib sends this during initialization:

"workspace": {
            "fileOperations": {
                "willRename": {
                    "filters": [
                        {
                            "pattern": {
                                "glob": "**/*.{clj,cljs,cljc,cljd,edn,bb,clj_kondo}",
                                "matches": "file"
                            },
                            "scheme": "file"
                        }
                    ]
                }
            }
        },

bringe17:08:51

I don’t know if that is related to supporting exactly what @U01EB0V3H39 is referring to, though.

ericdallo17:08:27

looks correct, @U01EB0V3H39 could you share a repro project and saying exactly what you are trying to do and what you expect?

bringe17:08:42

The logs between client and server might be helpful, too.

👍 1
bringe17:08:54

From after trying to do it.

Max20:08:44

I have a hunch this might be PEBCAC (sorry!) I might’ve at some point clicked the “don’t ask me again” box in the prompt. Does anyone happen to know the name of the key in vscode’s state where that’s set?

Max21:08:41

Ok, I managed to figure out the key after some trial and error. Unfortunately, resetting it doesn’t fix the issue. I’ve also seen it work successfully on another computer, so this appears to be localized to my setup somehow. Here’s a trace of the lsp communication when I move a file.

bringe23:08:06

Hmm… should there be some other message about the changing of the namespace for the new file, @UKFSJSM38? Or would that change be included in the textDocument.text value of the textDocument/didOpen notification?

bringe00:08:45

@U01EB0V3H39 It might also help to compare the above with the messages from a computer that it works on.

👍 1
Max21:08:30

Here you go

ericdallo22:08:48

That log looks correct to me

bringe02:08:02

The response in the first logs show no document changes in the willRenameFiles response, but the response in the second one does. Why might clojure-lsp be sending the edits in one project but not another when a file is renamed?

bringe02:08:59

A repro project might help.

Max04:08:23

Would a repro project still help if the behavior is consistent across projects on the same computer?

bringe16:08:05

Hmm maybe not. Have you checked that you’re using the same version of Calva and clojure-lsp on both machines?

Max17:08:12

Calva v2.0.291, clojure-lsp 2022.07.24-18.25.43 on both. Also here’s the lsp server info on the computer where it’s not working.

Max17:08:21

I also tried blowing away my global state.vscdb and restarting vscode to see if that would fix it, it did not.

Max18:08:23

Good news! I was wrong, and it is specific to this particular repo. The cause appears to be repos with multiple projects in them. I didn’t notice before because I have quite a few of these on this particular computer. I pushed a repro repo up here: https://github.com/maxrothman/clojure-lsp-repro

ericdallo18:08:25

@U01EB0V3H39 is the root of that repo the root of your project? if so, it won't work indeed, you need at least a deps.edn in the root to clojure-lsp understand the project as a whole, or open the specific module you want to code

ericdallo18:08:45

clojure-lsp project itself has submodules, you can use it as example :)

Max18:08:32

For this particular project, a root deps.edn wouldn’t serve any purpose apart from getting clojure-lsp to work, since it’s really a few separate applications sharing a couple of libraries. Is there any interest in adding config that tells clojure-lsp where the root is? Or what needs to be in the root deps.edn for clojure-lsp to work? I added one that just contains an empty map, and it doesn’t seem to fix the problem.

ericdallo18:08:35

No, this is client's responsibility tell to server what is the root when initializing. Even so, it's a good practice for toolings having something on root that bring all together for tooling. having a empty deps.edn wouldn't help since you would be ignoring the submodules deps.edn, what you can do is link the inner modules deps.edn on the root deps.edn like clojure-lsp does https://github.com/clojure-lsp/clojure-lsp/blob/master/deps.edn#L2-L5. Other libs like #polylith works similar

Max18:08:28

Adding a proper root-level deps.edn worked, thanks!

🆒 1
🎊 1
Alexander Kouznetsov17:08:48

Hey team, I have the following problem: when I add debug println statements to my code and evaluate it, I often get the output heavily truncated in the output window. Sometimes even the beginning of some printlns isn’t printed. Has anybody experienced the same issue? I’m on the latest calva and vscode version.

bringe18:08:11

It sounds like pprint is truncating the output. You can try disabling pprint by clicking the button in the status bar at the bottom right, or you can edit your pprint settings to make it not truncate, or to truncate at a much higher value.

bringe18:08:23

Although that last issue you mentioned sounds odd.

Alexander Kouznetsov19:08:25

I actually found that it was turned off. I don’t have a good example to reproduce ATM, I’ll post when I see it again.

👍 1