This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-15
Channels
- # announcements (51)
- # beginners (65)
- # calva (44)
- # cider (6)
- # clara (3)
- # clj-kondo (30)
- # cljsrn (5)
- # clojure (63)
- # clojure-australia (7)
- # clojure-dev (7)
- # clojure-europe (43)
- # clojure-gamedev (1)
- # clojure-nl (6)
- # clojure-uk (7)
- # clojurescript (51)
- # conjure (1)
- # cursive (9)
- # datascript (16)
- # datomic (14)
- # depstar (20)
- # events (1)
- # exercism (17)
- # figwheel-main (6)
- # fulcro (9)
- # graphql (3)
- # gratitude (2)
- # honeysql (4)
- # jobs (7)
- # leiningen (3)
- # lsp (107)
- # meander (7)
- # minecraft (3)
- # off-topic (16)
- # other-languages (4)
- # pathom (4)
- # pedestal (26)
- # practicalli (4)
- # re-frame (3)
- # reitit (7)
- # remote-jobs (1)
- # shadow-cljs (26)
- # tools-deps (67)
- # vim (19)
- # vscode (1)
Hi all, here is the recording of last night's event in case you missed it: Turning your editor into a Clojure IDE with clojure-lsp (by Eric Dallo) https://www.youtube.com/watch?v=grL3DQyvneI Many thanks to @ericdallo for the great presentation and for clojure-lsp

Disclaimer: I know almost nothing about LSP and haven't used clojure-lsp yet. What I'd like to try is to write very minimal language server and integrate it with emacs - like a "hello world" example. The broader idea is that for any file I open in my project I can fetch some interesting data from a 3rd party server and present it to the user. But initially I just want to understand how all the pieces fit together and show a simple "Hello" message in the client/emacs UI. What is a best example online that could get me started? Any good documentation?
@jumar I wrote a hello world LSP server recently here: https://github.com/zen-lang/zen-lsp It supports linting a custom language defined in EDN.
It's based on the clj-kondo lsp server which only provides diagnostics, no other lsp features
The easiest way to test this is really VSCode I think. I'm writing the server in emacs, but testing it in VSCode
including cider-nrepl during development so you see live updates made while developing in vscode
You know what might be nice, that when a missing require (or import) is added by LSP, to add it and then sort the require/imports (for at the moment, it adds missing items to the end each time). Do you think that might be a nice addition?
90% of the time clojure-lsp sorts according to how we like it, but not all of the time. Especially relating to long lists of imported classes or long lists of refers. If this is enabled, please have a way to disable it
@U11BV7MTK Can you elaborate an example on how the sort doesn't makes sense?
yeah the easiest way for me to check this would be to run the command line option to sort the ns's. do you know that offhand?
oh nice. there's a --dry
option. Although it seems that the command line doesn't use the existing cache? i'm at 54,000 ms analyzing the project
it should use the cache @U11BV7MTK
[email protected] metabase % clojure-lsp --dry clean-ns
Analyzing project... 144150ms
Checking namespaces...
[email protected] metabase % clojure-lsp clean-ns --dry
Analyzing project... 151930ms
Checking namespaces...
the --dry clean-ns
did not report a diff, now trying clean-ns --dry
to see if that makes it report a diff. But it again seems to not have used the cachebut no diff came from it, nor any files changed. now just running without --dry
and i'll just discard any diffs it changes
- [metabase.models :refer [Card Collection Dashboard DashboardCard Database Field Metric NativeQuerySnippet
- Pulse Segment Table User]]
+ [metabase.models :refer [Card Collection Dashboard DashboardCard Database Field Metric NativeQuerySnippet Pulse Segment Table User]]
yeah. also removed a comment
- [metabase.query-processor-test.order-by-test :as qp-test.order-by-test] ; used for one SSL connectivity test
+ [metabase.query-processor-test.order-by-test :as qp-test.order-by-test]
java.util.concurrent.TimeUnit
+ org.apache.sshd.client.SshClient
org.apache.sshd.client.future.ConnectFuture
org.apache.sshd.client.session.ClientSession
org.apache.sshd.client.session.forward.PortForwardingTracker
- org.apache.sshd.client.SshClient
here it sorted the capital S before lowercase fhere it sorted refers capital S
before lowercase d
[medley.core :as m]
- [metabase.models.setting :as setting :refer [defsetting Setting]]
+ [metabase.models.setting :as setting :refer [Setting defsetting]]
(as an addition, I noticed too, that if I have something like #_{:clj-kondo/ignore.....}
against a require/import and I sort it, that gets removed too)
It seems valid, Please open an issue with those details @U11BV7MTK so I can investigate later
Thank you for the detailed issues @U11BV7MTK I'll try to take a look soon!
I've noticed .lsp/.cache/sqlite.db
rather than .lsp/sqlite.db
in a couple of projects -- is that a recent change in LSP?
Yes! It was changed on latest release: https://clojurians.slack.com/archives/CPABC1H61/p1631563489180000
this was something bad for gitignores but the ideia is to move the db impl to a .cache folder
and when we change the db impl in the future, this will cause no more issues for users
OK, I'll update the various gitignore templates in clj-new and deps-new then.
clojure-lsp has already a logic to auto move the .lsp/sqlite.db
to .lsp/.cache/sqlite.db
thank you @U04V70XH6!
@U04V70XH6 if you update those templates, do you also include .clj-kondo/.cache
?
@U04V15CAJ https://github.com/seancorfield/clj-new/blob/develop/src/clj/new/lib/gitignore
Hey @ericdallo thanks again for pointing me towards getting start with lsp-clojure. It's amazing! I don't know everything I can with it though and can't find a list of commands and docs on the docs site. Could your, or anyone, share where I could find this info? FYI I'm also new to lsp in general in emacs so I might be missing something obvious.
Alright, this tutorial should certainly help you: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/
but since you use doom you can find probably most of commands with SPC c
witch will prompt all the commands for the code
section
AFAIK the evil keybindings are g D
for example, the one I told was the doom-emacs one that is available for both users :thinking_face:
anyway, you can probably check that with: M-x
and then type lsp-
, this will show all available commands and the keybindings if any for those commands :)
this is my doom config: https://github.com/ericdallo/dotfiles/tree/master/.doom.d
Their are just a ton of commands so I didn't see key bindings next to them. Now when I scroll down I do
Ok, I'm rolling now and my mind is blown. Execute code action was what I was really missing.
I start with clj-kondo and had to specify a couple of my helix helpers should be used like defn, do I move that to .lsp?
there is this code action as well: https://clojure-lsp.io/features/#resolve-macro-as
With clj-kondo I have
:lint-as {mxv.client.react/defrc clojure.core/defn
helix.hooks/use-callback clj-kondo.lint-as/def-catch-all
helix.hooks/use-memo clj-kondo.lint-as/def-catch-all}
that code action will just add the configuration to the lint-as as you pasted above
some things to confirm:
⢠make sure you have latest clojure-lsp
⢠remove .lsp/.cache
and restart the server with lsp-workspace-restart
if you changed the clj-kondo config after started
Is there a way (or discussion about) for libs to share their kondo settings? A lot of the new and active repos/libs I see have their own but it would be so nice to be able to auto import or merge into a project using them
it's possible to configure the clj-kondo config on the lib itself, making it easy for users of that lib
this is an example: https://github.com/nubank/state-flow/tree/master/resources/clj-kondo.exports/nubank/state-flow
so users just need to add to their clj-kondo config something like :
{:config-paths ["nubank/state-flow"]}
OR a badge/link or something even on readme signifying it's clj-kondo compliant and available to import the config
I added helix to that, I'm gonna try and remove my custom config for that and import to make sure I'm getting the setup
I just noticed that lsp automatically dumped the rewrite-clj config in my .clj-kondo dir :) Since I'm not using that in nbb, I simply added it to the .gitignore
awesome! I have on my backlog, down there, to open an PR on https://github.com/plumatic/plumbing š for fnk macro and probably others
@ericdallo last ? of the day and then I'll stop spaming the chanel š I was seeing usages next to defn symbol names but now I don't... Is that something I need to activate somehow?