Fork me on GitHub
#spacemacs
<
2020-04-13
>
borkdude07:04:13

@nick.romer maybe leaving some notes in the clj-kondo repo might be nice if you think it’s valuable for others

niveauverleih07:04:59

Of course. Do you mean a PR to the editor-integration.md?

practicalli-johnny07:04:27

@nick.romer the syntax-checking layer provides the indicators in the fringe showing which lines have warnings, issues.

niveauverleih08:04:17

@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?

practicalli-johnny08:04:42

Oh, you don't have a fringe? It's there by default, so not sure how it's turned off/on

niveauverleih08:04:18

@jr0cket... or is the fringe activated based on the screen size?

practicalli-johnny08:04:58

I am guessing there is a toggle, under SPC T somewhere... Not at my laptop yet 😁

niveauverleih08:04:51

Toggle: fringe This toggle is not supported.

practicalli-johnny08:04:18

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.

practicalli-johnny08:04:04

@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.

practicalli-johnny08:04:14

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.

practicalli-johnny09:04:30

On a side note, you might want to enable smartparens strict mode, dotspacemacs-smartparens-strict-mode t to prevent unbalanced parens

practicalli-johnny09:04:18

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

practicalli-johnny09:04:52

Ah, I have my clj-kondo in a different place. Thanks

borkdude09:04:15

@jr0cket The LSP server is not running using the binary

borkdude09:04:30

You need to download the .jar file, as described in the linked docs

practicalli-johnny09:04:48

Yes, once I actually read the docs it unsuprisingly worked 🙂 I like the very visual error messages, very handy.

practicalli-johnny09:04:07

I'll add it to my own .spacemacs config and check it works there.

spfeiffer09:04:45

Now i am getting curious: Is there an advantage running clj-kondo as lsp-server vs. running it as a linter?

borkdude09:04:11

@spfeiffer This has been discussed in this channel not so long ago

spfeiffer09:04:21

Sorry, will scroll back.

spfeiffer09:04:51

I skipped most of it as it sounded more like a „I just want to prove it is possible“ thing.

borkdude09:04:31

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

👍 4
borkdude09:04:26

and LSP is the most natural thing in VSCode so pretty much anyone who used the binary before, now runs LSP there

spfeiffer09:04:47

Was thinking in the spacemacs context now. clj-kondo is running fine as a linter, never bothered with lsp.

borkdude09:04:09

it's probably not so interesting for you then. I'm also still using the binary in emacs

👍 4
practicalli-johnny10:04:13

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.

borkdude10:04:59

makes sense

practicalli-johnny10:04:13

@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.

👍 8
spfeiffer13:04:33

Thanks for the great summary!

practicalli-johnny13:04:03

It's useful for my book too 😁

practicalli-johnny11:04:24

@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.

niveauverleih15:04:07

@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?

practicalli-johnny15:04:50

The install packages config is dotspacemacs-install-packages 'used-only

practicalli-johnny15:04:17

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.

niveauverleih22:04:38

@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!