This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-21
Channels
- # announcements (5)
- # babashka (9)
- # beginners (84)
- # calva (47)
- # clara (3)
- # clj-kondo (2)
- # clojars (8)
- # clojure-australia (3)
- # clojure-europe (3)
- # clojure-spec (1)
- # clojurescript (5)
- # conjure (6)
- # cursive (7)
- # datahike (3)
- # events (2)
- # helix (1)
- # lsp (217)
- # luminus (4)
- # malli (18)
- # meander (23)
- # membrane (12)
- # off-topic (26)
- # pathom (12)
- # reagent (44)
- # releases (1)
- # rewrite-clj (2)
- # shadow-cljs (19)
- # sql (17)
- # xtdb (6)
Hi!! Is there to turn off lsp-headerline-breadcrumb-mode
?
I copied this from the docs and the breadcrumb mode is enabled by default in my clojure buffers.
(use-package lsp-mode
:ensure t
:hook ((clojure-mode . lsp)
(clojurec-mode . lsp)
(clojurescript-mode . lsp))
:config
;; add paths to your local installation of project mgmt tools, like lein
(setenv "PATH" (concat
"/usr/local/bin" path-separator
(getenv "PATH")))
(dolist (m '(clojure-mode
clojurec-mode
clojurescript-mode
clojurex-mode))
(add-to-list 'lsp-language-id-configuration `(,m . "clojure")))
(setq lsp-clojure-server-command '("bash" "-c" "clojure-lsp"))
(lsp-headerline-breadcrumb-mode nil))
I guess I can add a hook and toggle it.For more details, check https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/
Oh, I saw that variable but I thought it kept the mode enabled with the breadcrumbs invisible. Ill try it.
LSP replace most clj-refactor features, and AFAIK only conflicts with creating a new ns which can be solved like this tutorial explains: https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/
Thank you for the sponsor @nicdaoraf ❤️
No worries 🙂 I appreciate all your efforts I'd contribute with code if I could but currently have a full-time job and a startup-ish with a friend
lsp-mode becomes unbearably slow for me when developing clj-kondo itself (e.g. in clj_kondo/impl/analyzer.clj). So slow that I have to turn it off unfortunately, because I can't even type anymore :(
There are a lot of things that may cause that: https://emacs-lsp.github.io/lsp-mode/page/performance/
Yeah, I'm trying here but it works for me well There is something that we could improve though related to file changes
but it's a corner case only when changing a function arity (that will trigger other scans in references), it should not make the experience that bad
I have emacs 27.1 with native json support and checked most of these things, still very slow
I am watching this:
$ tail -f /tmp/clojure-lsp.out
2021-02-20T11:32:36.922Z MBP2019.local INFO [clojure-lsp.main:350] - Shutting down
2021-02-20T11:32:37.213Z MBP2019.local INFO [clojure-lsp.main:355] - Exit
Nothing to see here?{:project-root "file:///Users/borkdude/Dropbox/dev/clojure/clj-kondo",
:project-settings {:auto-add-ns-to-new-files? false},
:client-settings
{:dependency-scheme "jar",
:source-paths #{"src" "test"},
:macro-defs {},
:project-specs nil,
:cljfmt {:indents {}},
:document-formatting? true,
:document-range-formatting? true},
:port "NREPL only available on :debug profile compiled binary",
:version "2021.02.19-00.19.27",
:log-file
"/var/folders/2m/h3cvrr1x4296p315vbk7m32c0000gp/T/clojure-lsp.3323505275673554799.out"}
https://gist.github.com/borkdude/9162c9bed4fca8722f7ca964244d82ea :didChange 14 seconds?
This slowness happens only when changing function arity? otherwise it could be a performance issue on clojure-lsp
For example I'm just editing the comment
form at the bottom of the file and I tried typing (+ 1 2 3)
:
(comment
(+ )
(parse-string "#js [1 2 3]"))
It takes 14 seconds before the space shows upThe question is also, why does it take 14 seconds ....
:didChange 14192ms
If I lint this file using clj-kondo only it takes 1 second:
$ time clj-kondo --config '{:output {:analysis {:locals true :keywords true} :format :edn}}' --lint src > /dev/null
clj-kondo --config --lint src > /dev/null 1.08s user 0.12s system 99% cpu 1.212 total
this way if user go to a referenced file and the function arity was changed it will have the most updated lint
I have a.clj:
(defn foo [a b])
b.clj
(foo 1 2)
If I change the arity of foo, I want clj-kondo warn that (foo 1 2)
has another arity nowif we don't do that, user will notice that only if enter on b.clj
change the buffer, and clj-kondo relint b.clj and notice that the arity changed
but if analyze only the current file, clj-kondo will not return findings of the other files
this is what clj-kondo itself has been doing, and lint warnings you will get when you visit the other files, because it persists through the cache
why should clj-kondo returning warnings for other files? you will see those warnings when you visit the other file
what we would need to do is: when changing a.clj
publish diagnostics for b.clj
also
I am not interested in seeing lint warnings for other files than the current one. Supporting that is way too unperformant, this is why clj-kondo doesn't do that. If I opt out of linting via lsp-mode I also want to opt out of this slow behavior
yeah, that should be considered too, I'll disable that as default, we may need to think more about that as a improvement
For now I'll have to disable lsp-mode for this project, as it's not workable unfortunately. Maybe I can see what clojure-lps is analyzing? Maybe it tries to analyze all my deps as well, by accident? This takes about 5-10 seconds on my machine
You could add a log here: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/file_management.clj#L62
I was going to look into the arglist issue for you, but this is now taking up my time instead ;)
Maybe you can also apply some debouncing, e.g. when the user types again, the previous requests get cancelled?
Also I found that the didChange on clojure-lsp could be complete async (confirming with lsp-mode folks)
@UKFSJSM38 This was added by snoe: https://github.com/clojure-lsp/clojure-lsp/issues/324#issuecomment-782887656 Isn't this what you need here?
@U04V15CAJ yes, I use that, but is not the same
so you need the locations, or only the list? if you need only the list, I think you can parse the arglist-strs as edn?
user=> (edn/read-string "[a b {:keys [:foo]}]")
[a b {:keys [:foo]}]
user=> (edn/read-string "[a b & xs]")
[a b & xs]
I think it could maybe fail on this:
user=> (edn/read-string "[{::str/keys [:x]}]")
Execution error at user/eval14 (REPL:1).
Invalid token: ::str/keys
but this is such a niche use case that you could maybe not support this onebut we could also change :arglist-strs
to [["x" "y"]]
instead of [["x y"]]
, would that make sense?
what we would need is a list of the args like ["a" "b" "& rest"]
this way I can count the children of the function usage with rewrite-clj and get the arg name via the index
user=> (e/parse-string "{::str/keys [:a]}" {:auto-resolve (fn [ns] (symbol ns))})
#:str{:keys [:a]}
or even:
user=> (e/parse-string "{::str/keys [:a]}" {:auto-resolve (fn [ns] (symbol (str ":" ns)))})
#::str{:keys [:a]}
to fake it more ;)I''ll merge the performance fix, made some tests and it really improved the performance for analyzer/impl.clj file 🙂
That works like a charm https://github.com/clojure-lsp/clojure-lsp/issues/324#issuecomment-782889893 ✨
I'm not sure what the referenced commit below that comment here does: https://github.com/dharrigan/clojure-lsp/commit/581263159654838a7a0d5c6b8f1ec65977aba907 It seems like you're parsing the arglists yourself?
Yeah, I don't get it that commit too 😅 it seems @U11EL3P9U made a rebase with his branch and because of the
Fixes clojure-lsp#324
comment it linked it somehowbut that was done before our conversation of today @U04V15CAJ
Released https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.02.21-21.02.51 of
clojure-lsp
adding support for signatureHelp 🎉

@UKFSJSM38 I am trying it now. Performance seems better now in the big analyzer.clj file in clj-kondo. But when I type 1111
and keep typing ones in the comment block at the bottom, it's still lagging, i.e. it slows down my typing. Is there something that can be done about this?
It's as if I'm connected to a remote terminal with half a second of network lag. I think an editor tool should never slow the user down while typing.
in clojure-lsp logs is there any method taking to much time? It turns out didChange is a notification and don't block user input, I suggest you follow performance section on lsp-mode as well
but since you could reproduce my previous issue, I suspect you will be able to reproduce this one too. it's the same, only less slow
2021-02-21T21:56:05.528Z MBP2019.local DEBUG [clojure-lsp.main:?] - :completion 329ms
2021-02-21T21:56:05.528Z MBP2019.local DEBUG [clojure-lsp.main:?] - :completion 330ms
2021-02-21T21:56:05.671Z MBP2019.local DEBUG [clojure-lsp.main:?] - :didChange 472ms
I tried finding the notify-references-on-change
flag to see if I could turn this off but I can't find it anywhere in the code
Don't get me wrong, I think clojure-lsp is awesome but I will turn it off in clj-kondo again now, just can't work like this in this project.
Thanks a lot in advance. About the signatureHelp: does this also work without lsp-ui? E.g. show it in the mini-buffer, like cider does?
BTW the performance adding 1
looks normal to me, but not sure realted to emacsGcc good performance
@U5B6G208G knows better ways to trace those performance issues on Emacs
Hmm, I don't seem to have the signature help.
Even despite stealing this from your dotfiles @UKFSJSM38 (setq lsp-signature-function 'lsp-signature-posframe)
Also, how do I remove the file paths? (You don't have them)
That doesn't look signature help, but hover request. Try lsp-signature-activate and ame sure your have posframe installed with that config of mine

Ah! It works I see. I had the expectation that it would come up automatically without having to invoke anything.
Is there a way to edit the faces so that the current arg is colored more obviously?
Tô come automatically we d need to pass to client a character that it'll know that should show the signature
> yeah, that's what I would expect too, like in cider Oh, I didnt know cider does this 😮
Ah, I see. Performance-aside, it can be "every char" being typed?
Exactly, the lap client is generic for multiple languages, so it can only do things that follow the lsp spec
Yes @nicdaoraf, but that would show the signature everytime, even on non sense places
nonsense places like fns without overloads?
Right. Actually, I write a lot of Typescript (usually via vscode) and signature help auto-pops up. But I've realized that the trigger char is probably ,
myFunc(arg1, arg2, arg3)
Ok, anyways, workflow optimization that is probably not worth the effort* 🙂
C-S SPC
isn't hard at all to press. So thanks for the explanation
Yeah, I agree that would perfect for clojure, but I could not find a character that makes sense
Actually, can't (
be the trigger for Clojure too?
Ah, I see. I guess they didnt have Lisps in mind when they designed the protocol (I mean MS)
Is this it?
> Hum, maybe we could use `(` as trigger and space as retrigger?
But as you said, you don't know the function name yet when you're only at (
?
I think if server return nil ( when don't know the function) a retrigger will no twork
maybe the server can remember some kind of state, the user typed '(` and then the next space will return something?
As a retrigger probably works only when user close the window but the signature is valid
Yeah, that could leave to false positives, thats why we should use the client info, the context field maybe can be hacked to make that work
TLDR for context field?
Is a field containing the information about the current signature, maybe can help us Check the spec for more info
@UKFSJSM38 clojure-lsp also has a rewrite-clj representation of the AST right? Can you use this to scan backwards to see which function call you are in (if any)?

We already do that, we scan backward to get the function name, but when user type (
the function name doesn't exists yet, but when one type a space, it should exists
What is your issue @U0BBFDED7 ?
(use-package! lsp-mode
:defer t
:config
(setq! lsp-ui-sideline-enable t
lsp-symbol-highlighting-skip-current nil
lsp-vetur-language-features-code-actions nil
lsp-ui-sideline-actions-icon nil
lsp-ui-sideline-show-code-actions nil)
(pushnew! lsp-file-watch-ignored-directories
"[/\\\\]\\.cpcache\\'"
"[/\\\\]\\.shadow-cljs\\'"
"[/\\\\]\\resources\\'")
(set-face-foreground 'lsp-face-highlight-read nil)
(set-face-background 'lsp-face-highlight-read nil)
(set-face-attribute 'lsp-face-highlight-read nil :weight 'extra-bold)
(set-face-background 'markdown-code-face nil))
I don’t think that’s missing from Doom. @U0BBFDED7, did you add (clojure +lsp)
to init.el
in addition to lsp
?
:man-shrugging::skin-tone-2: https://github.com/hlissner/doom-emacs/blob/develop/modules/lang/clojure/config.el#L18...L23
clojure-lsp
is on Github trending repos of Clojure 😄 🎉 Thanks all!
https://github.com/trending/clojure?since=monthly
