Fork me on GitHub
#lsp
<
2022-07-14
>
mpenet14:07:25

for some reason auto insertion of ns in new files doesn't work on my setup

ericdallo14:07:32

What editor are you using?

ericdallo14:07:49

what's the output of lsp-clojure-server-info ?

mpenet14:07:57

clojure-lsp 2022.06.22-14.09.50 clj-kondo 2022.06.22

mpenet14:07:48

well I just commented out auto-add-ns-to-new-files? to try it without

mpenet14:07:20

if I uncomment it it shows on lsp-clojure-server-info

mpenet14:07:23

:auto-add-ns-to-new-files? true,

ericdallo14:07:41

yeah, pretty weird not showing up on server-info

mpenet14:07:57

that was expected, it was commented, it shows no

👍 1
ericdallo14:07:03

also, how you are creating the new file? and is it inside the source-paths from server-info?

mpenet14:07:28

I mean the usual

ericdallo14:07:34

that setting is on by default, it should work as default

mpenet14:07:51

via vertico-exit

mpenet14:07:00

it selects the candidate and does whatever after

ericdallo14:07:11

Sounds correct

mpenet14:07:39

I have a setq cljr-add-ns-to-blank-clj-files nil in my conf

ericdallo14:07:55

correct too to avoid conflicts

mpenet14:07:03

I am quite sure it used to work tho

mpenet14:07:09

I ll try to nuke the cache

ericdallo14:07:29

Try restarting the LSP too

ericdallo14:07:37

the cache probably is not related, but you can try as well

mpenet14:07:49

already tried restarting

mpenet14:07:07

it works on another repo

ericdallo14:07:14

anything on server logs? lsp-clojure-server-log

ericdallo14:07:33

if it works on other repo, there is a chance to be bad source-paths configuration

ericdallo14:07:49

what's the path of the file?

mpenet14:07:00

Found the following clients for /home/mpenet/code/iam/modules/client/src/exoscale/iam/client/xzzzzzzzzzzzzz.clj: (server-id clojure-lsp, priority 0) The following clients were selected based on priority: (server-id clojure-lsp, priority 0)

mpenet14:07:08

oh, I think I might now

mpenet14:07:24

ok, the workspace is somewhat broken I think , it's a multi module repository and it's connected to the root not the module itself

ericdallo14:07:04

yes, that makes sense so. You can lsp-workspace-folders-remove and lsp to fix it

mpenet14:07:06

hmm no, no dice

mpenet14:07:03

:project-root-uri "file:///home/mpenet/code/iam/modules/client/src/exoscale/iam/client",

mpenet14:07:12

the root is correct, but it still wont create a ns form

mpenet14:07:19

I have to go on a call, back later

ericdallo14:07:53

when you get back, paste the server info of the fixed root

mpenet14:07:59

I updated the gist

ericdallo14:07:06

is file:///home/mpenet/code/iam/modules/client/src/exoscale/iam/client really correct for the project root? looks like it's duplicated client folder

mpenet14:07:24

yes it's correct

👍 1
ericdallo14:07:10

Does calling lsp-rename in another namespace work for that project?

mpenet14:07:08

yes it works

ericdallo14:07:37

hum, so the issue is not related to wrong source-paths /project-root as this feature relies on the same

ericdallo14:07:26

does server logs mention anything when creating the file?

mpenet14:07:46

Found the following clients for /home/mpenet/code/iam/modules/client/src/exoscale/iam/client/zzzzzzzzzzzzz.clj: (server-id clojure-lsp, priority 0) The following clients were selected based on priority: (server-id clojure-lsp, priority 0)

ericdallo14:07:59

this is not a server log, try lsp-clojure-server-log

mpenet14:07:58

2022-07-14T14:40:45.190Z WARN [clojure-lsp.kondo:260] - Non-fatal error from clj-kondo: No configs copied. 2022-07-14T14:40:45.190Z INFO [clojure-lsp.handlers:124] - :did-open 3ms 2022-07-14T14:40:45.190Z INFO [clojure-lsp.server:107] - :refreshing-test-tree 0ms 2022-07-14T14:40:45.190Z INFO [clojure-lsp.handlers:418] - :code-lens 0ms 2022-07-14T14:40:45.190Z INFO [clojure-lsp.handlers:437] - :semantic-tokens-range 0ms 2022-07-14T14:40:45.212Z INFO [clojure-lsp.handlers:252] - :document-highlight 0ms 2022-07-14T14:40:45.212Z INFO [clojure-lsp.handlers:437] - :semantic-tokens-range 0ms 2022-07-14T14:40:45.212Z INFO [clojure-lsp.handlers:404] - :code-actions 0ms 2022-07-14T14:40:45.223Z INFO [clojure-lsp.handlers:418] - :code-lens 0ms 2022-07-14T14:40:45.290Z DEBUG [clojure-lsp.server:82] - Publishing 0 diagnostics for file:///home/mpenet/code/iam/modules/client/src/exoscale/iam/client/bbbbbbbbbbbbbbbbbb.clj 2022-07-14T14:40:45.291Z INFO [clojure-lsp.server:83] - :publish-diagnostics 0ms 2022-07-14T14:40:45.714Z INFO [clojure-lsp.handlers:252] - :document-highlight 0ms 2022-07-14T14:40:45.714Z INFO [clojure-lsp.handlers:430] - :semantic-tokens-full 0ms 2022-07-14T14:40:45.715Z INFO [clojure-lsp.handlers:404] - :code-actions 1ms 2022-07-14T14:40:45.715Z INFO [clojure-lsp.handlers:369] - :hover 0ms

ericdallo14:07:25

file:///home/mpenet/code/iam/modules/client/src/exoscale/iam/client/bbbbbbbbbbbbbbbbbb.clj is not inside a valid source-path, it would need to be on file:///home/mpenet/code/iam/modules/client/src/exoscale/iam/client/src/bbbbbbbbbbbbbbbbbb.clj

mpenet14:07:52

hmm why the double src

ericdallo14:07:12

yeah, like I said, this folder structure is pretty weird IMO 😅

mpenet14:07:39

it doesn't have double src tho

mpenet14:07:46

not sure why it looks up stuff there

mpenet15:07:12

I mean home/mpenet/code/iam/modules/client/src/exoscale/iam/client/src does not exist

mpenet15:07:49

and modules/client/deps.edn has :paths ["src" "resources"]

ericdallo15:07:25

I'm confused. What's the correct project root? could you ls in your terminal?

mpenet15:07:05

~/code/iam/modules/client ❯ ls deps.edn resources src target test tests.edn

ericdallo15:07:47

right, so the project root on the server info is wrong

ericdallo15:07:59

you need to lsp-workspace-folders-remove and add it again with lsp

ericdallo15:07:33

specifying /home/mpenet/code/iam/modules/client

mpenet15:07:06

it works now 🙂

mpenet14:07:35

I also have :auto-add-ns-to-new-files? true

Jordan Yee17:07:31

Hello, I'm having an issue where certain LSP features such as go-to-definition and get-references are getting results from the output directory in a ClojureScript project. This output directory is under the resources/ directory, which sounds like it should be ignored by default by the :source-paths-ignore-regex setting. How might I diagnose whether I need to fix some local configuration, or if this is a bug?

❯ clojure-lsp --version
clojure-lsp 2022.06.29-19.32.13
clj-kondo 2022.06.22

ericdallo17:07:28

What editor are you using? if Emacs could you paste lsp-clojure-server-info ?

frank18:07:03

I continued to experience this after upgrading to a version of clojure-lsp that supported source-paths-ignore-regex. It went away after I deleted the clj-kondo and clojure-lsp caches and restarted clojure-lsp

Jordan Yee19:07:35

I'm using Kakoune, so I don't have that Emacs info. I did try to delete the caches and restart, but it didn't work. I'll try that again just in case I missed something the first time. 1. Delete all caches

rm -rf .clj-kondo/.cache
rm -rf .lsp
rm -rf .cpcache # didn't do this the first time
2. Start editor; wait for lsp to initialize

Jordan Yee19:07:30

3. Try list-symbol-references... ...and I'm still seeing a reference in the out directory.

ericdallo19:07:10

we need the server info information, emacs and calva have commands to retrieve that

ericdallo19:07:26

not sure about kakoune, but it's a LSP command the editor need to call

Jordan Yee19:07:16

I'm looking into that, but in the meantime is there a way to get this when running the server from the command line?

ericdallo19:07:55

hum, not really this is mostly a information important for the long running session

ericdallo19:07:09

you can try clojure-lsp <task> --verbose

Jordan Yee19:07:38

One thing to note is that after updating to the latest version, deleting the caches, and restarting the lsp server, I don't seem to be able to hit an output directory via go-to-definition, but it is showing up in the list-refrences results.

ericdallo20:07:44

It should not show on both, unless you opened the resource file manually

Jordan Yee20:07:28

Ok, I have the server info from Calva, but may have to sanitize it since it's a private project. What info would you be after from that?

ericdallo20:07:21

project-root, source-paths and settings

Jordan Yee20:07:20

{
  "client-settings":{
    "auto-add-ns-to-new-files?":true,
    "document-formatting?":false,
    "dependency-scheme":"jar",
    "keep-require-at-start?":true,
    "linters":{
      
    },
    "document-range-formatting?":false,
    "cljfmt-config-path":".cljfmt.edn"
  },
  "project-root-uri":"file:///Users/<user>/repos/<project>",
  "cljfmt-raw":"{:paths [\"src\" \"test\"], :indents {fn-traced [[:inner 0]]}}",
  "clj-kondo-version":"2022.06.22",
  "final-settings":{
    "auto-add-ns-to-new-files?":true,
    "document-formatting?":false,
    "dependency-scheme":"jar",
    "keep-require-at-start?":true,
    "source-paths":[
      "/Users/<user>/repos/<project>/src/clj",
      "/Users/<user>/repos/<project>/dev-resources",
      "/Users/<user>/repos/<project>/src/cljc",
      "/Users/<user>/repos/<project>/env/dev/clj",
      "/Users/<user>/repos/<project>/test",
      "/Users/<user>/repos/<project>/src",
      "/Users/<user>/repos/<project>/src/cljs"
    ],
    "project-specs":[
      {
        "project-path":"project.clj",
        "classpath-cmd":[
          "lein",
          "with-profile",
          "+test,+dev",
          "classpath"
        ]
      },
      {
        "project-path":"deps.edn",
        "classpath-cmd":[
          "clojure",
          "-A:test:dev",
          "-Spath"
        ]
      },
      {
        "project-path":"build.boot",
        "classpath-cmd":[
          "boot",
          "show",
          "--fake-classpath"
        ]
      },
      {
        "project-path":"shadow-cljs.edn",
        "classpath-cmd":[
          "npx",
          "shadow-cljs",
          "classpath"
        ]
      },
      {
        "project-path":"bb.edn",
        "classpath-cmd":[
          "bb",
          "print-deps",
          "--format",
          "classpath"
        ]
      }
    ],
    "linters":{
      
    },
    "source-aliases":[
      "dev",
      "test"
    ],
    "uri-format":{
      "upper-case-drive-letter?":false,
      "encode-colons-in-path?":false
    },
    "document-range-formatting?":false,
    "cljfmt-config-path":".cljfmt.edn"
  },
  "classpath":[
    ...<.m2 paths cut>,
    "/Users/<user>/repos/<project>/resources",
    "/Users/<user>/repos/<project>/src/clj",
    "/Users/<user>/repos/<project>/dev-resources",
    "/Users/<user>/repos/<project>/target/classes",
    "src",
    "/Users/<user>/repos/<project>/src/cljc",
    "/Users/<user>/repos/<project>/env/dev/clj",
    "/Users/<user>/repos/<project>/test",
    "/Users/<user>/repos/<project>/src",
    "/Users/<user>/repos/<project>/src/cljs",
    "test",
    
  ],
  "port":"NREPL only available on :debug profile (`make debug-cli`)",
  "server-version":"2022.06.29-19.32.13",
  "log-path":"/var/folders/r4/0dgj2cyx4_v74vmp43t1sy700000gs/T/clojure-lsp.2977080460538470698.out",
  "project-settings":{
    
  }
}

ericdallo20:07:42

I don't see any resources on the source-paths, which looks correct, but I do see "/Users/<user>/repos/<project>/dev-resources" , is your generated code on that folder?

ericdallo20:07:48

source-paths looks pretty correct, it's excluding both target and resource folders, so the only reason is if you opened that target file manually, could you try restart the editor and close all files before that to avoid editor opening those files?

Jordan Yee21:07:49

No, dev-resources doesn't have any generated code in it. I've closed everything down, deleted the cache directories, and restarted my editor. But it sounds like something else must be holding onto the resources path... Aside from the cache directories I mentioned above, are there any others you might know if, or that would be stored outside of the project?

ericdallo21:07:39

No, we do have a global cache for other purposes though, /.cache/clojure-lsp or /.config/clojure-lsp

ericdallo21:07:49

Unlikely to be related

Jordan Yee21:07:17

So the good news is that after updating to the latest version of clojure-lsp, I haven't been able to get to an output file via go-to-definition. But I do still see some out references in the results of list-symbol-references command. If that holds, then at least it means I can avoid the output files if I'm paying a little bit of attention when looking at references, but I'm curious to know what's going on since this seems like it shouldn't be a possible scenario. Also, I feel like I should mention that other than this, the lsp server is working great and I've seen it improve a lot over the years, so thanks for your work on it!

ericdallo21:07:54

Thank you :) Yeah, pretty interesting this behavior, maybe try with calva or emacs so we can disconsider anything with the editor