Hey all, I recently upgraded both emacs lsp-mode and clojure-lsp-native, and I'm now receiving this message when opening edn files (other clojure files seem fine):
> LSP There are no language servers supporting current mode edn-mode' registered with lsp-mode'.
This is new behavior that I didn't see before upgrading. Any tips on where I should look to remedy this?
> oh I didn't know there is a edn-mode now, is this a new major mode? maybe @bozhidar know? I know, I know. 😄 It was requested a while back, and I finally got to doing it recently. Sorry for the late response!
oh I didn't know there is a edn-mode now, is this a new major mode? maybe @bozhidar know?
yeah, it was recently added I think
Ok, I will add to lsp-mode, one sec
https://github.com/clojure-emacs/clojure-mode/commit/cfb875ca3dc6de03a31a7780b109a7fc0e77f53c
https://github.com/emacs-lsp/lsp-mode/commit/3e55ca80712d66f2fc38bad514b5e2521751433d, just make sure you update to latest lsp-mode @jgdavey when available in melpa in hour or so
Oh, awesome. Thanks!
(cross-posted from the zulip) does anyone have experience writing a custom clojure lsp linter? I'm trying to follow the documentation here: https://clojure-lsp.io/settings/#custom-linters and getting stuck. I created the following .lsp/config.edn:
{ :classpath-config-paths ["typeytypetypetype/examples"]
:linters {:custom {typeytypetypetype.examples/example-linter {:level :info}}}}
as well as the following example linter file:
result of: cat clojure-lsp.exports/linters/typeytypetypetype/examples.clj
(ns typeytypetypetype.examples)
(defn example-linter [{:keys [db uris params reg-diagnostic!]}]
(reg-diagnostic! {:uri (first uris)
:level (:level params)
:code "my-org/missing-unit-test"
:message "Logic function missing unit test"
:source "my-org/codestyle"
:range {:row 1 :col 2 :end-row 3 :end-col 4}}))
I tried running
clojure-lsp diagnostics --verbose
but do not see any info printed, and it's unclear to me whether it's picking up my changes, or running anything related to my example linter.
I'm probably missing something obvious, but I've been fighting with it for a few hours, and I really struggled to understand the docsHey let me check!
@sam.t.straus I think the issue here is that the example.clj is not in the classpath of your project (I believe we can improve this explanation in the docs), but if you lein classpath or clj -Spath (if using deps.edn), you should see that file
usually, in projects people add that to the resources folder which is included in the classpath
does this go in the project root deps.edn, or inside of .lsp/config.edn?
the example.clj should go in something like:
resources/clojure-lsp.exports/linters/typeytypetypetype/examples.clj
and in your deps.edn you should have something similar to:
:paths ["src" "resources"]oh, I see -- let me try that
the point is, the clojure-lsp.exports should be in an folder that is considered a classpath
[INFO] :maintain-dep-graph 0ms
[ 99%] Project analyzed Finding diagnostics...
resources/clojure-lsp.exports/linters/typeytypetypetype/examples.clj:4:7: info: [clojure-lsp/unused-public-var] Unused public var 'typeytypetypetype.examples/example-linter'
resources/clojure-lsp.exports/linters/typeytypetypetype/examples.clj:4:31: warning: [unused-binding] unused binding db
src/typeytypetypetype/run_web_server.clj:2:51: warning: [unused-referred-var] #'compojure.core/POST is referred but never used
I still don't see the custom linter error (
"Logic function missing unit test"
)
in the output, although interestingly the examples.clj file is now getting linted when I call clojure-lsp diagnostics --verbose
is there any way to verify whether example-linter is registered/ever getting called?you can ignore that file linters or add #_{:clojure-lsp/ignore [:clojure-lsp/unused-public-var]} and append _ to db.
Hum, there should be some of https://github.com/clojure-lsp/clojure-lsp/blob/b16dda017000563a7de5ffc3184606c74ab6d031/lib/src/clojure_lsp/feature/diagnostics/custom.clj#L99-L124
managed to get this working after fixing the classpath issue, and then uninstalling and re-installing clojure-lsp.
i think what confused me was that i assumed that everything in the lsp setup was fully contained in the .lsp folder, so I assumed that classpath in the docs was a reference to the :classpath-config-paths config.edn option
thanks for your help! 🙂
hum maybe you had a old clojure-lsp version. Glad you have it working!