@nick.romer maybe leaving some notes in the clj-kondo repo might be nice if you think it’s valuable for others
Of course. Do you mean a PR to the editor-integration.md?
@nick.romer the syntax-checking
layer provides the indicators in the fringe showing which lines have warnings, issues.
@jr0cket I did uncomment syntax-checking. BTW in my screenshot you see a red line which imo comes from the syntax-checking layer. Can the fringe be activated separately?
Oh, you don't have a fringe? It's there by default, so not sure how it's turned off/on
@jr0cket... or is the fringe activated based on the screen size?
I am guessing there is a toggle, under SPC T
somewhere... Not at my laptop yet 😁
Toggle: fringe This toggle is not supported.
SPC T f
toggles my fringe okay. Sounds like something is missing from you Spacemacs setup. I'll have a look at the .spacemacs file you posted.
@jr0cket Thank you!
@nick.romer Your .spacemacs file does seem to have some issues. First thought is that its from an older install, as it downloaded lots of packages in the elpa/develop file, rather than using the newer elpa/emacs-version/develop. Although I do seem to have a fringe, but do not see the clj-kondo marks there.
I assume you are using the Spacemacs develop
branch if you are using lsp, so suggest updating your .spacemacs file with the spacemacs.template, using SPC f e D
. Use b
to copy all changes from the template, except where you know you made those changes. You may want to backup .spacemacs before doing that just in case (but I havent had an issue doing this). Also Spacemacs will download all the packages again, so do this when you have 10 minutes to spare.
I am having a look to see if I can find the specific config, or if its another layer required.
On a side note, you might want to enable smartparens strict mode, dotspacemacs-smartparens-strict-mode t
to prevent unbalanced parens
I am not getting any clj-kondo errors at all when running your .spacemacs config, possibly because I am not running an LSP server. Do you have a pointer to instructions as to where I can install the LSP server for Clojure? Or is it just using the clj-kondo binary? Thanks
@jr0cket https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md#lsp-server
Ah, I have my clj-kondo in a different place. Thanks
@jr0cket The LSP server is not running using the binary
You need to download the .jar file, as described in the linked docs
Yes, once I actually read the docs it unsuprisingly worked 🙂 I like the very visual error messages, very handy.
I'll add it to my own .spacemacs config and check it works there.
Now i am getting curious: Is there an advantage running clj-kondo as lsp-server vs. running it as a linter?
@spfeiffer This has been discussed in this channel not so long ago
Sorry, will scroll back.
I skipped most of it as it sounded more like a „I just want to prove it is possible“ thing.
not really, it serves a real purpose, mostly for environments where the binary doesn't run. earlier this was Windows (no longer true), but there are also other (more fringe) architectures / OSes
and LSP is the most natural thing in VSCode so pretty much anyone who used the binary before, now runs LSP there
https://marketplace.visualstudio.com/items?itemName=borkdude.clj-kondo <- almost 15k installs already 🙂
Was thinking in the spacemacs context now. clj-kondo is running fine as a linter, never bothered with lsp.
it's probably not so interesting for you then. I'm also still using the binary in emacs
I have it working, although used a slight variation as I didn't want to hard code the path to the jar file in my Spacemacs config. So I put this in .spacemacs dotspacemacs/user-config
(use-package lsp-mode
:ensure t
:hook ((clojure-mode . lsp))
:commands lsp
:custom ((lsp-clojure-server-command '("clojure-lsp-server-clj-kondo")))
:config (dolist (m '(clojure-mode clojurescript-mode)) (add-to-list 'lsp-language-id-configuration `(,m . "clojure")))))
The clojure-lsp-server-clj-kondo
is a script on my path to call the java -jar clj-kondo-lsp-server-standalone.jar command using a relative path.
#!/bin/sh
java -jar ~/.local/apps/clj-kondo-lsp-server-2020.04.05-standalone.jar
This makes the emacs code more portable to other accounts and computers.makes sense
@spfeiffer the only differences I am aware of between clj-kondo and clj-kondo-lsp-server for Emacs are:
• Using lsp I am prompted to spawn an LSP process for every project I have open (I have a lot), although you can skip it for each project. SPC a p
lists 22 clojure-lsp processes for me at the moment (although these use very minimal resources). LSP does remembers which you have run and will run them again if you restart Emacs, which does add a few seconds to the startup time (although I rarely restart Emacs)
• UI difference. With LSP the text of the clj-kondo error is printed to the right hand side of the buffer when you move the cursor over an error. clj-kondo used a popup. I assume this is probably configurable somewhere.
• clj-kondo is part of the Clojure layer, so only needs a variable set on that layer. clj-kondo-lsp-server requires a dotspacemacs/user-config
configuration (although this could be added to the Clojure layer as a variable too with a bit of work. Ideally an external script would be used to launch the lsp server (as in the script above).
So apart from supporting environments where clj-kondo binary does not run, I concur that there no benefit to lsp over a working clj-kondo with the Clojure layer.
@nick.romer apart from having an older .spacemacs file, I didn't notice any specific configuration that would stop the fringe being displayed. I notice you added lsp-mode
as an additional package, this is not required as the lsp layer includes the lsp-mode
package. The only other difference was using Ivy, but I dont see how that would stop the fringe being shown.
Thanks for the great summary!
It's useful for my book too 😁
@jr0cket I removed lsp-mode and it still works. Question: I had to set the variable dotspacemacs-install-packages to used-but-keep-unused , otherwise some dependencies would be removed during startup and immediately reinstalled. What is the value on your system?
@nick.romer My config is shared at https://github.com/practicalli/spacemacs.d/
The specific config I added for LSP is at https://github.com/practicalli/spacemacs.d/commit/6187e11fe6c998afd39de91377a17a628bbfe37d
The install packages config is dotspacemacs-install-packages 'used-only
With your .spacemacs, you can remove the lsp layer, as you are bringing in lsp-mode
as an additional package. Although I recommend using a layer where available, rather than individual packages.
@practicalli fyi emacs doesn't support fringes in terminals https://stackoverflow.com/questions/35865400/why-doesnt-emacs-have-a-fringe-mode-in-terminal. Thank you for sharing your config!