lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
Karol W贸jcik 2020-08-06T06:08:58.044Z

Lsp runs smooth with cider! It's pleasure to use for now! Very happy the clojure-lsp exists

Karol W贸jcik 2020-08-06T10:02:30.044500Z

Is it possible to gather macro declarations from clj-kondo config?

borkdude 2020-08-06T10:20:42.044900Z

@karol.wojcik Not sure what your question is. Could you elaborate?

Karol W贸jcik 2020-08-06T10:24:18.047600Z

Sure. I'm getting a lot of errors from flycheck-lsp due to not known macros. For instance if you're using rum.core there are bunch of macros which are mostly defs. I've got .clj-kondo/config.edn in which all those macros are specified.

{:lint-as {rum.core/defcs clojure.core/def,
           rum.core/defc clojure.core/def,
           view.core/FOR clojure.core/for,
           view.core/KEEP clojure.core/keep}}
I would like clojure-lsp to use those declarations, because maintaining declarations both in config.edn & .lsp/config.edn' is tedious

borkdude 2020-08-06T10:26:40.048500Z

ok, thanks. btw, there is a possibly better config for rum to get more complete linting: https://github.com/borkdude/clj-kondo/tree/master/libraries/rum As for your LSP question, I don't know, so maybe someone else can answer that one

Karol W贸jcik 2020-08-06T12:20:33.049200Z

I think that I should just rely on clj-kondo and disable lsp checker for clj/s. EDIT: Ok that works:

(add-hook 'clojure-mode-hook '(lambda ()
                                  (setq flycheck-disabled-checkers
                                        (append flycheck-disabled-checkers '(lsp)))
                                  (setq flycheck-enabled-checkers (append flycheck-enabled-checkers '(clj-kondo-clj)))))

  (add-hook 'clojurescript-mode-hook '(lambda ()
                                        (setq flycheck-disabled-checkers
                                              (append flycheck-disabled-checkers '(lsp)))

                                        (setq flycheck-enabled-checkers (append flycheck-enabled-checkers '(clj-kondo-cljs)))))

  (add-hook 'clojurec-mode-hook '(lambda ()
                                   (setq flycheck-disabled-checkers
                                         (append flycheck-disabled-checkers '(lsp)))

                                   (setq flycheck-enabled-checkers (append flycheck-enabled-checkers '(clj-kondo-cljc)))))
Thanks @borkdude

ericdallo 2020-08-06T13:19:10.051300Z

@karol.wojcik We just implemented that yesterday: as clj-kondo doesn't allow us to have a .clj-kondo globally like clojure-lsp does, we just implemented the functionality that you can pass a clj-kondo key to your lsp config.edn , so something like this would work: https://github.com/ericdallo/dotfiles/blob/master/.lsp/config.edn#L1-L17

borkdude 2020-08-06T13:21:05.052400Z

@ericdallo clj-kondo does allow you to change the .clj-kondo directory, using :config-dir

borkdude 2020-08-06T13:21:36.052800Z

but it's advisable to have one per project, since it saves project-source-related information in .clj-kondo/cache

borkdude 2020-08-06T13:22:20.053400Z

although you can also tweak that using :cache-dir

borkdude 2020-08-06T13:22:54.054100Z

the stance that clj-kondo has on configuration is that it's a property of a project on which all team members agree upon

ericdallo 2020-08-06T13:24:53.056300Z

Yes, we are using cache-dir with .clj-kondo/cache , it's just I think some cases a global configuration works better, for example, at Nubank we have a bunch of services using midje, with a global configuration so we don't need to duplicate a .clj-konndo config dir with the linter exclusions to all prpojects

ericdallo 2020-08-06T13:25:23.056900Z

and the global .lsp/config.edn support is working for months for us

borkdude 2020-08-06T13:28:26.057500Z

yeah, if that works for you, that's fine :) you can also use clj-kondo.core/merge-configs to merge global and local config

ericdallo 2020-08-06T13:33:06.058200Z

nice, this could be the better of both ideas, merging some common global config and project specific config

ericdallo 2020-08-06T13:33:16.058500Z

thank you for the ideas @borkdude 馃檪 (clj-kondo is awesome)

borkdude 2020-08-06T13:34:07.058900Z

note that clj-kondo automatically merges configs passed to :config

borkdude 2020-08-06T13:34:39.059400Z

I think it might also pick up the local one in .clj-kondo/config.edn additionally, not entirely sure

borkdude 2020-08-06T13:35:37.059600Z

yes, it does

ericdallo 2020-08-06T13:37:33.060500Z

nice, so this is probably already working, I'll test this specific case later

Karol W贸jcik 2020-08-06T16:08:03.062500Z

How can I use clj-kondo only? I 've disabled lsp checker, but clj-kondo does not work out of the box. If I don't use lsp mode then clj-kondo works.

ericdallo 2020-08-06T16:08:53.062800Z

what editor do you use?

ericdallo 2020-08-06T16:09:58.063Z

Why do you want to disable lsp checker? clojure-lsp use clj-kondo as a linter too so if you use lsp checker, you use clj-kondo , you don't need to setup anything more

borkdude 2020-08-06T16:10:36.063200Z

Maybe lsp mode steals clojure mode for flycheck?

1
borkdude 2020-08-06T16:11:04.063400Z

I've written some docs how to fix that, if that's the issue: https://github.com/borkdude/flycheck-clj-kondo#multiple-linters

Karol W贸jcik 2020-08-06T16:14:37.064100Z

I'm using emacs

1
ericdallo 2020-08-06T16:16:00.064400Z

You can do what @borkdude suggested above, but I wonder what is you problem currently to you need to do that

ericdallo 2020-08-06T16:16:20.064600Z

lsp-mode brings a lot of another features that I recommend you to use like: Code actions, project diagnostics, find reference/usage etc

Karol W贸jcik 2020-08-06T16:17:16.064900Z

I want to use lsp-mode, but is it necessary to use it in conjunction with lsp-checker?

ericdallo 2020-08-06T16:18:28.065100Z

I see, no, you can disable it with (setq lsp-diagnostics-provider :none) : https://emacs-lsp.github.io/lsp-mode/page/settings/

borkdude 2020-08-06T16:19:25.065300Z

@karol.wojcik The latest clojure-lsp bundles clj-kondo so you might want to migrate to that at some point

鈽濓笍 1
borkdude 2020-08-06T16:19:46.065500Z

which is I think what Eric was getting at

1
Karol W贸jcik 2020-08-06T16:21:01.065900Z

(add-hook 'clojurescript-mode-hook '(lambda ()
                                        (setq lsp-diagnostics-provider :none)
                                        ))

  (setq-default lsp-diagnostics-provider :none)
It does not work 馃槥

Karol W贸jcik 2020-08-06T16:21:11.066100Z

I've installed clojure-lsp today

borkdude 2020-08-06T16:23:36.066300Z

should the lambda be quoted?

Karol W贸jcik 2020-08-06T16:23:37.066500Z

Ok I see. There is new version.. Will check it out

ericdallo 2020-08-06T16:24:34.066700Z

Also make sure you have the latest lsp-mode

Karol W贸jcik 2020-08-06T16:38:01.066900Z

I think that due to to much files watched lsp-mode is unable to use clj-kondo.

LSP :: You can configure this warning with the `lsp-enable-file-watchers' and `lsp-file-watch-threshold' variables
I'm got this in .lsp/config.edn but still lsp tries to watch like 10k files
{"project-specs" [{:project-path "build.boot"
                   :classpath-cmd ["boot" "show" "-c"]}]

 }

borkdude 2020-08-06T16:42:06.067100Z

why would lsp watch dependencies that don't change?

Karol W贸jcik 2020-08-06T16:43:22.067300Z

I think it tries to grab all the resources. 馃槷 Btw clj-kondo is used! 鉂わ笍 @borkdude I think that hooks support is incorrect for rum.core/defcs since first parameter is state and it's auto-added, by default

borkdude 2020-08-06T16:44:07.067500Z

@karol.wojcik Yes. A PR for that to fix it is welcome. Please discuss in #clj-kondo

borkdude 2020-08-06T16:44:27.067700Z

It has been brought up before and there was someone working on a fix, but it stalled somehow

borkdude 2020-08-06T16:46:36.067900Z

@martinklepsch and @robert-stuttaford are the people also using that

Karol W贸jcik 2020-08-06T17:54:52.068800Z

@ericdallo For sure something is wrong here. Lsp tries to watch whole project while it should watch only "src" folder.

ericdallo 2020-08-06T18:01:15.069Z

Did you configure the "source-paths" in your .slp/config.edn ?

Karol W贸jcik 2020-08-06T19:06:09.069500Z

I thought it will be auto configures based on boot.build

Karol W贸jcik 2020-08-06T19:10:48.070Z

I had this in config.edn

"project-specs" [{:project-path "build.boot"
                   :classpath-cmd ["boot" "show" "--fake-classpath"]}]

ericdallo 2020-08-06T19:12:42.070200Z

Hum, i'm not sure why it scans all those files so, @snoe can you confirm if this is a LSP server or a client issue?

snoe 2020-08-06T19:43:29.070400Z

@karol.wojcik there's also the ignore-classpath-directories option. If you don't have that set it would cause lsp to look at some generated files if boot puts them in the classpath. There's also source-paths which defaults to ["src","test"] and doesn't get pulled out of project. Not sure if that's what you mean by whole project

snoe 2020-08-06T19:44:20.070600Z

@dpsutton has also mentioned that lsp-mode has some issues with overscanning the project

snoe 2020-08-06T19:47:29.071Z

maybe, actually https://github.com/emacs-lsp/lsp-mode/pull/1829

Karol W贸jcik 2020-08-06T20:09:50.071800Z

@snoe I think that ignore-classpath-directories should work here:

{:source-paths ["src"
                "test"]
 "project-specs" [{:project-path "build.boot"
                   :ignore-classpath-directories ["resources" "target"]
                   :classpath-cmd ["boot" "show" "--fake-classpath"]}]}
but it does not. LSP watches whole project

snoe 2020-08-06T20:11:54.072100Z

@karol.wojcik it goes on the root, next to source-paths

snoe 2020-08-06T20:12:21.072300Z

both should also be strings not keywords

Karol W贸jcik 2020-08-06T20:16:51.072500Z

@snoe does not work.

snoe 2020-08-06T20:18:26.072800Z

Yeah, I suspect lsp-mode might be the issue.

ericdallo 2020-08-06T20:33:52.073Z

@karol.wojcik Can you send this issue on our lsp-mode channel: https://gitter.im/emacs-lsp/lsp-mode? Then we can track and understand if is a issue with client side 馃檪