Lsp runs smooth with cider! It's pleasure to use for now! Very happy the clojure-lsp exists
Is it possible to gather macro declarations from clj-kondo config?
@karol.wojcik Not sure what your question is. Could you elaborate?
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 tediousok, 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
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@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
@ericdallo clj-kondo does allow you to change the .clj-kondo
directory, using :config-dir
but it's advisable to have one per project, since it saves project-source-related information in .clj-kondo/cache
although you can also tweak that using :cache-dir
the stance that clj-kondo has on configuration is that it's a property of a project on which all team members agree upon
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
and the global .lsp/config.edn
support is working for months for us
yeah, if that works for you, that's fine :) you can also use clj-kondo.core/merge-configs
to merge global and local config
nice, this could be the better of both ideas, merging some common global config and project specific config
thank you for the ideas @borkdude 馃檪 (clj-kondo is awesome)
note that clj-kondo automatically merges configs passed to :config
I think it might also pick up the local one in .clj-kondo/config.edn
additionally, not entirely sure
yes, it does
nice, so this is probably already working, I'll test this specific case later
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.
what editor do you use?
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
Maybe lsp mode steals clojure mode for flycheck?
I've written some docs how to fix that, if that's the issue: https://github.com/borkdude/flycheck-clj-kondo#multiple-linters
I'm using emacs
You can do what @borkdude suggested above, but I wonder what is you problem currently to you need to do that
lsp-mode
brings a lot of another features that I recommend you to use like: Code actions, project diagnostics, find reference/usage etc
I want to use lsp-mode, but is it necessary to use it in conjunction with lsp-checker?
I see, no, you can disable it with (setq lsp-diagnostics-provider :none)
: https://emacs-lsp.github.io/lsp-mode/page/settings/
@karol.wojcik The latest clojure-lsp bundles clj-kondo so you might want to migrate to that at some point
which is I think what Eric was getting at
(add-hook 'clojurescript-mode-hook '(lambda ()
(setq lsp-diagnostics-provider :none)
))
(setq-default lsp-diagnostics-provider :none)
It does not work 馃槥I've installed clojure-lsp today
should the lambda be quoted?
Ok I see. There is new version.. Will check it out
Also make sure you have the latest lsp-mode
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"]}]
}
why would lsp watch dependencies that don't change?
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
@karol.wojcik Yes. A PR for that to fix it is welcome. Please discuss in #clj-kondo
It has been brought up before and there was someone working on a fix, but it stalled somehow
@martinklepsch and @robert-stuttaford are the people also using that
@ericdallo For sure something is wrong here. Lsp tries to watch whole project while it should watch only "src" folder.
Did you configure the "source-paths"
in your .slp/config.edn
?
I thought it will be auto configures based on boot.build
I guess it uses this default: https://github.com/snoe/clojure-lsp/blob/bae3cc77e9f4b6d9f90a46104b54d0196ac92745/src/clojure_lsp/crawler.clj#L239-L240?
I had this in config.edn
"project-specs" [{:project-path "build.boot"
:classpath-cmd ["boot" "show" "--fake-classpath"]}]
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?
@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
@dpsutton has also mentioned that lsp-mode has some issues with overscanning the project
maybe, actually https://github.com/emacs-lsp/lsp-mode/pull/1829
@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@karol.wojcik it goes on the root, next to source-paths
both should also be strings not keywords
@snoe does not work.
Yeah, I suspect lsp-mode might be the issue.
@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 馃檪