lsp

J 2026-03-06T16:06:11.599749Z

Hi! Is there a way to keep an entry of ns form in place:

(ns foo
  (:require
    [zzz.core] ;; keep this first
    [aaa.core]
    [bbb.core])

dpsutton 2026-03-06T16:15:27.729259Z

i tried putting #_ aaa and #_ 1 in the vector but it causes it to fail

lassemaatta 2026-03-06T16:15:32.591569Z

not to get all XY problemy, but why?

J 2026-03-06T16:17:39.542589Z

In order to load data_readers first

dpsutton 2026-03-06T16:17:58.151249Z

oh . you want to affect the load order?

ericdallo 2026-03-06T16:19:02.988699Z

I think the only way is having a name that sorting alphabetically will leave it in the start

J 2026-03-06T16:22:49.837219Z

@dpsutton idealy yes. Here zzz.core allow to load functions used by data_readers.clj Some functions are used inside bbb.core

ericdallo 2026-03-06T16:24:17.841439Z

we faced similar issues at nubank, but we ended up moving the zzz.core upper in ns hierarchy so it's available more globally in the project

lassemaatta 2026-03-06T16:24:18.685889Z

>

When Clojure starts, it searches for files named 'data_readers.clj'
> and 'data_readers.cljc' at the root of the classpath.
do you actually need to manually require it?

J 2026-03-06T16:28:18.384119Z

@lasse.olavi.maatta following this little guide, I think the require is require ^^ https://gist.github.com/wandersoncferreira/06bdefe99b9db12fcf7ce269b2f42a63

👍 1
J 2026-03-06T16:30:49.493119Z

@ericdallo your ns is automaticaly sorting or not?

ericdallo 2026-03-06T16:32:35.108559Z

yes, I don't recall right now, but moving up in the dependecny tree the zzz.core may help

J 2026-03-06T16:50:14.728069Z

The workaround for the moment:

{...
 :aliases {:aot {:main-opts ["-e" "(do (require '[zzz.core]) (compile foo)]}
           :uberjar {:extra-deps [...]
                     :main-opts ["-m" "uberdeps.uberjar" "--aliases" "aot" "--main-class" "foo"]"}}

😅 1
olli 2026-03-06T19:14:19.081039Z

I was going to suggest making your own clj-kondo linter for that (since there's one for unsorted namespaces) but while looking around it's codebase I ran into https://github.com/clj-kondo/clj-kondo/tree/master/src

olli 2026-03-06T19:15:02.257669Z

So I guess you could try naming zzz.core to aaa.core 🤠

boosja 2026-03-06T06:42:56.942699Z

I'm working on an emacs package where I need to find all the function calls of certain functions. Is there a way to query the clojure-lsp cache programmatically from a predefined list of fully-qualified function-names with emacslisp?

olli 2026-03-06T08:22:21.871189Z

You know about https://github.com/emacs-lsp packages right? I'm not super familiar with emacs or clojure-lsp but use lsp-mode and lsp-ui in my daily work. I think you'd be interested to look at the function https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L6923 and follow the call stack until you find the level of abstraction you like

teodorlu 2026-03-06T08:23:20.154699Z

I believe you can call the language server directly — not the Emacs part of clojure-lsp, but the language server over the protocol (JSON over HTTP).

olli 2026-03-06T08:23:26.811099Z

The lsp-mode package also provides a jsonrpc log if that's interesting to your case https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/#log-client-server-json

boosja 2026-03-06T08:25:43.935159Z

The lsp-mode api works only on positional symbols in files on disk. What I want is to query lsp for a string

olli 2026-03-06T08:25:54.389659Z

Looking at the logs on my machine, it seems like what's being sent is just filenames and line/col, not the fully-qualified function name. I suppose you could look at the clojure-lsp source code if there's any symbolic mapping available

olli 2026-03-06T08:27:23.630339Z

Yeah. Then you've got https://github.com/clojure-emacs/clj-refactor.el but I'm not familiar with it's internals

boosja 2026-03-06T08:28:47.969219Z

I have thought about using clj-kondo to find what I am looking for, but I was just wondering if there was a way to query the lsp-cache, since the data should already be there

boosja 2026-03-06T08:29:04.756669Z

I haven't looked into clj-refactor.el

boosja 2026-03-06T08:33:57.117659Z

The purpose of the package is not refactoring of the code though 🤔

borkdude 2026-03-06T09:00:40.675899Z

you can call out to the clj-kondo binary to find those. https://github.com/clj-kondo/clj-kondo/tree/master/analysis

borkdude 2026-03-06T09:01:50.937439Z

there was a package called anakonda.el which did this as well

borkdude 2026-03-06T09:01:57.640119Z

but using clojure-lsp may work well too

borkdude 2026-03-06T09:02:35.495839Z

(https://github.com/didibus/anakondo)

👀 1
borkdude 2026-03-06T09:03:14.624639Z

o wait, that was only used for completions, but I guess it's not too far off

olli 2026-03-06T09:03:37.793299Z

Looks like you can use the CLI too clojure-lsp references --from 'my-ns/the-symbol' <ps://clojure-lsp.io/api/cli/|https://clojure-lsp.io/api/cli/>

👍 1
boosja 2026-03-06T09:04:42.415119Z

I'll check out how anakondo calls clj-kondo 🙏

boosja 2026-03-06T09:05:26.979759Z

clojure-lsp references --from 'my-ns/the-symbol' This does not work for libraries' function calls, not quite sure why

borkdude 2026-03-06T09:05:39.618789Z

anakonda is calling clj-kondo here: https://github.com/didibus/anakondo/blob/16b0ba14d94a5d7e55655efc9e1d6d069a9306f2/anakondo.el#L320

🙏 1
boosja 2026-03-06T09:05:51.803579Z

Or clojure.core/filter for instance

olli 2026-03-06T09:06:56.172069Z

Using the clojure-lsp jvm API would seem interesting too if you need to do something more than just list the occurrences. Possibly with babashka? https://github.com/babashka/pod-registry/blob/master/examples/clojure-lsp.clj

👀 1
boosja 2026-03-06T09:07:01.440899Z

☝️ that was just a test, but similar to what I want to do

boosja 2026-03-06T09:09:07.308909Z

Thanks for all the help and suggestions 🙏 😊 I have some paths to look into further.

boosja 2026-03-06T09:10:11.160229Z

It might end up as a clojure-dep instead as @teodorlu suggested over Tuple, just now 😄

borkdude 2026-03-06T09:10:56.209809Z

what's Tuple?

boosja 2026-03-06T09:15:15.111759Z

https://tuple.app/

boosja 2026-03-06T09:15:37.053199Z

It is the pair-programming video conference tool we use at work

👍 1
boosja 2026-03-06T09:15:56.898589Z

It gives you (almost) full access to the others computer

boosja 2026-03-06T09:16:13.325779Z

Very handy within a team