This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-01
Channels
- # aleph (3)
- # announcements (10)
- # babashka (6)
- # bangalore-clj (4)
- # beginners (91)
- # biff (7)
- # cider (25)
- # cljs-dev (1)
- # clojure (109)
- # clojure-europe (9)
- # clojure-norway (5)
- # clojure-uk (1)
- # clojurescript (22)
- # cursive (22)
- # data-science (1)
- # datalevin (5)
- # datomic (7)
- # emacs (7)
- # etaoin (1)
- # events (3)
- # graphql (12)
- # hyperfiddle (1)
- # inf-clojure (1)
- # lsp (69)
- # luminus (1)
- # meander (21)
- # nbb (4)
- # off-topic (27)
- # other-languages (12)
- # rdf (58)
- # releases (3)
- # remote-jobs (2)
- # rum (12)
- # shadow-cljs (4)
- # sql (3)
- # xtdb (1)
I just started using lsp-mode and found that renaming a defrecord
does not work as expected:
(defrecord Foo)
->
M-x lsp-rename RET Bar
->
(defreBar
Is there a way how I can fix that?Hey. Does anyone know what's this LSP error about? I typed a keyword with three slashes (I actually use it and need it) and this happens:
i don't think multiple slashes are "allowed" in keywords.
jk, i was wrong, it works lol
They are. I used them and I wanted to namespace a namespaced kw š
@invertisment_clojuria This comes up occasionally. 3 slashes are not supported in Clojure. If it works, then it's just because there isn't any validation on that. LispReader may accept it but tools.reader does not (which is used by babashka, CLJS, etc.)
ā¢ '/' has special meaning, it can be used once in the middle of a symbol to separate the namespace from the name, e.g. my-namespace/foo
. '/' by itself names the division function.
(link: https://clojure.org/reference/reader)
But if I use /
in Clojure the second one becomes part of the name. And that's totally fine for my uses.
I don't need to separate it, it's an identifier
This is from babashka:
bb -e '(name :hello/dear/world)'
"dear/world"
bb -e '(namespace :hello/dear/world)'
"hello"
Don't:
$ plk
ClojureScript 1.10.914
cljs.user=> 'foo/bar/baz
Syntax error reading source at (<cljs repl>:1).
Invalid symbol: foo/bar/baz.
cljs.user=> :foo/bar/baz
Syntax error reading source at (<cljs repl>:1).
Invalid keyword: :foo/bar/baz.
Oh, why does CLJS do that... hmm š I don't use symbols though (phew, dodged all these compilation errors). Only keywords :thinking_face:
bb -e "(namespace 'hello/dear/world)"
1: (namespace 'hello/dear/world)
^--- Invalid symbol: hello/dear/world
So um... I'll ask about this in Clojure then š Maybe they'll do some kind of a patch or maybe it will be marked as "intended". It's not good that the implementations allow different things.
Yeah, I'm not sure it's a issue on clojure-lsp as you opened https://github.com/clojure-lsp/clojure-lsp/issues/1163 @invertisment_clojuria
This is my issue š
I created it differently but then as I was instructed that /
is not allowed I changed the issue.
Previously I created this issue to indicate that I want to type more than one /
and expect the highlighting errors not show up.
But after getting more info I changed the issue into "add a new warning" and I think I can't remove bug
tag.
When I use resolve-macro-as
, it removes comments in my .clj-kondo/config.edn
file:
$ git diff
diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn
index f29b7985d..290eba7c1 100644
--- a/.clj-kondo/config.edn
+++ b/.clj-kondo/config.edn
@@ -1,9 +1,9 @@
-;!zprint {:format :off}
{:lint-as {honeysql.helpers/defhelper clojure.core/def
honeysql.util/defalias clojure.core/def
- crossbeam.utils/when-let* clojure.core/let}
+ crossbeam.utils/when-let* clojure.core/let
+ clojure.test.check.clojure-test/defspec clj-kondo.lint-as/def-catch-all}
:linters
let me check!
it leaves comments inside of the map:
$ git diff
diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn
index 1a82492e5..88ff1fd1e 100644
--- a/.clj-kondo/config.edn
+++ b/.clj-kondo/config.edn
@@ -1,8 +1,8 @@
-;!zprint {:format :off}
{:lint-as {honeysql.helpers/defhelper clojure.core/def
honeysql.util/defalias clojure.core/def
; example comment in test
- crossbeam.utils/when-let* clojure.core/let}
+ crossbeam.utils/when-let* clojure.core/let
+ clojure.test.check.clojure-test/defspec clj-kondo.lint-as/def-catch-all}
alright, please open a issue, it should not be that hard to fix (if you wanna https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/feature/resolve_macro.clj#L43)
what function would find the definition but do it in a new window? asking for emacs if the editor is relevent.
This is not specified in LSP spec, so I think each editor would need to implement/handle manually
Hey.
For some reason in my nvim config Clojure LSP server stopped formatting the code. Other servers work (I tested on tsserver
).
I also see this warning in my :LspLog
:
[WARN][2022-07-14 15:55:10] ...lsp/handlers.lua:110 "The language server clojure_lsp triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
There is only this warning and nothing else and it occurs all the time.
How do I debug this? Is this a problem with my config? It's a generic config for all LSP servers to initialize in the same way.Could you check https://clojure-lsp.io/troubleshooting/#server-log?
It doesn't say anything about formatting. It mostly says about published diagnostics and it has a couple of warnings about clj-kondo. But other than that it looks clean. Does it log formatting attempts? Maybe it means that my config doesn't try to ask for formatting? It has this too but I'm not sure it means anything:
2022-08-01T18:55:52.998Z DEBUG [clojure-lsp.nrepl:21] - nrepl not found, skipping nrepl server start...
yes, it logs formatting attemps, so probably your editor is not calling lsp formatting
I found the problem. When I have a non-clean working directory and I start a new LSP server then the formatting doesn't work.
try getting <https://clojure-lsp.io/troubleshooting/#client-server-log%7Cclient<->server> logs
Because I ran git stash -u
and then reran nvim
and then formatting worked.
What's weird with this is that the file that I was formatting was not changed and should've probably compile. I'll try to get the logs.
I have the log. Do you have a specific text that I should look for?
It has the formatting messages:
[DEBUG][2022-08-01 22:10:57] .../lua/vim/lsp.lua:1023 "LSP[clojure_lsp]" "client.request" 1 "textDocument/formatting" { options = { insertSpaces = true, tabSize = 2 }, textDocument = { uri = "file:///home/martin/aaaaaaaaaaaaaaaaaaaaaaaaa.clj" }} <function 1> 3
There is client.request
and then there is rpc.send
This is a real and quite large project, I just removed the filename.
That URI is correct, if I open it in Firefox it opens the file.
This is that URI but with removed intermediate package names:
file:///home/martin/Documents/dev/aaaaaa/aaaa/test/aaaaa/aaaa/crud/queries/aaaaaaaaaaa_test.clj
The test
directory means it's my testsNever saw this behavior, since server is not logging formatting, I still suspect the request is not being sent to server
Maybe it's logging the formatting, I just didn't look for it.
There are places with huge chunks of code. I didn't talk about them.
There is the textDocument/didSave
and textDocument/didChange
which have a lot of code.
But textDocument/formatting
are very small and without actual code.
So should formatting
one have my file or should be some kind of the other request?
But this is not it?
[DEBUG][2022-08-01 22:10:57] .../vim/lsp/rpc.lua:347 "rpc.send" { id = 4, jsonrpc = "2.0", method = "textDocument/formatting", params = { options = { insertSpaces = true, tabSize = 2 }, textDocument = { uri = "file:///home/martin/Documents/dev/aaaaaa/aaaa/test/aaaaa/aaaa/crud/queries/aaaaaaaaaaaa_test.clj" } }}
It says the URI. So what else should it say?
(btw this is my regex for searching: method.= .[a-zA-Z]*.formatting
)So anyway. I tried to stash all my files and I think that some kind of initialization prevents the server from formatting the file. Because right now I have a codebase that is dirty and broken. And it doesn't work right now. But when I stashed the changes and restarted then it worked. But it's not this file that's broken. I think something is still broken from my refactoring but I don't know where so I haven't fixed it yet. But it's probably bad that it doesn't format if something somewhere else is broken.
Ok, I'll try
I can't make a repro. I tried to import nonexistent function, I tried to require a file that has bad ending parens, I tried cyclical dependency and also nonexistent ns. All of these worked. I don't know why my current project doesn't. I'll try to look for what could be different. But now I have to go to sleep. I hope I'll notice what this is.
When I stash and start-up vim then it works. Then when I unstash it stops working with the same LSP server. So it's not tied to start-up of LSP server. Maybe that's a clue. I mostly have symbol and namespace import renames.
I also found that in both cases the tests pass and repo compiles just fine. So it's something weird š
Removing of .clj-kondo
dir did nothing. Is there other cache I could delete?
Removing .lsp
and restarting also did nothing.
This test code snippet breaks the formatting:
(deftest magic-test
(testing "should delete stuff"
(testing "id check"
(is (= {:aaaa-aaaaa/aaa-aaaa-aa [:aaaaaaaaa/aaaa-aaaaa/aaa-aaaa-aa]}
(->> (core/foo
[:aaaaaaaaaaa/aa-aaaaaa-aaaaaaaaa :aaaa-aaaaa/aaa-aaaa-aa])
::aaaaaaaa-aaaaaaaa/aaaaaa
:aaaaaaaaaaa/aa-aaaaaa-aaaaaaaaa))))))
core/foo
exists. Weeeeeirdtesting
macro?{:aaaa-aaaaa/aaa-aaaa-aa [:aaaaaaaaa/aaaa-aaaaa/aaa-aaaa-aa]}
And specifically it is :aaaaaaaaa/aaaa-aaaaa/aaa-aaaa-aa
when it's in the first part of =
in the is
assertion. The nested one inside the ->>
macro is the same keyword but it doesn't break if the first one is deleted.
This is formatted just fine:
(deftest magic-test
(testing "should delete stuff"
(testing "id check"
(is (= (->> (core/foo
[:aaaaaaaaaaa/aa-aaaaaa-aaaaaaaaa :aaaa-aaaaa/aaa-aaaa-aa])
::aaaaaaaa-aaaaaaaa/aaaaaa
:aaaaaaaaaaa/aa-aaaaaa-aaaaaaaaa))))))
Probably it's the double /
. Is the LSP server running on babashka or in CLJS? Because double /
is not allowed there.
The problem with this is that previously I did all of this on CIDER and Spacemacs and it didn't hitch even once.
I'll refactor my code to not use more than one /
in kw but I'll need to do a lof of refactoring for that.I added a link of this chat into this issue: https://github.com/clojure-lsp/clojure-lsp/issues/1163 I think this is connected.
yep, double quotes should cause issues on lots of libs :) in this case, https://github.com/weavejester/cljfmt, which is what clojure-lsp uses.
But it works on CIDER just fine. That's weird :thinking_face: I think you do some kind of parsing. Also your linter fails.
cider does its own formatting rule, clojure-lsp delegates to cljfmt to format, so this would be needed to be fixed there, and about the lint on clj-kondo, if @U04V15CAJ agree this should be fixed...
Yes but... https://develop.spacemacs.org/layers/+lang/clojure/README.html
> if @U04V15CAJ agree this should be fixed. Can you give a summary of "this"?
Is this one by default? Also, we would need to debug if cider is calling the exact same function of clojure-lsp.
> Can you give a summary of "this"? About making clj-kondo understand double slashes
> About making clj-kondo understand double slashes and complaining about them
There is also a comment from Alex Miller that even though CLJ supports the _/__/__
for symbols and keywords right now it's best for futureproofing to not use it.I added it into the github issue.
I used it for quite some time and I didn't have any problems. The second /
happily goes into the name of the keyword and symbols like that are allowed too. I had literally no problems with it except when I asked why LSP has problems. It works flawlessly in CIDER for CLJ -- both symbols and keywords.
Also the doc is vague on this so they probably didn't care at the time they wrote it.
But if it gets added into the linter then it's the standard (except in CIDER).
I've explained my point several times to you know. Although in some cases you might get away with it, it is not supported by Clojure. Don't do it.
My point is not to do it but figure out why it doesn't work and I know now. I already used it for several months and I'll do my refactoring. I can't do it immediately, there is quite a bit of code. It's not that I somehow can't refactor but it takes time and obviously why refactor when I didn't even know it's a thing.
I think something is off. If I run this command then the output already contains a message about my bad keyword:
clj-kondo --lint src/ | grep keyword
src/.../.../core.clj:104:1: error: Invalid keyword: my/fancy/bad-keyword.
And the version is... from last month:
clj-kondo --version
clj-kondo v2022.06.22
So why isn't it then reported on my LSP... I think something isn't lining up. Maybe that means that there are other assertions that are not taken into account?It could be a analysis error from kondo side so clojure-lsp is not showing all possible lint issues
I think that in my github issue's screenshot it's the same thing that's happening. Keyword parsing fails and it cascades into a different failure, in that case it thinks that the first value of the map has a newline inside (IMO this is what's broken).