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])i tried putting #_ aaa and #_ 1 in the vector but it causes it to fail
not to get all XY problemy, but why?
In order to load data_readers first
oh . you want to affect the load order?
I think the only way is having a name that sorting alphabetically will leave it in the start
@dpsutton idealy yes. Here zzz.core allow to load functions used by data_readers.clj
Some functions are used inside bbb.core
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
>
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?@lasse.olavi.maatta following this little guide, I think the require is require ^^ https://gist.github.com/wandersoncferreira/06bdefe99b9db12fcf7ce269b2f42a63
@ericdallo your ns is automaticaly sorting or not?
yes, I don't recall right now, but moving up in the dependecny tree the zzz.core may help
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"]"}}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
So I guess you could try naming zzz.core to aaa.core 🤠
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?
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
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).
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
The lsp-mode api works only on positional symbols in files on disk. What I want is to query lsp for a string
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
Yeah. Then you've got https://github.com/clojure-emacs/clj-refactor.el but I'm not familiar with it's internals
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
I haven't looked into clj-refactor.el
The purpose of the package is not refactoring of the code though 🤔
you can call out to the clj-kondo binary to find those. https://github.com/clj-kondo/clj-kondo/tree/master/analysis
there was a package called anakonda.el which did this as well
but using clojure-lsp may work well too
o wait, that was only used for completions, but I guess it's not too far off
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/>
I'll check out how anakondo calls clj-kondo 🙏
clojure-lsp references --from 'my-ns/the-symbol'
This does not work for libraries' function calls, not quite sure why
anakonda is calling clj-kondo here: https://github.com/didibus/anakondo/blob/16b0ba14d94a5d7e55655efc9e1d6d069a9306f2/anakondo.el#L320
Or clojure.core/filter for instance
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
☝️ that was just a test, but similar to what I want to do
Thanks for all the help and suggestions 🙏 😊 I have some paths to look into further.
It might end up as a clojure-dep instead as @teodorlu suggested over Tuple, just now 😄
what's Tuple?
It is the pair-programming video conference tool we use at work
It gives you (almost) full access to the others computer
Very handy within a team