This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-02
Channels
- # announcements (9)
- # babashka (67)
- # beginners (62)
- # bitcoin (2)
- # clara (1)
- # clj-kondo (62)
- # cljfx (6)
- # cljs-dev (25)
- # clojars (17)
- # clojure (142)
- # clojure-australia (2)
- # clojure-europe (42)
- # clojure-gamedev (2)
- # clojure-nl (31)
- # clojure-poland (10)
- # clojure-spec (14)
- # clojure-uk (30)
- # clojurescript (3)
- # conjure (1)
- # cursive (10)
- # data-science (1)
- # datascript (4)
- # datomic (9)
- # depstar (7)
- # fulcro (17)
- # girouette (15)
- # graalvm (44)
- # honeysql (20)
- # jackdaw (3)
- # jobs (8)
- # jobs-discuss (10)
- # juxt (5)
- # lein-figwheel (1)
- # lsp (175)
- # malli (19)
- # pedestal (2)
- # reagent (31)
- # reitit (2)
- # remote-jobs (3)
- # reveal (12)
- # sci (77)
- # shadow-cljs (22)
- # specter (6)
- # startup-in-a-month (2)
- # tools-deps (1)
- # xtdb (21)
I am I think having a similar issue maybe? In the same file, I see two function bodies. One follows the other:
(defn foo []
(log/error ...))
(defn bar []
(log/error ...))
For the first instance, I get unresolved var. For the second, no highlight.
It shouldn’t be unresolved.
The same thing for an @(http/post …)
in a function body.
I upgraded clj-kondo from brew, and have latest clojure-lsp installed via hombrew.We didn't change that code recently(latest releases), Could you open a issue with a reprod of clj-kondo on command line working where clojure-lsp doesn't?
I mean, on the upside, it’s kind of a repro? I don’t have the smallest reproducible case, but I assume it won’t be too difficult.
@ericdallo will include this in the report, but just FWIW: I did not update clj-kondo until after I saw this issue.
Clojure-lsp use a specific clj-kondo version(also show on clojure-lsp --version), not your clj-kondo installed
That why I suggested removing the cache files, check if you have anything on your deps.edn that may cause that
and it’s possible it has something to do with clj-kondo/config.edn’s existence? but it seems to come and go across restarts + clearing of the cache and sqlite db
It looks like if I remove my .clj-kondo directory (and by extension its config.edn), that fixes it.
anyway, updated the repro steps. please let me know if I can be of any help in testing. (DM generally works better)
What is *clj
for? (I found that filtering without this doesn't filter at all)
Clojure-LSP uses clj-kondo so you will get the same diagnostics (provided LSP calls clj-kondo correctly, there have been some problems)
Hm, homebrew reports that the latest version of clojure-lsp is still 2021.02.24-14.23.08
Eric Dallo told me yesterday that automagically updating the homebrew package failed. FWIW, I always do this manually for my packages.
Yeah I'm going to download the binary from Github, just wanted to let someone know. How amazing is that we have binaries for this, BTW...
@orestis Of course I have scripts for this, but it's a manual action which takes me about 10 seconds
This is relatively nothing compared to the time that goes into a developing the release
@orestis I bumped clojure-lsp tap, you can now install latest via homebrew, I'll work on the auto bump soon
An obvious thing I’m seeing using lsp for diagnostics is that it frequently gets out of sync or stops producing diagnostics. Of course the neovim client is alpha so perhaps there’s more work to be done there...
This can be a "too many open files" problem, I'm also seeing this sometimes in emacs
Also I’m not sure how well Clojure-lsp handles multiple clients at the same time on the same project?
wasn't clojure-lsp killing itself after some time of inactivity @ericdallo?
I would much prefer for now to launch the lsp server manually and see the diagnostics in my console.
or disable diagnostics in lsp-mode and use clj-kondo proper (this is what I'm doing)
Not sure, never had a problem like that, but I know Calva already had the same issue
Also the gets of sync looks a odd issue, we really would need some kind of repro I think
The file watch is just for lsp-mode watch changes on all those files, should not kill anything
in any way, I think this is causing the error I'm seeing, because when I killall clojure-lsp
it works again
No, imagine something else change a file that is not open on Emacs, with file watch, lsp-mod e will know that and warn lap server. But when you open a file in Emacs, lsp-mod e will manage it anyway
So the file watch is just something more, but not related with lsp in a single file
I think you can just set to nil lsp-file-watch-ignored
or something, let me confirm
Git file changes I think it's a example, but I think restarting lsp should fix it though
So just to get it clear, it’s the editor that notifies the LSP server about file changes?
So the server is the one with access to the filesystem? Or does the client sends chunks of text that have changed to the server?
Yes, both, but for changes like that, the responsibility is from the client to watch for the file changes
So currently I have a "stuck" lsp server. How can I best debug to see what might be up? /tmp/clojure-lsp...
isn't showing up.
clojure-lsp.main.LSPTextDocumentService/didChange main.clj: 117
clojure-lsp.handlers/did-change handlers.clj: 58
clojure-lsp.feature.file-management/did-change file_management.clj: 119
clojure.core/reduce core.clj: 6833
clojure.core.protocols/fn/G protocols.clj: 13
clojure.core.protocols/fn protocols.clj: 75
clojure.core.protocols/seq-reduce protocols.clj: 31
clojure.core.protocols/fn/G protocols.clj: 19
clojure.core.protocols/fn protocols.clj: 136
...
clojure-lsp.feature.file-management/did-change/fn file_management.clj: 122
clojure-lsp.feature.file-management/replace-text file_management.clj: 96
clojure-lsp.feature.file-management/offsets file_management.clj: 82
...
java.lang.NullPointerException:
Yeah, it seems a issue on the replace text logic, please open a issue with a minimal repro
So it seems like what's happened is because the didChange handler isn't working, the file gets out of sync, then everything else seems to be working but on the wrong text 😄
The file gets out of sync indeed, but nothing related with file watches, but related with a recent change where we introduced incremental text changes
I can reproduce this consistently with a specific file. I see a lot of debug messages like so:
2021-03-02T19:24:23.733Z frosty.local DEBUG [clojure-lsp.crawler:142] - Cannot find position data when analysing fn* {:name fn*, :filename "/Users/orestis/dev/nosco/nosco-gamma/cljs/nosco/views/idea_single.cljs", :from nosco.views.idea-single, :col nil, :from-var IdeaNavigation, :arity 2, :bucket :var-usages, :row nil, :to cljs.core} nil
that message is not related with the issue, is just a log that I need to avoid logging unecessary
I restart the server, attach a new client, add a new empty line to the file, hit save... boom.
It's not exactly minimal, it's a big file I have here. I can probably attach it though?
All I can offer is that it's the didChange handler, and AFAICT from neovim, it's sending always the entire file down the pipes...
hum, it could be a issue with neovim if does not support the incremental text changes
[ DEBUG ] 2021-03-02T20:38:52+0100 ] ...im/HEAD-dc3ca16_1/share/nvim/runtime/lua/vim/lsp/rpc.lua:388 ] "rpc.send.payload" { jsonrpc = "2.0", method = "textDocument/didChange", params = { contentChanges = { { text = '(ns nosco.react)\n\n\n(defmacro forward-ref!\n "Takes a component symbol and updates the definition with React.forwardRef,\n preserving metadata on the component var."\n [component]\n `(set! ~component (.forwardRef nosco.react/React ~component)))\n\n\n' } }, textDocument = { uri = "file:///Users/orestis/dev/nosco/nosco-gamma/cljs/nosco/react.clj", version = 3 } }}
Here's the command that neovim sends on the change. It's the entire text of the buffer.
Hope it gives some light. I'll be off to bed now.. thanks for your time on this project! Please apply for clj-together funding 🙂
I already applied 🤞 😄 It helps, I think clojure-lsp is not considering the full text, I'll take a look on this later today, thanks 👋!
Hi, I think https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/feature/file_management.clj#L119 might be the piece of code in charge, it expects a range of changed characters. I will see if I can get LSP running locally so that I can confirm and submit a PR, it might be tomorrow though.
Yes, it is, that was changed recently, probably we are having some race condition on there, we need to check how vim is sending the didChange texts
I think the issue might be simpler: NeoVim doesn't send a start/range at all because it's sending the entire text. So replace-text
is getting nil values in line
, col
, end-line
, end-col
and throws the NPE
It could be indeed, but even so I think it should send the position according to the LSP spec
I did a small POC locally and indeed it throws an NPE, and of course the fix is trivial -- I will try tomorrow to run LSP locally so I can verify that this is indeed happening and add a test.
/**
* An event describing a change to a text document. If range and rangeLength are
* omitted the new text is considered to be the full content of the document.
*/
The client should respect the incremental sync but it seems like it doesn't... but I guess that yeah supporting that on the server is easy enough...
yes, probably handling the didChange as full text when the range is not present seems a valid approach
If you could capture somewhere the format that the emacs lsp client sends the changes I might be able to provide a test that covers both cases... But not tonight.
Any more action needed on my part? I think testing on Emacs is the blocker here. I've setup NeoVim to run my local fork of clojure-lsp so if something like this comes up again it'll be easy to validate.
Sure, for a range this is a sample:
(ns foo)
(let [a 1
b 2]
(+ a b))
[Trace - 04:30:39 PM] Sending notification 'textDocument/didChange'.
Params: {
"textDocument": {
"uri": "file:///home/greg/dev/nu/zakarum/postman/integration/aux/init.clj",
"version": 55
},
"contentChanges": [
{
"range": {
"start": {
"line": 4,
"character": 7
},
"end": {
"line": 4,
"character": 8
}
},
"rangeLength": 1,
"text": "c"
}
]
}
changing it to
(ns foo)
(let [a 1
b 2]
(+ a c))
I can test manually the PR tonight (couple of hours), if everything ok, I can merge it
@ericdallo @borkdude thanks to both of you for looking into that issue I created. My bad on the unresolved vars linting! Probably a silly question, but is there any way to like… help automate the creation of :lint-as
entries? (Perhaps this is a question better asked in #clj-kondo but)
it's a feature I already thought about it, it'd be a clojure-lsp responsibility I think
like, if I see a situation where I need to add a :lint-as, having an easier way to stub it in my clj-kondo/config.edn would be nice. in addition, it would be sweet to be able to select from already understood options
Yeah, I think if we could know what is the clj-kondo file used, we could have some kind of code action: Lint as def
or Lint as defn
additionally, some shared repository of common lint-as entries would be nice. i guess it’s kind of like externs or something at that point?
one more improvement, clj-kondo could report the finding with some metadata, like suggested lint-as
That's one of the coolest features from Cursive IMO, it'd be really cool to have something like that
one last pie in the sky scenario that would be rad: i often kind of stumble around a project, finding them one at a time. that’s kind of why i mentioned some kind of “stub them all” command.
or leave them stubbed, but at least there’s a map of what i have provided lint info for vs what i haven’t
As for: > suggested lint-as You guess is as good as mine. If clj-kondo could make this suggestion it might just already lint it like that.
eh, i suppose that’s harder than it looks…
for instance, you wouldn’t want to create lint-as entries for http/get, http/post, etc. since the lint-as {org.httpkit.client/defreq clojure.core/def}
is the actual solution
yes, but that's how cursive suggests I think, it suggests to lint as def or defn or a custom one(?)
yes, I think it's good to have a repo for that, but it's better to make the IDE fix for you. Not sure, only saw folks from work using it
do i understand correctly that maintainers of libs /could/ provide linting definitions as part of their artifacts?
> Currently this is only supported for a hard-coded list of namespaces for projects which are known to be problematic. If your project uses one of these namespaces, Cursive will prompt you with a notification:
this probably is another future step, I think just suggesting the basic lint as could be really cool/helpful
back to borkdude’s point about just submitting the lint-as defs to maintainers or to the central repo
@U06DQC6MA You can read about that here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration