This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-30
Channels
- # aleph (2)
- # announcements (8)
- # babashka (12)
- # beginners (34)
- # calva (36)
- # cherry (3)
- # cider (1)
- # clj-kondo (11)
- # clj-otel (6)
- # cljdoc (31)
- # clojure (121)
- # clojure-conj (1)
- # clojure-czech (2)
- # clojure-europe (109)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (3)
- # cursive (3)
- # datahike (1)
- # datomic (9)
- # deps-new (6)
- # docker (5)
- # emacs (21)
- # fulcro (4)
- # hoplon (16)
- # introduce-yourself (2)
- # london-clojurians (5)
- # lsp (87)
- # malli (17)
- # missionary (1)
- # nbb (27)
- # off-topic (257)
- # pathom (4)
- # portal (42)
- # practicalli (1)
- # rdf (3)
- # releases (2)
- # shadow-cljs (49)
- # slack-help (3)
- # timbre (2)
I would like to use the analysis data produced by clj-kondo
. Is there a way to get this data from clojure-lsp
which is already started from Emacs? Perhaps configure clojure-lsp
so that it writes it into a file and keeps it updated? Or can I somehow connect to the clojure-lsp
process? Or should I run my own clj-kondo
` process with a file watcher separately?
@U2ERGD6UD Does this help? https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md
That is all the data that lsp itself uses, but lsp also does some processing on that and can export its own format using clojure-lsp dump
(WARNING: it's a lot of data)
I know, I can run clj-kondo
and get the data I need. But my project is big and it takes a while. And since Emacs already has started clojure-lsp
, I hoped I can reuse this instance so I don`t have to run it twice.
I don't really understand the internals of LSP protocol, but could it be used to get the analysis data in raw (EDN)?
I'll defer to @UKFSJSM38 but these details, but I don't think so at the moment
It's possible and easy to access that data via editor but clojure-lsp doesn't support dump via editor yet, but would be easy to add, would you mind creating a issue for that @U2ERGD6UD? We could offer a function to return that info via a custom request, but I'd like to understand how you want to use the info, if via a Elisp function(if using Emacs) or something else
Yeah, exactly, that's why I'd like to understand what you would do with that data, probably saving to a file would be a best option
Well, going through the editor seams not right. I want the data in Clojure. To generate charts/graphs in a Clerk notebook. So I have a running REPL where I would like to access the data.
You can't really link to the running clojure-lsp as if it's a graal image, a repl won't work
But for a running jvm clojure-lsp it's already possible via lsp-clojure-connect-nrepl-server that I use for debugging purposes
I think for your case may be a good idea use clojure-lsp JVM in your editor so you could do that
lsp-clojure-nrepl-connect (or something, can recall the exact name right now), will connect cider to the nrepl running in clojure-lsp of your editor
Then you can use the clojure-lsp.api to access functions that provide kondo analysis
@U2ERGD6UD check clj-kondo channel for LSP docs on how to running the most recent LSP + kondo + nREPL (typed this on phone)
It works too, but it doesn't need to be the most recent master to do that, https://clojure-lsp.io/installation/#embedded-jar-legacy-executable from lastest release is already enough
I could include lsp-clojure
as a dependency to my existing REPL with Clerk. And then start the lsp/kondo analysis via API. Correct?
@U2ERGD6UD Here is how you can start lsp along with any other deps in an nREPL server:
It looks like the functions in clojure-lsp.api
print the analysis data. Can I get to the data directly?
ok, so the analysis data is in the resulting value. can I dispable printing the output?
the docs are missing mention, but you can just pass :raw? true
and should not have any print, only the result
yeah, not sure would be possible to support :output nil as some commands didn't have the output, would cause a breaking change
and :output
is already a map on some commands, so would be weird I think to support :output :none
If shape of :output
can not be changed, perhaps a new option :no-output true
would be more clear.
output is already a map for some functions but not for others (which I intend to fix now), but if we introduce a :output :raw
as a keyword value, we would cause breaking changes for commands that didn't call :output
(because didn't exist)
@U2ERGD6UD would look weird for commands that already have :output
right?
But why have the :raw
there? The option does not change the output. It disables it. And the function result does not change. I find "raw" misleading. Should be "none" oder "disabled" or something...
yep, a legacy from clojure-lsp.main which uses internal-api as well, clojure-lsp --raw
, I agree we could have :output :something true
also maybe output is not a good place to specify whether should print to stdout or not :) output means the output of the function, if will use edn, json, canonical-paths etc, but not the stdout print
maybe :silent
or something which is really what raw was intended for since the beginning
Another idea: {:output {:target :std-out}}
as default with possibility of {:output {:target :none}}
but isn't the function return a target of a output as well 馃槀 ?
:output :quiet
? I'm out of ideas already..
Perhaps dump
should not print at all and just return a value. And then have a new start with dump!
Probably it's not the same case but cider-eval-last-sexp-and-replace
does the same magic.
@U1EP3BZ3Q I think borkdude is sharing about the inline symbol feature which allows you to remove a local or var and replace with its real code
an eval would get only the result and not really the entire code being used considering other vars and locals
yeah, repl is awesome, but if I can get some or most features without the need to connect and eval a huge project, I'm even happier
I always say that clj-kondo is there not to replace the REPL but to optimize the time you spend in the REPL, since you can spot issues early, you don't even have to bother to eval it
Using emacs, clojure-align
seems to be pretty slow for my coworker and me when lsp is enabled. A small file like this seems to take around 3.5 seconds to format:
{:paths ["src"]
:deps {dep1 {:local/root "path/to/dep1"}
example/depdency2 {:local/root "example/path/to/dep2"}
a/longer-dependency-name-for-format-example {:mvn/version "2.0.0"}}
:aliases {:test {:extra-paths ["test"]}}}
Scanning the code, I think this is because clojure-align
may make several recursive calls cljfmt
. Before digging deeper, I am just hoping to confirm that others are experiencing this issue and that we don't have anything misconfigured on our endsyes, I think this is a performance issue in cljfmt + a lot of calls that probably should not happen in clojure-align.
One thing that happens is that lsp-mode changes indent-region
via a variable to use lsp for format regions in clojure buffers, you can disable that and rely on lsp-format-buffer
or region manually which is what most people do
https://github.com/emacs-lsp/lsp-mode/blob/781889628b9e0504fde279371548149deae4849d/lsp-mode.el#L4094 that does that
cool, that is what I noticed. There may be some low hanging fruit in the clojure-align
function that may reduce the number of necessary calls to indent-region
thanks for confirming!
just FYI, looks like there may be a solution that would move this to a single cljfmt call: [align associative (Attempt to solve issue #36) by reutsharabani 路 Pull Request #299 路 weavejester/cljfmt](https://github.com/weavejester/cljfmt/pull/299)
ah yea, I'm following that issue 馃槢 really looking forward to have align associative in cljfmt, it's the only big feature I miss from cljfmt
last thing would be column limit, which I think would probably end the split-braining between cljfmt and zprint