Fork me on GitHub
#emacs
<
2022-03-23
>
genmeblog10:03:20

How to explicitly select clj-kondo as a backend for flycheck in lsp-mode? looks like lsp-mode brings own checker which reports nothing and this checker is set by default...

borkdude10:03:49

@U1EP3BZ3Q As I'm developing clj-kondo I always use my own clj-kondo version together with clojure-lsp. To do this, you have to disable diagnostics in ls-mode

borkdude10:03:17

lsp-diagnostics-provider :none

bananadance 2
genmeblog10:03:28

still it doesn't work...

genmeblog10:03:31

;; clojure

(use-package flycheck)
(use-package flycheck-clj-kondo)
(use-package clojure-mode
  :config (require 'flycheck-clj-kondo))
(use-package cider
  :custom ((cider-eldoc-display-context-dependent-info t)
	   (cider-repl-pop-to-buffer-on-connect 'display-only)
	   (cider-overlays-use-font-lock t)
	   (cider-repl-buffer-size-limit 60000)))
(use-package clj-refactor)
(use-package clojure-mode-extra-font-locking)
(use-package sayid)
(use-package cljr-ivy)
(use-package clojure-snippets)
(use-package clj-decompiler)

;; lsp

(use-package lsp-mode
  :hook ((clojure-mode . lsp))
  :custom ((lsp-lens-enable t)
	   (lsp-enable-indentation nil)
           (lsp-diagnostics-package :none)
           (lsp-clojure-custom-server-command '("/usr/local/bin/clojure-lsp")))
  :config (dolist (m '(clojure-mode
		       clojurec-mode
		       clojurescript-mode
		       clojurex-mode))
	    (add-to-list 'lsp-language-id-configuration `(,m . "clojure"))))

(use-package lsp-ui :commands lsp-ui-mode)
(use-package lsp-treemacs)
(use-package lsp-ivy)

genmeblog10:03:46

ah wait... provider!

genmeblog10:03:11

@U04V15CAJ thanks a lot! I was setting wrong variable 😕 Now it works.

🎉 2
ericdallo16:03:09

> brings own checker which reports nothing and this checker is set by default... FYI: lsp-mode checker uses server diagnostics, which if you are using clojure-lsp uses clj-kondo under the hood anyway with extrac checks like unused-public-var , so if you are not developing clj-kondo or similar and it's using lsp-mode already with clojure-lsp I suggest stick to lsp's diagnostics

genmeblog18:03:16

@UKFSJSM38 thanks, I know that clj-kondo is used under the hood. However it seems to skip some test (like unused fn args for example) which are important for me.

ericdallo18:03:18

not really, this is all delegated to clj-kondo, we have all features clj-kondo has

ericdallo18:03:35

maybe something with your config?

genmeblog18:03:16

Hmmm... Possibly. I posted Clojure part of confif at the beginning of this thread. Will take a look at this again...

genmeblog08:03:41

It was definitely something wrong with my config. Now it works. Thanks.

Carlo16:03:49

I started getting the weirdest error, and I'm not sure how to debug it. If I start a repl in a very barebone project, (one file with no definitions, and the deps.edn file is just {}, I get:

nREPL server started on port 42689 on host localhost - 
;; Connected to nREPL server - 
;; CIDER 1.2.0snapshot, nREPL 0.9.0-beta3
;; Clojure 1.10.3, Java 11.0.12
;;     Docs: (doc function-name)
;;           (find-doc part-of-name)
;;   Source: (source function-name)
;;  Javadoc: (javadoc java-object-or-class)
;;     Exit: <C-c C-q>
;;  Results: Stored in vars *1, *2, *3, an exception in *e;
;;  Startup: /run/current-system/sw/bin/clojure -J-Dghostwheel.enabled=true -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta3"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-alpha13"} cider/cider-nrepl {:mvn/version "0.27.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
Execution error (NullPointerException) at user/eval6938 (REPL:11).
null
I wasn't having this problem yesterday, and I'm unsure about what changed

dpsutton16:03:23

i’m guessing something in your user file changed

dpsutton16:03:13

but just run `/run/current-system/sw/bin/clojure -J-Dghostwheel.enabled=true from a terminal and see if you can recreate. then try the whole form /run/current-system/sw/bin/clojure -J-Dghostwheel.enabled=true -Sdeps ‘{:deps {nrepl/nrepl {:mvn/version “0.9.0-beta3”} refactor-nrepl/refactor-nrepl {:mvn/version “3.0.0-alpha13"} cider/cider-nrepl {:mvn/version “0.27.2”}} :aliases {:cider/nrepl {:main-opts [“-m” “nrepl.cmdline” “--middleware” “[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]“]}}}’ -M:cider/nrepl`

Carlo16:03:02

where's the user file? The first invocation gives me a repl, the second one:

$ /run/current-system/sw/bin/clojure -J-Dghostwheel.enabled=true -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.9.0-beta3"} refactor-nrepl/refactor-nrepl {:mvn/version "3.0.0-alpha13"} cider/cider-nrepl {:mvn/version "0.27.2"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
nREPL server started on port 45425 on host localhost - 
and then no more output

dpsutton16:03:57

the file user.clj

dpsutton16:03:04

somewhere on your classpath possibly

dpsutton16:03:14

ok so it starts up successfully from the terminal

dpsutton16:03:51

another thing to try is to m-x nrepl-toggle-message-logging and see what messages are being sent and see if you can identify which form is causing an error

Carlo17:03:24

And if I do that in the *nrepl-messages file I get:

(-->
  id         "1"
  op         "clone"
  time-stamp "2022-03-23 18:07:47.853539798"
)
(<--
  id          "1"
  session     "3a6296e1-8dc9-4953-830c-f7096037a642"
  time-stamp  "2022-03-23 18:07:47.867360287"
  new-session "3f8edff6-2be6-4805-88e4-861d35f0e780"
  status      ("done")
)
(-->
  id         "2"
  op         "clone"
  time-stamp "2022-03-23 18:07:47.887012884"
)
(<--
  id          "2"
  session     "b288116f-d426-41c8-a1d1-0f934195b7ab"
  time-stamp  "2022-03-23 18:07:47.888980355"
  new-session "da2c4d47-e11b-4b6b-bb19-5c56effce8ec"
  status      ("done")
)
(-->
  id         "3"
  op         "describe"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:47.907917218"
)
(<--
  id         "3"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:47.915637077"
  aux        (dict ...)
  ops        (dict ...)
  status     ("done")
  versions   (dict ...)
)
(-->
  id                                 "4"
  op                                 "eval"
  session                            "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                         "2022-03-23 18:07:47.949186858"
  code                               "(let [__value (clojure.core/apply clojure.core/require cloju..."
  column                             1
  file                               "*cider-repl clojure/malliOmg:localhost:39249(clj)*"
  inhibit-cider-middleware           "true"
  line                               11
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
)
(<--
  id         "4"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:48.060764262"
  err        "Execution error (NullPointerException) at user/eval6938 (REP..."
)
(<--
  id         "4"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:48.102727695"
  ex         "class java.lang.NullPointerException"
  root-ex    "class java.lang.NullPointerException"
  status     ("eval-error")
)
(-->
  id                                 "5"
  op                                 "stacktrace"
  session                            "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                         "2022-03-23 18:07:48.104261194"
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
)
(<--
  id         "4"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:48.105132252"
  status     ("done")
)
(-->
  id         "6"
  op         "out-subscribe"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:48.106093896"
)
(-->
  id                                 "7"
  op                                 "init-debugger"
  session                            "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                         "2022-03-23 18:07:48.107134403"
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
)
(-->
  id                           "8"
  op                           "version"
  session                      "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                   "2022-03-23 18:07:48.117185766"
  debug                        "false"
  insert-newline-after-require "true"
  prefix-rewriting             "false"
)
(<--
  id         "8"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:48.123624126"
  status     ("done")
  version    "3.0.0-alpha13"
)
(-->
  id                           "9"
  op                           "version"
  session                      "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                   "2022-03-23 18:07:48.138939798"
  debug                        "false"
  insert-newline-after-require "true"
  prefix-rewriting             "false"
)
(<--
  id         "9"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:48.143182456"
  status     ("done")
  version    "3.0.0-alpha13"
)
(-->
  id                           "10"
  op                           "artifact-list"
  session                      "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                   "2022-03-23 18:07:48.160728478"
  debug                        "false"
  force                        "false"
  insert-newline-after-require "true"
  prefix-rewriting             "false"
)
(-->
  id                           "11"
  op                           "warm-ast-cache"
  session                      "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp                   "2022-03-23 18:07:48.162174268"
  debug                        "false"
  ignore-paths                 nil
  insert-newline-after-require "true"
  prefix-rewriting             "false"
)
(<--
  id         "10"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:49.417052327"
  artifacts  ("side-fx" ...)
  status     ("done")
)
(<--
  id            "6"
  session       "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp    "2022-03-23 18:07:49.969334107"
  out-subscribe "3f8edff6-2be6-4805-88e4-861d35f0e780"
  status        ("done")
)
(<--
  id           "11"
  session      "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp   "2022-03-23 18:07:51.459600573"
  ast-statuses "()"
  status       ("done")
)
(<--
  id         "5"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:53.869526756"
  class      "java.lang.NullPointerException"
  message    nil
  stacktrace ((dict "class" "clojure.core$with_meta__5437" "file" "core.clj" "file-url" "jar:file:/home/carlo/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj" "flags" ("clj") "fn" "with-meta" "line" 220 "method" "invokeStatic" "name" "clojure.core$with_meta__5437/invokeStatic" "ns" "clojure.core" "type" "clj" "var" "clojure.core/with-meta") ...)
)
(<--
  id         "5"
  session    "3f8edff6-2be6-4805-88e4-861d35f0e780"
  time-stamp "2022-03-23 18:07:53.870304907"
  status     ("done")
)

Carlo17:03:33

I think this could be the culprit:

stacktrace ((dict "class" "clojure.core$with_meta__5437" "file" "core.clj" "file-url" "jar:file:/home/carlo/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar!/clojure/core.clj" "flags" ("clj") "fn" "with-meta" "line" 220 "method" "invokeStatic" "name" "clojure.core$with_meta__5437/invokeStatic" "ns" "clojure.core" "type" "clj" "var" "clojure.core/with-meta") ...)

dpsutton17:03:34

i think it was blowing up on `(let [value (clojure.core/apply clojure.core/require cloju...” `

🙌 1
😍 1
Carlo17:03:01

where is that? (I know that I have written some code that looks like that in my emacs config

Carlo17:03:11

but where do you see it in the trace?

dpsutton17:03:42

message 4. and then an error

Carlo17:03:59

ok I understand what's the problem here; in my emacs config, I wrote:

(after! cider-mode
  (defun cider-tap (&rest r)
    (cons (concat "(let [__value "
                  (caar r)
                  "] (tap> (with-meta __value {:portal.viewer/default :portal.viewer/pprint}))
                     __value)")
          (cdar r)))

  (advice-add 'cider-nrepl-request:eval
              :filter-args #'cider-tap))
it turns out that I can't do the with-meta wrapping, but I wish I understood why

Carlo17:03:46

basically I was trying to wrap every message that passes through tap> with some metadata (to set the portal viewer), but maybe some values can't accept metadata and they blow up?

dpsutton17:03:41

caar isn’t a valid function name

dpsutton17:03:48

and cdar what are those?

dpsutton17:03:24

ah i missed how they were interspersed in the string there

dpsutton17:03:48

well, that’s your problem. i’m not sure what you’re trying to accomplish but the error is in your code

🙌 1
Carlo17:03:36

sure, thank you, I think my original problem is solved, I'll confirm as I finish upgrading emacs. I'll ask if there's some construct that can't get metadata in another channel! ☺️

dpsutton17:03:34

anything that doesn’t implement IObj i believe

dpsutton17:03:42

so lots of java things. numbers, strings, etc

dpsutton17:03:49

its not universally applicable

dpsutton17:03:23

i’d probably turn that into something like (doto value portal/view) or something like that