Fork me on GitHub
#calva
<
2022-05-16
>
pinkfrog13:05:09

I’ve a question on Calva +cljfmt. Basically Calva can read a .cljfmt.edn file, the file content is basically

{:indents {some-indents-settings}}
However, for the command
clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}}' -M -m cljfmt.main --indents indentation.clj
The expected contend of indentation.clj is {some-indents-settings} instead of the whole content {:indents xxx. My question is, how can I reuse .cljfmt.edn for both calva and the above command?

👍 1
Geoffrey Gaillard13:05:51

Sorry, I was raising my finger because I'm interested in the answer too.

pez13:05:09

This is more generally a cljfmt question, I think. It's cljfmt that specifies the cljfmt.edn shape, and also the options for the cljfmt command line. What you can do is to make a script that extracts the :indents entry and writes it to a file, then something like:

extract-indents.clj > indents.edn && clojure -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.8.0"}}}' -M -m cljfmt.main --indents indents.edn

pinkfrog13:05:10

Yup. I can only do that.

pez14:05:41

cljfmt might have an issue about it.

Ferdinand Beyer16:05:46

Not sure how VS-Code calls this feature, but is really driving me crazy. Since recently, Calva added “snippets”, so that common used forms such as defmethod expand to a form with placeholders that you can jump to using <Tab>. However, this is inconsistent with other Clojure completion, and regularly gets into my way. For example, when typing (if-, I get a menu with auto-completion for if-let, if-some, etc. I can select one and hit <Enter> or <Tab> and can continue typing. However, this breaks with forms that have a “snippet”. For example, when I select if from the list after typing (if, I will end up with the snippet expanded within the parentheses, ending up with double parentheses:

((if test-expr
 then-expr
 else-expr))
How can I turn this off?

2
pez16:05:59

I don't know where these snippets are coming from, actually. Is it clojure-lsp, @UKFSJSM38? This happens to me quite often with Rich comments. Anyone else in the <!subteam^S03BGSAUPTQ|@calva-team> have an idea what's going on?

pez16:05:51

Thanks! Do you want an issue about this? I like the help, but it seems wrong that even though the input is something like (comm) the snippet inserts ((comment)).

ericdallo16:05:12

yes, would not be a easy fix on clojure-lsp as all snippets are independent from current code context

Ferdinand Beyer16:05:09

Thanks for the support ❤️ I did not use LSP outside of what comes with Calva yet… is there maybe a way to disable snippets?

Lukas Domagala16:05:45

Yeah, the clojure-lsp snippets got recently added to calva’s autocomplete. They’ve existed for a while, but “snippets” itself had a broken lsp protocol interaction until around 2 months ago. And until a few weeks ago nrepl autocomplete was preferred over clojure-lsp, so you’d only see the snippets if you didn’t connect a repl

ericdallo16:05:21

no, ATM there is no way to disable via clojure-lsp config, but there is via client initiationOptions snippetSupport https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_completion

ericdallo16:05:13

I think we could fix the paren issue on clojure-lsp, feel free to open a issue

pez16:05:53

Sounds like there is hope! 😃

pez16:05:29

Can you file that, issue, @U031CHTGX1T? I need to go afk for some hours here.

Ferdinand Beyer16:05:44

Of course, leave that to me. And thanks again!

Lukas Domagala16:05:19

Oh and while fixing the snippet lsp protocol bug we made a design decision to not provide two versions for the things that have snippets. So if-let only exits as a snippet, not as a macro autocomplete. If we can’t find a better fix, we could change that decision. That way you could choose if you want the basic completion or the snippet.

👍 1
bringe03:05:42

@UKFSJSM38 Could we use the client/unregisterCapability request to unregister snippets after initialization? Would support for that need to be added to clojure-lsp?

bringe16:05:10

Yes we can do that already, or yes that support can be added to clojure-lsp and then we can do that?

ericdallo16:05:32

sorry, I misread the questions. ATM clojure-lsp doesn't support unregisterCapability , so we would need to add support for that, even so, a config to disable snippets may be convenient too

bringe16:05:01

I think it would be pretty awesome to have that support in clojure-lsp. Calva could then add settings to enable/disable features without a server restart, and those same settings could be used when creating the initialize request so that only the desired capabilities are enabled at server startup.

ericdallo16:05:08

yep, makes senses, and it should not be hard to implmement it I think, feel free to create one more issue about that 😂

ericdallo16:05:09

I'm still researching how to solve #982 properly, but that idea of supporing register/unregister capabilities on the fly is a nice to have

ericdallo17:05:17

@U031CHTGX1T, this should be fixed on clojure-lsp master, you can test it via #clojure-lsp-builds or wait for next release which should be soon. I managed to fix for cases like (|) or whatever that it has valid parens match, but not (| because we can't parse code properly, but I don't think this is that common as most users use paredit like features.

🙌 3
Ferdinand Beyer17:05:57

Thanks @UKFSJSM38 that’s amazing!

👍 1
bringe18:05:02

One more issue created @UKFSJSM38 😄

🔨 1
Sakib18:05:34

For are testing function I'm getting this warning ; WARNING: Use of undeclared Var forever-clojure.core/are at line 1 <cljs repl> I started a cljs node repl.

pez18:05:17

Are you requiring it?

Sakib18:05:51

Yes, This way.

(ns forever-clojure.core
  (:require [clojure.test :refer [are]]))

Sakib18:05:33

It is working as expected. Probably I didn't load the file previously. 😺

pez19:05:15

That's great to hear!

❤️ 1
pinkfrog23:05:00

Hi. This issue is probably more of the vscode side. clojure-lsp has a nice feature of lint on unused public vars. However, the lint messages are show in the problems pane in vscode. I’d like the relevant unused public vars to be only decorated (hinted) in the editor, but NOT shown in the problems pane. Way to achieve?

pinkfrog23:05:55

I am aware vscode has a filter functionality on problem pane, but yet, the problem count is not affected by this option.

ericdallo00:05:47

AFAIK not possible, the unused-public-var is in the end a diagnostic, you can customize it type, info warning or error, but it's still a diagnostic, and most editors consider it in the diagnostics count