This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (1)
- # babashka (118)
- # beginners (108)
- # calva (20)
- # chlorine (3)
- # clara (10)
- # clj-kondo (47)
- # cljsrn (10)
- # clojure (144)
- # clojure-australia (5)
- # clojure-czech (2)
- # clojure-dev (11)
- # clojure-europe (94)
- # clojure-france (4)
- # clojure-nl (5)
- # clojure-spec (3)
- # clojure-sweden (2)
- # clojure-uk (11)
- # clojuredesign-podcast (5)
- # clojurescript (56)
- # cloverage (1)
- # code-reviews (6)
- # conjure (1)
- # cursive (13)
- # datascript (1)
- # datomic (16)
- # defnpodcast (1)
- # emacs (1)
- # etaoin (1)
- # events (7)
- # fulcro (21)
- # graalvm (3)
- # helix (17)
- # jackdaw (3)
- # jobs-discuss (2)
- # lambdaisland (2)
- # london-clojurians (2)
- # meander (2)
- # mid-cities-meetup (2)
- # midje (1)
- # off-topic (1)
- # pathom (3)
- # pedestal (12)
- # reagent (7)
- # reitit (15)
- # reveal (12)
- # shadow-cljs (6)
- # sql (14)
- # test-check (3)
- # vim (13)
Has anyone used the clj-kondo analysis output to implement jump to definition in emacs?
I have jump-to-definition on my to-do. That and eldoc are my next two, but I got kind of stuck with trying to make the analysis async so it doesn't freeze emacs first time you open a file from a project 😝 and that was a lot of work, so then I chocked and I put the whole thing on back burner haha. Thinking of getting back into it soon
Could you piggieback on the data produced during the linting run @? I figure the .clj-kondo cache directory ought to have all sorts of useful data that I just don’t have an interface into.
Yup, clj-kondo analysis data has everything I'd need. The row/col location of each var in each file and their name and doc is all there
Is there a way to configure it to just re-use the cache I already have? It's not a huge deal, but it'd be a bit nicer to only actually compute that data once
anakondo uses its own cache. the format in .clj-kondo/.cache is an implementation detail which is not supposed to be used by other tools since it can change (it doesn't change often, but it could happen)
That makes sense, it'd be nice if there was a canonical database of analysis data that other tools could hook into.
But it's likely that when you use anakondo to build up its cache, clj-kondo's cache will be populated as a side effect as well
I can also say that in practice, I've not seen any performance impact even on a 10 year old laptop that can't even run Google Chrome without crashing. The biggest issue for me right now is the initial time to analyse a project, and the fact that it blocks Emacs while doing that initial analysis. Most of the time there is taken by the Java analysis, not clj-kondo, so even then I don't think from clj-kondo's perspective its that big a problem for now.
Also, syncing Emacs with a file based cache wouldn't be that simple, probably requiring its own cache for it 😛
What I have wondered though is more, if I decide to save my own cache to a file, so on Emacs restart you don't need to re-analyse the project, if I should re-use the clj-kondo's folder, or have my own folder, or store it within Emacs's own folder, etc.
I guess I was thinking more in terms of a database with an API that tools can be written against. I'd like to be able to query for code construvts with datalog or SQL, for example.
Anyways, my grand vision for programming is more smalltalk-image shaped and less file shaped
totally possible to make a tool which puts clj-kondo's data into a SQL db: https://github.com/borkdude/babashka/blob/master/examples/hsqldb_unused_vars.clj
The downsides of that is for an Emacs editing environment you now have to manage long lived subprocesses and that comes with its own issues.
I haven't tested the feasibility of this, but you can try out the example in your own machine to see how it performs
Hum... like if I didn't maintain a cache? It means clj-kondo would need to re-analyse all files every edit and re-initialize hsqldb and insert all vars and then run the query.
this is just an example of how to use hsqldb. I mean: you could maintain your own cache in a hsqldb
If I maintain my cache in a DB, that's a seperate process that Emacs as to start and manage
yeah. you can use it with babashka to create ad hoc databases on your file system, just like sqlite
Ok, that's interesting then, I'll think about it. Could make my code easier, querying data-structures in Emacs is alright but that would make it much nicer
so, the support for hsqldb from within babashka comes from here: https://github.com/babashka/babashka-sql-pods/
There's the downside of having users need to install one more binary, but I guess they are already expected to install clj-kondo
That's for sure. Of course you could also make your own anakondo binary with GraalVM and use clj-kondo from there.
Postgres and HSQLDB (embedded) are the only databases I've gotten to work with GraalVM
Hum, ya that could be an option as well. I'll hammock on it all. Though at this point I wouldn't really see myself making a major refactor of that sort unless it really helped me down the road. But I like the ideas.
My ideal would be a standardized “database” of analysis information that could be populated by tools like clj-kondo and cider and used by various editor plugins as well as by ad-hoc user queries
Of course, as someone who isn’t writing code (and doesn’t have time to) I'm grateful for the work y'all do
@fiddlerwoaroof this branch uses a much more recent clj-kondo fwiw: https://github.com/sogaiu/alc.index-defs/tree/update-clj-kondo