This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-08
Channels
- # announcements (8)
- # aws (2)
- # babashka (11)
- # babashka-sci-dev (39)
- # beginners (62)
- # calva (5)
- # cider (1)
- # clj-kondo (50)
- # cljdoc (2)
- # cljs-dev (6)
- # clojure (52)
- # clojure-austin (22)
- # clojure-czech (13)
- # clojure-europe (88)
- # clojure-nl (1)
- # clojure-norway (5)
- # clojure-uk (6)
- # clojuredesign-podcast (13)
- # clojurescript (45)
- # community-development (3)
- # core-typed (31)
- # cursive (12)
- # datahike (2)
- # datalevin (7)
- # datomic (5)
- # events (1)
- # exercism (11)
- # fulcro (27)
- # gratitude (1)
- # holy-lambda (3)
- # hoplon (2)
- # introduce-yourself (2)
- # jobs (1)
- # lambdaisland (3)
- # lsp (110)
- # malli (2)
- # meander (4)
- # music (2)
- # off-topic (50)
- # overtone (1)
- # pathom (13)
- # polylith (26)
- # re-frame (4)
- # releases (2)
- # rewrite-clj (3)
- # ring (12)
- # shadow-cljs (20)
- # specter (4)
- # tools-deps (8)
- # xtdb (40)
is there any way to access / navigate the sideline code actions without using the mouse?
yep, I abandoned lsp-ui at all, the modeline from lsp-mode is quite enough and lsp-execute-code-action
shows the actions quickly, you can filter with vertico/consult easily
https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/ Check modeline code actions
how far does clojure-lsp goes into derivation of semantics of a Clojure program?
i.e., what semantics does it derive?
known so far: • ns def and var def with positions, https://github.com/clojure-lsp/clojure-lsp/blob/87ec9773b63e884304499fa592c0c8c858a79490/common-test/src/clojure_lsp/test_helper.clj#L153 • outgoing/ingoing file references, https://github.com/clojure-lsp/clojure-lsp/blob/87ec9773b63e884304499fa592c0c8c858a79490/lib/src/clojure_lsp/feature/file_management.clj#L91 • https://github.com/clojure-lsp/clojure-lsp/blob/87ec9773b63e884304499fa592c0c8c858a79490/lib/src/clojure_lsp/feature/call_hierarchy.clj#L70, https://github.com/clojure-lsp/clojure-lsp/blob/87ec9773b63e884304499fa592c0c8c858a79490/lib/src/clojure_lsp/feature/call_hierarchy.clj#L78
I'm asking because I'm trying to get semantic representation of a Clojure program (deps included). I.e., read(program-folder) => program-as-data
@U0ZQT0K2N not sure you are aware, but I want to implement a tool for that soon on clojure-lsp, check this https://github.com/clojure-lsp/clojure-lsp/issues/744 I think it's related to what you want?
but basically clojure-lsp relies entirely on clj-kondo analysis, so everything there should be available from clojure-lsp
that tool would be handy for communicating knowledge
I am wondering what knowledge clojure-lsp has to offer. it relies and builds on top clj-kondo, as you mention. that 'on top' includes integration with LSP, but perhaps clojure-lsp derives some more knowledge as well?
other source of knowledge for clojure-lsp seems to be rewrite-clj, as clojure-lsp is being mentioned on rewrite-clj's page as adopters. but I'm not sure I've seen so far any knowledge from rewrite-clj being used in clojure-lsp, is there?
ah, so it's being used to manage the source of clojure-lsp, but is not used by it internally, right?
ah, I see. thank you for explaining.
btw, what's the difference between stuff under features
and feature
?
I went through features
, feature
stuff is on the list
Hello! Should there be any difference in performance, comparing clojure-lsp format
to cljfmt
? I'm assuming they should be about the same.
I'm testing it out though, and cljfmt is much faster on my machine. I'm hoping lsp is just checking more files, so it's a configuration issue. Figured it's just easier to ask though 🙂
yeah, cljfmt is a little bit faster because it just scan the folders you pass, clojure-lsp finds that automatically via classpath and have a more robust mechanism for format configuration (available on classpath jars too)
so if you want to use only format, you can choose cljfmt, but if you want to use more clojure-lsp features like clean-ns
and diagnostics
for example, at nubank we have a common codestyle
project with all lint and format configs, so all projects just use that jar and have everything in a standard
Thanks for the quick reply. We already used cljfmt
, but we also want to use clean-ns
, so I figured it would also be nice to use the format
command. The configuration of clojure-lsp is nice. I put a test together really quickly, and the result was that clojure-lsp
was 4x slower. I think it was just a poor test 😄
Since I have your attention, what is the difference between diagnostics
and just calling clj-kondo
? clj-kondo was much faster for us, probably because of its --parallel
option.
diagnostics
will bring kondo analysis + clojure-lsp/unused-public-var
clojure-lsp usually is slower the first time when it caches the external analysis, the next times it scan project only to know all analysis + namespaces
ah, never mind. Found it from the documentation. clojure-lsp has custom linters, which by default include clojure-lsp/unused-public-var
if you use lein-clojure-lsp, it will analysze one time only, so you can format
clean-ns
diagnostic
That's nice, but we don't use lein 🙂
we replaced all cljfmt/clj-kondo/nsorg etc at nubank by clojure-lsp because even if it's a little bit slower, it has consistency, config standards for hundreds of projects, and it's a single tool for everything
Sorry for barraging you with questions, but is it possible to tell format
with paths to format? Would be nice to only format files that have changed (e.g. a pre-commit hook).
yes, we should have docs about that, but check this issue: https://github.com/clojure-lsp/clojure-lsp/issues/775#issuecomment-1046072006
@UKFSJSM38 I wonder what kind of style config you end up having (mentioned codestyle
), should be of a high grade. Is it open-sourced somewhere?
nope it's a nubank internal project as it contains macros and functions from other projects, but I can share its core idea:
Basically, it's a lein project with no clojure code, witch exports only a resources
folder like this:
resources/clojure-lsp.exports/nubank/codestyle/config.edn
{:clean {:ns-inner-blocks-indentation :same-line}
:classpath-config-paths ["nubank/lib-a"
"nubank/lib-b"]
:use-metadata-for-privacy? true
:auto-add-ns-to-new-files? true
:cljfmt {:indents {assoc-if [[:block 1]]
assoc-in-if [[:block 1]]
assoc-some [[:block 1]]
assoc-in-some [[:block 1]]
constraint-fn [[:block 2]]
consume! [[:block 0]]
data-fn [[:block 1]]
defhandler [[:block 2]]
defint [[:block 0]]
defuf [[:block 1]]
,,,}}}
resources/clj-kondo.exports/nubank/codestyle/config.edn
{:skip-comments true
:config-paths ["../common-a"
"../state-flow"
"../common-b"
"../common-c"
"../../marick/midje"]
:hooks {:analyze-call {foo/a foo/b}}
:lint-as {clojure.test.check.clojure-test/defspec clj-kondo.lint-as/def-catch-all
clojure.test.check.properties/for-all clojure.core/let
schema.test/deftest clojure.test/deftest}
:linters {:deprecated-var {:level :info}
:refer-all {:exclude [midje.sweet
matcher-combinators.test
clojure.test.check.clojure-test
clojure.test]}
:clojure-lsp/unused-public-var {:exclude-regex [".+\\.server/run-dev"
".+\\.server/servlet-init"
".+\\.server/servlet-destroy"
".+\\.server/servlet-service"
".+\\.components/start-sachem-system!"
".+\\.components/ensure-system-up!"]}}}
This makes clojure-lsp and clj-kondo find those configs of any project using this jar, having the need of only this config on each project:
.clj-kondo/config.edn
{:config-paths ["nubank/codestyle"]}
.lsp/config.edn
{:classpath-config-paths ["nubank/codestyle"]}
BTW, @U04V15CAJ may be interested on knowing we do that, this is shared across hundreds of services :)
That's cool! Thanks for sharing. ❤️ 🙂
Hi,
I am hitting something similar to what @pesterhazy was reporting: I have trouble getting clojure-lsp to work with emacs beyond 2022.01-22-01.31.09
. Later releases do not report linting failures at all (so it's more widespread than what @pesterhazy was mentioning, I just don't get any kondo warnings notices)
Could you please check https://clojure-lsp.io/troubleshooting/
I also saw this when doing a video with @U02KYBC5WJY in Calva. I advised him to install the clj-kondo extension separately, since we could not figure it out with lsp only.
As a workaround you can use flycheck-clj-kondo
and disable the linter in clojure-lsp.
Keep in mind, flycheck-clj-kondo
will offer only clj-kondo features, not refactors, lens and clojure-lsp features
I don't see why one would like to use kondo separated if not using a edge kondo or something @U04V15CAJ
@UKFSJSM38 I agree, but as I said, we could not figure it out. There were no .lsp config files anywhere. So we went with a workaround.
yeah: https://gist.github.com/pyr/0c0954698f91f351648c12ee0b80881f#file-lsp-output-edn-L35
it might be related to the fact that to debug all this I removed all other packages (and thus have no projectile anymore)
@UKFSJSM38 well, in Daniel's case, navigation worked, so I think lsp was doing something
Calva uses nrepl navigation as fallback @U04V15CAJ
I saw this behavior that kondo lint configs were not working on recent versions if you have wrong project-root
probably a regression we introduced that just a side effect of a wrong project config
I'll take a look at that later, but you should fix the project root anyway doing https://clojurians.slack.com/archives/CPABC1H61/p1649429398486999?thread_ts=1649429139.776189&cid=CPABC1H61
yeah, that regression probably make you the need to fix the root, is not ideal, but you would probably have lots of other issues if not fixing the project root, including performance issues
OK, with the root fixed, I get linting through clojure-lsp. Thanks for the help with debugging!
we could make lsp-mode double confirm when root is /home
/home/your-user
/Users/your-user
@UKFSJSM38 you mentioned graal doesn't have JAVA_HOME
is it all env vars? if not, HOME
might be all that's needed to check.
yeah, I was thinking about checking HOME
indeed as JAVA_HOME
is not present and even if it s present points to the Java installation dir, not the user home, right?
oh, sorry, I was wondering if graal has access to any env vars, if it does HOME
would be nice
yes, it has the same access to env vars normally, what is doesn't have is the jvm properties, like (System/getProperty "java.home")
Another corollary behavior is that clojure-lsp hangs buffers when they are being opened, which seems to be related to it wanting to consider my home directory as any project's root
Wondering if this is a known issue or not:
Working with schema and want to validate a schema in the repl. I type s/val
and ask for autocompletions. The first is s/valid?
which sounds right and I select it, but that is from spec and brings in spec :as s when I already have schema :as s and only want those completions. Has this behavior been noted before?
Probably not, also we changed recently some logic regarding that so it could be a regression too
When you have a alias already required, we should not suggest other ns requires for that alias
I've also noticed in completions, that if I have :as log
already required, log/spy
completion is still coming in with additional-text-edits
yeah i’ve had log
from clojure.tools.logging in a ns and using completions (even for log/warn
from c.t.logging will bring in some util logging ns we have
@U11BV7MTK it should be fixed on master, could you try a #clojure-lsp-builds in a couple of minutes?