Fork me on GitHub
#lsp
<
2021-07-02
>
Akiz11:07:43

Hi, I have just created a valid function which is wrongly parsed by lsp.

(defn send-to-slack [message]
  (let [command (clojure.string/join " " ["curl" "-i" "-X" "POST" "-H" "\\"Content-Type: application/json\\"" "-d" (str "'{\\"text\\":\\"" message "\\"}'") slack-uri])]
    (shell/sh "sh" "-c" command)))
It seems valid to Emacs once i change \\ to \ but then it fails during execution… Should I ignore warnings or there is some workaround?

ericdallo12:07:37

That looks wrong with the double slashes, I'd guess

ericdallo12:07:12

The warnings from clj-kondo are pretty reliable, not sure if it's a issue there

👍 2
ericdallo12:07:25

@U04V15CAJ may know what's is the correct here

borkdude12:07:26

why are you escaping it like this?

borkdude12:07:35

if it's related to a Windows-specific bug... try babashka.process instead, it will apply that fix automatically without escaping

👍 4
borkdude12:07:15

btw, if I eval this code from a file:

(require '[clojure.string]
         '[clojure.java.shell :as shell])

(defn send-to-slack [slack-uri message]
  (let [command (clojure.string/join " " ["curl" "-i" "-X" "POST" "-H" "\\"Content-Type: application/json\\"" "-d" (str "'{\\"text\\":\\"" message "\\"}'") slack-uri])]
    (shell/sh "sh" "-c" command)))

borkdude12:07:21

it seems to be incorrect as well

borkdude12:07:30

Syntax error reading source at (REPL:5:89).
Invalid token: Content-Type:

borkdude12:07:46

You might need an extra \ in front of those double \\s

☝️ 4
Akiz12:07:32

Oh, you are right, thanks. It is a specific problem in evaluating BB in org mode… There is no other way how can evaluate this script - this is why, it took me some time to construct this 🙂. I have yet to find a way how to keep this code consistent between .org and .clj.

borkdude13:07:33

@UBRV1HXPD Is this the org-mode stuff from Adam?

👍 4
borkdude13:07:52

On his stream yesterday he discovered that it accidentally quotes strings the wrong way. I think he's going to fix it soon

borkdude13:07:04

You might want to follow up on the discussions forum

Akiz13:07:53

Ha, thanks. I will check that elisp.

Akiz13:07:54

@U04V15CAJ I am still not able to get this to work in BB REPL. Once the command seems parsed correctly it fails during execution. Should I move to babashka/process? Thanks

borkdude13:07:31

Is this on Windows?

borkdude13:07:41

Then probably yes

Akiz13:07:22

No, using babashka in zsh on macos. And I am going to deploy this script on old unsuported centOS too…

borkdude13:07:05

ok, please start another thread in #babashka then, where we can discuss what's going wrong.

💯 4
borkdude13:07:23

I'm kind of busy now, but perhaps someone else can help meanwhile

👍 4
Joshua Suskalo21:07:16

So I'm just trying out clojure lsp for the first time on a machine that can actually run it, and it's looking pretty cool so far! One question: I have hooks set up with clj-kondo to resolve a particular macro, but it appears that clojure-lsp isn't recognizing that hook and is giving me a warning about an unresolved macro. Is there some configuration I need to add to have it pay attention to the clj-kondo config?

ericdallo21:07:32

Hey, glad to hear you are liking :)

ericdallo21:07:09

Yeah, it should work the same as using clj-kondo, unless you have a outdated .clj-kondo/.cache folder?

ericdallo21:07:43

Do you have a .clj-kondo folder?

Joshua Suskalo21:07:05

Yup, it has the hooks that I configured. I've been using clj-kondo with spacemacs for a while and it was all working correctly.

Joshua Suskalo21:07:31

I'm now trying out doom for a bit and got the lsp set up and it's complaining about stuff I already have configured.

ericdallo21:07:08

Hum, could you try removing .clj-kondo/.cache folder?

ericdallo21:07:58

If that doesn't work, could you try removing .lsp/sqlite.db?

Joshua Suskalo21:07:42

same issue. I can try removing the sqlitedb though

Joshua Suskalo21:07:02

reindexed after restarting the workspace and has the same issue

Joshua Suskalo21:07:36

If I run clj-kondo from the commandline I get no warning for the macro either.

ericdallo21:07:38

That's odd, any errors on the clojure-lsp log?

ericdallo21:07:20

You can get it via the :log-path of the return of lsp-clojure-server-info

Joshua Suskalo21:07:29

Jul 02, 2021 4:44:30 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint handleCancellation
WARNING: Unmatched cancel notification for request id 433
This is everything I have in my stderr buffer

ericdallo21:07:47

Not that one

Joshua Suskalo21:07:54

Okay, looks like there's a lot going on in there

ericdallo21:07:34

maybe it's better to restart the project and get the new log to avoid to much noise

Joshua Suskalo21:07:12

The only thing logged at an ERROR level is clojure-lsp crawler saying it imported some of my config to the clj-kondo folder

ericdallo21:07:35

as ERROR level? that's odd

Joshua Suskalo21:07:40

yeah, it was weird

ericdallo21:07:51

could you paste it here?

Joshua Suskalo21:07:41

2021-07-02T21:44:07.948Z iris-joshua ERROR [clojure-lsp.crawler:79] - Imported config to .clj-kondo/org.suskalo/farolero. To activate, add "org.suskalo/farolero" to :config-paths in .clj-kondo/config.edn.

Joshua Suskalo21:07:44

That's the only error

Joshua Suskalo21:07:56

Lots of stuff is logged at debug level saying invalid clj-kondo finding

ericdallo21:07:14

that's okay, let me check that error

ericdallo21:07:49

oh, the level is wrong on the code, but that is the return of a clj-kondo log

ericdallo21:07:09

odd, everything seems correct, and I use hooks with clojure-lsp and they work fine

ericdallo21:07:17

could you try to make a minimal repro?

ericdallo21:07:28

a repo with minimal macro and the hook

Joshua Suskalo21:07:01

Sure, I could try, but I probably won't have time for it today.

ericdallo21:07:18

no problem, I can test it on my side when you have the repro

borkdude21:07:23

it should work right out of the box