This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-06
Channels
- # announcements (18)
- # asami (14)
- # aws (5)
- # babashka (58)
- # beginners (32)
- # calva (12)
- # cider (29)
- # clj-kondo (8)
- # cljfx (8)
- # cljs-dev (4)
- # clojure (101)
- # clojure-europe (54)
- # clojure-germany (5)
- # clojure-nl (8)
- # clojure-serbia (8)
- # clojure-spec (12)
- # clojure-uk (8)
- # clojurescript (24)
- # cursive (3)
- # datomic (17)
- # docs (2)
- # etaoin (12)
- # events (1)
- # fulcro (1)
- # google-cloud (2)
- # jobs (1)
- # jobs-discuss (6)
- # lsp (65)
- # luminus (2)
- # malli (10)
- # meander (4)
- # nrepl (1)
- # off-topic (112)
- # onyx (2)
- # pathom (6)
- # polylith (14)
- # re-frame (9)
- # reagent (36)
- # reitit (13)
- # releases (2)
- # remote-jobs (5)
- # rewrite-clj (12)
- # shadow-cljs (70)
- # specter (2)
- # startup-in-a-month (1)
- # xtdb (14)
so I think there's a pretty big issue with caching we need to solve - imo an important constraint to uphold is that when the server starts, its state should reflect the state of the filesytem.
pre-kondo we used checksums to see if dependencies changed and only cached those; project sources were never cached. With kondo we are now also caching project sources. The problem is most prevalent when I git pull
in the morning and start up vim. New functions and namespaces are reported as unresolved and the analysis is missing.
So I think we either have to rm files from the kondo cache on startup, or ideally if kondo can be given a flag to ignore the cache for any files being analyzed.
Hum, I understand the issue but I don't recall having this issue, did you mean new functions and namespaces are reported as unused or unresolved? I'm not sure I have this issue
here's an example
$ cat src/a.clj src/b.clj
(ns a (:require b)) (b/foo) (b/bar)
(ns b) (defn foo [] 1)
open up a.clj - clojure-lsp should say b/bar
is unresolved
shut it down
echo " (defn bar [] 2)" >> src/b.clj
start it back up, opening only a.clj
and b/bar
will still be unresolved.but wait, https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/crawler.clj#L218 will always be called and should lint project everytime, right?
I think in kondo caching always wins but I think it would be nice to say if i lint a.clj and b.clj - that the cache will not be used by the files
so what we need is on that analyze-paths
accept a use-cache?
that will not use the :cache
flag on clj-kondo
Because ATM https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/config.clj#L25
yes, I meant, only on that line call, because we call the analyze-paths
on both classpath analysis and project source-paths analysis
this way we could use the cache for deps/classpath analysis and don't use the cache on the next call, the source-paths analysis
You can say :cache false
but I don't understand why you would not use the cache, as clj-kondo won't learn about new arities etc for the linted functions?
Oh, I thought the :cache false
would just don't use some cached previous analysis, I didn't know would affect the analysis features
I see, so whenever some sources have changed outside of clj-kondo's visibility, you effectively want to re-lint the entire project

ok, I think clj-kondo supports all you need right now, but if not, feel free to post an issue
if you re-lint both files, no special args are needed - why do you think this is the case?
So we are already linting project source-paths on every startup, but still this is not working, is that right @U0BUV7XSA?
yeah, I'm not sure if it's on the kondo side or ours tho - having trouble taking the time to figure it out
if you re-lint sources, clj-kondo should have a consistent view of interactions between those files. no special options needed
you could maybe log which files are linted or something, to find out what happens
thoughts @ericdallo @borkdude?
Hey team, does someone have a config a nvim or some such config I could look at, for commands like “add missing require/import”? (I know https://github.com/snoe/dotfiles/blob/master/home/.vimrc, but I don’t think the “add-missing-require” call is there) Will play with it soon, but if there are more files I could look at for inspiration would appreciate it!
Maybe we should link your config https://clojure-lsp.github.io/clojure-lsp/clients/#vim @U11EL3P9U if you agree 🙂
@U0C5DE6RK I suggest you always use the code actions as if there is a available way to import the ns, it will be there
Check add-missing-require https://clojure-lsp.github.io/clojure-lsp/features/#code-actions
Thanks Eric. Apologies for the noobie question here, but am not quite sure I understand the codeaction bit. Would you mind expanding a bit deeper?
(in dharrigan’s vimrc, I see:
call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'add-missing-libspec', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1]})
is add-missing-libspec
here a codeaction, or something else?)Ah, I think I understand. code-actions
are the commands listed here (https://clojure-lsp.github.io/clojure-lsp/features/#code-actions) — and I guess coc
may already have mappings to them. Will check coc to see how to invoke the correct code action to add missing require.
yes, the server return the available code actions, and you, user, select what you want to execute
if that function could be required/imported, then the server will return a code action for that on that line 🙂
I have some keymaps for code-actions if you need a second source for your vim config https://github.com/rafaeldelboni/dotfiles/blob/master/config/nvim/init.vim#L206

Okay, one more noob question: Say I have
nnoremap <silent> crml :call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'move-to-let', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1, input('Binding name: ')]})<CR>
Could I do above with a codeAction?
If I do @UMMMKKADU ac
, I don’t see move-to-let
as an option.
If I try
:call CocActionAsync('codeAction', 'move-to-let')
It says it is unsupported
That keyboard shortcut does seem to work thoughif the move to let action show on code actions, it should work for the current buffer cursor
(indeed, it does not seem to show) Okay, I think I understand this much better. Thanks team!
I think that's the only one missing on code actions :thinking_face: we could add that
Cool! May have mistunderstood a bit more. What about something like “extract-function”? If I hover over a form, and run coc-codeaction, I still only see these suggestions:
xD — indeed could be nice add! if you like can make an issue on GH. I don’t know when I’ll have time, but could add to my someday to write a pr. Great work on lsp team — my vim setup has become object of envy from friends — it’s so darn cool now.
whenever I run code-action, it seems like I only get these 4 results. For example, in this one I expected to find thread-first
or something like this
yeah, that depends on how vim sens that buffer position, on emacs it works on both
@U0C5DE6RK visual select is also where the "move to let" is hiding. You just need to select something inside of a let
-block
Okay, one more noob question. Looks like add-missing-libspec
command can auto-import namespaces.
It seems to fail with java classes though.
(i.e if I hover over FlexmarkHtmlConverter
, and run add-missing-libspec
, would love it do: (:import (com.vladsch.flexmark.html2md.converter FlexmarkHtmlConverter))
)
Is something like this supported with clojure-lsp yet? If yes, what’s the way to trigger it?