Fork me on GitHub
#lsp
<
2023-02-06
>
pmooser12:02:27

I'm noticing when typing new code, lsp-mode is always constantly displaying errors (related to me not being done typing) in the minibuffer. Is there any way to suppress this? It's not actually (in my opinion) very helpful, but it is visually noisy and stops anything else that might appear there (from CIDER, for example, which is actually more helpful as I'm typing with how it highlights the arg list for whatever function I happen to be calling).

ericdallo12:02:02

Could you share a print of what you are seeing?

pmooser12:02:30

If I start to type a defn like this, with my cursor as shown:

pmooser12:02:58

@UKFSJSM38 This is what goes into the minibuffer:

ericdallo12:02:01

does that shows on minibuffer?

ericdallo12:02:43

I see, I didn't even know that was possible 😂 That probably happens because you don't have flycheck or flymake configured properly?

pmooser12:02:43

It's not WRONG but it's also not helping me.

pmooser12:02:55

Ah hm, that's interesting.

pmooser12:02:06

Isn't this driven by flycheck:

ericdallo12:02:12

even so, I suggest you install lsp-ui to have those warnings on your buffer like:

pmooser12:02:45

Yeah, ok - I had an inkling that if I installed lsp-UI, at least the errors would go somewhere else. I'll go ahead and do that, thank you.

pmooser12:02:20

I'll give it a try!

ericdallo12:02:35

👍 lsp-ui is cool, but some features are a little bit too much, so I suggest add:

(setq lsp-ui-doc-enable nil
      lsp-ui-peek-enable nil)

ericdallo12:02:51

all the others are already disabled by default IIRC

pmooser12:02:03

Ok thank you - I'm adding that to my use-package declaration and then I'll probably just have to customize the colors!

ericdallo12:02:30

I think the colors should work fine OOTB, they use emacs default faces for success, warning, error etc

pmooser12:02:46

@UKFSJSM38 It works as you suggested - the errors appear in the buffer itself as overlays (or whatever). Interestingly, though, and possibly not a bug, but it still stops the normal (quite helpful) display from CIDER in the minibuffer in this case.

pmooser12:02:06

So if I type this:

pmooser12:02:21

Sorry - nevermind. It is working, but not always.

pmooser12:02:34

If I manage to determine when it works and when it doesn't, I'll come back with a more useful (precise) question.

ericdallo13:02:43

I found pretty weird to show lint in the minibuffer, the default behavior without lsp-mode is not that AFAIK, I suggest you ask in the Discord server of emacs-lsp: https://discord.com/channels/789885435026604033/789890622424219658

pmooser13:02:17

Ok, thanks for the heads up - I had very limited luck asking for help there with lsp-treemacs (which I'm convinced is just broken on a number of platforms) but I'm not quite good enough yet at elisp to debug it myself.

pmooser13:02:23

I will try to post there later just in case they are interested.

pmooser13:02:34

Thanks for all the help -it's very appreciated.

👍 2
The Continium12:02:05

Hi - I am using the lsp server via nvim. When I am building clojure libraries and installing them locally e.g. lein install the change in function signature is not being picked up and I get diagnostic errors that are not correct. If I delete all the .lsp and .clj-kondo directories ( which I presume forces a recreation of any cache ) it resolves the issue. As I am developing the library I am not updating the version of the library every time I install. Should this change in the library in the local maven repo be picked up; is it a bug ? Is there a way to ask the lsp server to recreate the cache rather than having to remove them manually from the file system ?

ericdallo13:02:10

Good corner case, ATM clojure-lsp caches the sha of the project.clj, and since that would not change, it will use the cached classpath, one thing you can try to confirm that is to change anything in your project.clj, like add a space or newline and after a server restart it should work

ericdallo13:02:33

not sure how we would fix that , pretty hard to know, would need to check the sha in the .m2 or something

The Continium13:02:45

Thanks for the quick reply. The edit of the deps/project.clj + LspStop clojure_lsp + LspStart clojure_lsp works. I’m not sure how this would be done through the lsp interface but perhaps adding a manual call to make the cache stale ( reset the shah value ) would at least give a manual approach ?

ericdallo13:02:07

yeah, we fixed the last cache issue I was aware in the previous release, so this is the only one that we know that we would like to reset that cache, even so, not sure worth it. At least a issue makes sense for that if you don't mind opening it, there we could discuss fixing the root cause or other alternatives

The Continium13:02:04

sure - I’ll open one

Noah Bogart20:02:40

I filed https://github.com/clojure-lsp/clojure-lsp/issues/1489 earlier today and went ahead and fixed it, but before I open a PR, seems prudent to check if the solution I came up with is okay lol. My bug is about non-string literals in the metadata of a var: (def ^{:doc (:doc (meta #'existing-var))} target-var 789). my solution is to enable finding the documentation of the referenced var if and only if the metadata is written in this way, lol (see the picture for a demonstration)

ericdallo20:02:13

hum, not sure what if the metadata is written in this way means even checking the print, maybe sharing the draft PR would be easier :p ?

👍 2
Noah Bogart20:02:19

Yeah, I've got a simple fix and a complex fix lol

😅 2
ericdallo20:02:20

maybe doc is not only string? maybe a str would fix it already?

Noah Bogart20:02:02

The bug is that doc-line checks (when (seq doc), which doesn't actually verify the docs are a string. If markdown is enabled, docstring->formatted-markdown throws an Exception as you noted.

Noah Bogart20:02:14

the simple fix is change the check to (when (and (string? doc) (seq do)

ericdallo20:02:01

yeah, it never occurred that doc could be other than string, that's new to me hehe

ericdallo20:02:30

maybe we should confirm is doc that comes from clj-kondo should really be other things than string

Noah Bogart20:02:31

the more complex and fun fix is to check if the metadata is referencing another var's metadata and then use q/find-definition to get information about it, and check it for a doc string lol

Noah Bogart20:02:09

as you can see in the image I posted, base-var has a docstring, and then existing-var is referencing it and target-var is referencing existing-var . My PR implements tracing those references

ericdallo20:02:04

sounds cool that find-definition, so it seems to be 2 different issues: • fix the exception, show the hover as string • new feature: follow metadata docs

ericdallo20:02:43

No problem fixing in the same PR, added 2 comments there, LMK what you think

Noah Bogart20:02:12

of course, I'll fix those right up

ericdallo20:02:42

that's a nice feature, we should probably mention in the docs somewhere in features.clj I guess

Noah Bogart22:02:51

I can write some up tomorrow if you'd like

ericdallo22:02:41

Would be nice! I think a simple mention in the hover section in the features would be enough

👍 2
ericdallo15:02:57

One thing would be nice to improve is the follow arity as well, at Nubank we have hundreds of functions like:

(defn ^:private bar-impl [{:keys [a b c d]}])

(defn bar [options] ,,, (bar options))
and would be awesome to hover into (bar|) and see the bar-impl arity instead of bar, maybe we could do the same when one uses :doc (:doc (meta #'bar-impl)) ?

Noah Bogart15:02:15

hmm! that's interesting

Noah Bogart15:02:47

I've seen folks hardcode the arglists before

ericdallo15:02:29

yeah, that should fix that as well, not sure if using the same :doc field though