Fork me on GitHub
#lsp
<
2023-01-19
>
borkdude15:01:58

Any idea why navigation won't work in this case from the bottom defn usage to the custom defn macro one? I looked at the clj-kondo analysis and this seems right

(ns foo
  (:refer-clojure :exclude [defn])
  (:require [clojure.core :as core]))

(core/defmacro defn [name & body]
  `(core/defn ~name ~@body))

(|defn foo [])

ericdallo15:01:36

could you be more specific where it's the cursor with | that you are trying to find defintiion?

ericdallo15:01:25

so you expect to go to the macro definition in that file right?

ericdallo15:01:43

let me double check

borkdude15:01:12

In metabase, when I run "find references" on the custom defn macro, I get a lot of clojure.core/defn references instead

ericdallo15:01:13

hum, for some reason, the var-definition of your custom defn seems wrong, you can confirm that calling lsp-clojure-cursor-info with cursor on that defn

ericdallo15:01:25

it seems to be pointing to clojure.core/defn for some reason

ericdallo15:01:02

the :ns especifically is wrong, not sure if it's a clojure-lsp or kondo bug, let me check

borkdude15:01:44

$ clojure -M:clj-kondo/dev --lint src/foo.clj --config '{:analysis true :output {:format :edn}}' | jet --query ':analysis :var-definitions'
[{:col 1,
  :defined-by clojure.core/defmacro,
  :end-col 29,
  :end-row 6,
  :filename "src/foo.clj",
  :macro true,
  :name defn,
  :name-col 16,
  :name-end-col 20,
  :name-end-row 5,
  :name-row 5,
  :ns clojure.core,
  :row 5,
  :varargs-min-arity 2}]

ericdallo15:01:47

if you rename to something else like defna works haha

borkdude15:01:02

weeiiird :) ok, thanks, the issue is in clj-kondo then

ericdallo15:01:18

you're welcome!

borkdude16:01:43

found the issue

ericdallo16:01:13

What was it?

borkdude16:01:25

There were some overrides applied to the stored analysis for clojure.core, but this was done regardless of the namespace. It should only be done for clojure.core/cljs.core https://github.com/clj-kondo/clj-kondo/blob/38bf429b4ffb5712bebd7fd63c1db34f1a600699/src/clj_kondo/impl/analysis.clj#L87 cc @UPWHQK562 :)

ericdallo16:01:02

Nice, I can bump kondo on LSP

borkdude16:01:28

not yet, I didn't push it yet

👍 2
sheluchin16:01:10

Ah, thanks for finding my bug 🙂

borkdude16:01:12

My pleasure ❤️

4
borkdude17:01:48

@UKFSJSM38 ready to be bumped

borkdude17:01:08

I made a dev script to launch clojure-lsp from my local dev folder with also my local version of clj-kondo:

#!/usr/bin/env bash

clj -Sdeps '{:deps {clj-kondo/clj-kondo {:local/root "/Users/borkdude/dev/clj-kondo"}
                    clojure-lsp/clojure-lsp {:local/root "/Users/borkdude/dev/clojure-lsp/cli"}
                    cider/cider-nrepl {:mvn/version "0.28.6"}}}' -M -m clojure-lsp.main
I called this script ~/bin/clojure-lsp-dev and use it in my emacs settings as the server command Including nREPL takes care of having an nREPL available to make changes to clj-kondo and clojure-lsp while it's running. The bb debug-cli is nice, but I needed to re-generate it too often

ericdallo17:01:00

that looks nice!

ericdallo18:01:32

Since I don't code that much on clj-kondo, I usually run this:

alias update-clojure-lsp='bash <(curl -s ) --dir ~/dev/clojure-lsp/ --version nightly --static
which downloads the latest nightly if I'm not actively developing something

J20:01:02

Hi guys! I’m using clojure-lsp with emacs and I have this error in /tmp/clojure-lsp.out:

Error while looking up classpath info in /Users/.../Documents/labs/.... Error: Cannot run program "clojure" (in directory "/Users/.../Documents/labs/..."): error=2, No such file or directory
I don’t know why I get this error. I can run clojure -M:dev in the project

ericdallo21:01:52

probably your clojure is not in the PATH emacs is using, try launching emacs from your terminal which has the clojure command working

J21:01:52

Oh right! Did you know how update the emacs PATH (started without the terminanl)