Fork me on GitHub
#calva
<
2022-04-15
>
pinkfrog08:04:15

By clicking following to definition, vscode shows a library file, cljs.core.async.interop, how can I see other files under the same directory?

pez11:04:19

There's no way that I know of. We could show where the jar is in the hover, but from there the user would need to figure out the next steps.

pinkfrog14:04:09

Cursive with intellij shows the lib, so can easily navigate the lib files

pez14:04:27

Cursive is awesome when working with any Java stuff, and IntelliJ has full citizen support for jar files.

pinkfrog09:04:00

better it would be possible to turn on breadcrumbs for library files

🧵 3
janezj12:04:19

I would like that code is not so widely indented when function names are very long and html tree is deep. What is the best solution,

(sui/ui-grid {:columns 2}
                  (sui/ui-grid-row {}
                                   (sui/ui-grid-column {:width 12}
                                                       (div {:style {:width "500px
I don't like that first param is always in a new line.
(sui/ui-grid
      {:columns 2}
      (sui/ui-grid-row
       {}
       (sui/ui-grid-column
        {:width 12}

pez12:04:15

I think I'd like

(sui/ui-grid {:columns 2}
       (sui/ui-grid-row {}
         (sui/ui-grid-column {:width 12}
           ...)))

👍 2
janezj12:04:47

Me too, Is there an elegant way to configure the formatter?

pez12:04:47

Something like so in whatever file you have configured in calva.fmt.configPath:

{:indents {#"sui/ui-grid.*" [[:inner 0]]}
 :test-code (sui/ui-grid {:columns 2}
              (sui/ui-grid-row {}
                (sui/ui-grid-column {:width 12}
                  ...)))}
I'm not super savvy with cljfmt config, though. I'd check out https://github.com/weavejester/cljfmt.

👀 2
pez12:04:35

As https://calva.io/formatting/ mentions, if you have the cljfmt config file in the workspace, you'll enjoy hot reload. So you can experiment with the settings and reformat the config file itself to check what happens. That's why there's a :test-code entry in my example.

janezj13:04:40

I read this in the user guide about cljfmt, but just don't want to invent my style. It seems i would have too. I was hoping that there is a way to turn on some common and widely accepted style.

pez13:04:20

The default is the most common and widely accepted style. You can also go for https://tonsky.me/blog/clojurefmt/, which is also common, but slightly controversial:

{:indents ^:replace {#"^." [[:inner 0]]}
 :test-code [(sui/ui-grid {:columns 2}
               (sui/ui-grid-row {}
                 (sui/ui-grid-column {:width 12}
                   ...)))
             (let [foo bar]
               (str "foo"
                 "bar"))]}

👀 2
janezj21:04:40

You are working on large projects, so the formatting style is usually defined per project?

pez05:04:17

Indeed. If many people are involved is common to bring down diff noise by enforcing project wide formatting.

Lukas Domagala14:04:35

Hey Calva friends, I finally managed to finish adding the https://github.com/BetterThanTomorrow/calva/issues/1498 locations from lsp and nrepl. If anyone wants to help test it, here’s the preview https://output.circle-artifacts.com/output/job/9b33bd43-135b-46b2-8a3b-478b86cc6250/artifacts/0/tmp/artifacts/calva-2.0.267-pull-1596-a73d9071.vsix. It shouldn’t break anything, but any performance might be worse. Thanks for helping out!

🚀 3
💜 3
clojure-lsp 3
calva 4
☝️ 1
1
pez15:04:48

Calva friends should note that this feature is already in dev, so it will reach all users next time we cut a release, which is later today or tomorrow. So please consider giving the build a spin and help us catch any (unlikely) reasons to hold off the release.

pez15:04:39

Thanks for doing this work, @domagala.lukas! gratitude 🙏 ❤️ I love how you apply just the right solution to a problem that has been bothering us (maintainers as well as users) for very long, mainly because we haven't figured out a good solution.

💜 2
3
❤️ 1
bringe00:04:01

Is there documentation about this feature?

pez04:04:58

No, not sure what we would say. We’re changing internal things.

bringe18:04:41

> but we could provide an options map that lets users decide which provider is used. This lead me to believe there was maybe some user setting involved.

bringe18:04:09

And I was wondering what configuring the setting would look like.

Lukas Domagala19:04:52

@U9A1RLFNV I’ve added the possibility of options, but there’s no way to set them yet. The hope is that the default will be good for everyone, but if it isn’t we can expose them.

👍 1
bringe19:04:07

Sounds good

Jack Arrington15:04:31

Is there any way in Calva to collapse (fold) all the rich comments in a file? I enjoy using them for REPL-driven workflow, but occasionally I just want to view the rest of the code without clutter, and it'd be nice to have a quick way to minimize them all without doing each one manually

1
Cora (she/her)15:04:34

That would be a great addition to calva! I don't think there's a way to do it right now. you can run Fold from the command palette but that's super manual

pez15:04:16

There's an extension Fold Plus that almost does this. You can have the cursor on comment somewhere in the file and it will fold all forms that has comment in them. Obviously will fold some other stuff as well, but maybe we should contribute to that extension to add the missing pieces?

1
Cora (she/her)15:04:11

I love not having to recreate the wheel!

pez15:04:34

Also, I just tried, with Fold Plus, if you select (comment and then use the command, it will be quite more precise with what is folded.

❤️ 1
andy.fingerhut16:04:14

Is this channel a reasonable place to ask about clojure-lsp implementation/behavior? My purpose in asking is to learn enough to find out whether I want to tackle writing an LSP for a different language than Clojure, so perhaps not the most Clojure-relevant line of questions, let alone Calva.

ericdallo16:04:55

I think so, or #lsp

andy.fingerhut16:04:23

Huh, I just tried searching for channels with "lsp" in their name and somehow missed that. I'll ask there.

👍 1
andy.fingerhut16:04:52

Doh. Didn't finish the search properly. I see it now.

Serafeim Papastefanos19:04:29

Hello friends! can somebody explain to me what would Clover (https://marketplace.visualstudio.com/items?itemName=mauricioszabo.clover) offer me over Calva ? (if it offers anything at all)

leifericf19:04:06

@U3Y18N0UC probably knows 😊

seancorfield19:04:16

I use Clover + Calva. Clover is for use with a Socket REPL -- instead of using nREPL/CIDER, which is essentially what Calva uses for a REPL connection.

seancorfield19:04:06

So I have the nREPL UI disabled in Calva (its a setting) and rely on Calva for all the static stuff: paredit, code insight, syntax coloring, LSP analysis, clj-kondo linting, etc.

💡 1
seancorfield19:04:34

Then I use Clover for the dynamic stuff: Socket REPL connection, evaluation of code, running tests, etc.

💡 1
seancorfield19:04:42

Why do I use Clover for that instead of just what is built into Calva? • I run Socket REPLs in a lot of my Clojure processes -- even in production • Using a Socket REPL is built into Clojure -- no dependencies are needed • You can tell any Clojure process to start a Socket REPL automatically via a JVM property at process startup • I want the same editing experience regardless of whether I'm working with a local process or a remote process

💡 2
today-i-learned 1
seancorfield19:04:24

The other thing I really like about Clover is that you can customize it via ClojureScript: here's my Clover configuration file https://github.com/seancorfield/vscode-clover-setup/blob/develop/config.cljs

👀 2
seancorfield19:04:03

I use tap> extensively because I also use the Portal extension for VS Code.

seancorfield19:04:01

That config also includes code to open JavaDocs and ClojureDocs directly inside VS Code in a web browser panel. There's also code to call add-libs (from a branch of tools.deps.alpha to dynamically load new dependencies into a running REPL -- so I update my deps.edn file and highlight the hash map containing the dependencies and then ctrl-; shift-a and those new libraries are loaded into my REPL without a restart.

Serafeim Papastefanos19:04:02

thank you very much for the thorough explanation !

👍 1
seancorfield19:04:34

I have a couple of videos on my YouTube channel showing my workflow with Atom + Chlorine + Cognitect's REBL which is overall pretty similar to how I now work with VS Code + Clover + Portal (Chlorine is the original version of Clover -- a lot of the same core code is shared between the two different editor plugins).

wow 1
👀 1
seancorfield19:04:56

A long video of my REPL-Driven Development workflow is shown in this London Clojurians presentation: https://www.youtube.com/watch?v=gIoadGfm5T8

thanks3 2
👀 2
Serafeim Papastefanos19:04:22

thank you @U04V70XH6 i'll put it on my to-watch list 🙂

seancorfield19:04:55

Feel free to DM me with any Qs you have while/after watching it!

🙌 1
mauricio.szabo20:04:26

Also, Clover does have some somewhat unexplored ways of customizing the way you render your results. You can see some of the work here, on my presentation on Spock, where I do render a chessboard as a result of my code evaluation instead of printing the raw EDN data: https://youtu.be/_8z1r8KV9uk?t=1052 I'm using Chlorine on the presentation, but it works on Clover too (as Sean said, they are essentially the same plug-in, with the exception that Chlorine can render results inline, and Clover can't because of VSCode limitations)

👀 2
leifericf21:04:41

@U3Y18N0UC Oh, that’s cool! Spock looks incredible, too. Is it similar to core.logic and miniKanren? I have yet to explore logic programming. It blows my mind.

mauricio.szabo21:04:54

Well, yes and no. Spock is a wrapper over SWI Prolog, so in a way, it's a real prolog programming language inside Clojure. This makes it a little bit hard to coordinate things, but also is a pure-data approach to calling prolog, so it does not depends on macros like core.logic. It's also orders of magnitude faster too (SWI Prolog - there's also an implementation over TuProlog, and that's WAY slower)

💡 1
manas_marthi16:04:40

Hi @U04V70XH6 I am watching the youtube talk you shared. I copied the your dot-clojure deps.edn and tools folder to my .clojure folder. Got hit by a blocker at the first command. Pls advise if I missed anything

WARNING: Specified aliases are undeclared and are not being used: [:new]

seancorfield16:04:56

That repo has a big disclaimer that it changes all the time. Some aliases have been replaced by tools so it's clojure -Tnew ...

😁 1
seancorfield16:04:00

You'll need the tools folder from that repo merged with yours, not just the deps.edn file

seancorfield16:04:17

And make sure your CLI is up to date! I update my dev setup all the time to make it more effective for me.

manas_marthi16:04:15

Noted thank you. I copied tools folder as well

seancorfield16:04:32

I think the readme has examples of using the tools that replaced the aliases?

manas_marthi17:04:23

$ clojure -Tclj-new create :template application :name cloverclj2/core

Failed with (underlying error, possibly from Maven):
    Failed to resolve version for application:lein-template:jar:RELEASE: Could not find metadata application:lein-template/maven-metadata.xml in local (/home/manas/.m2/repository)

Execution error (ExceptionInfo) at clj-new.helpers/resolve-remote-template (helpers.clj:176).
Could not locate the artifact for template: application
        Tried coordinates:
                {application/clj-template #:mvn{:version "RELEASE"}}
                [application/boot-template "RELEASE"]
                [application/lein-template "RELEASE"]

For more detail, enable verbose logging with :verbose 1, 2, or 3
Got hit by something else. The deprecated RELEASE maven option is used somewhere This did the trick

seancorfield23:04:48

No idea where you got application from? The clj-new README says clojure -Tclj-new app :name myname/myapp

seancorfield23:04:57

(! 797)-> clojure -Tclj-new app :name cloverclj2/core
Generating a project called core based on the 'app' template.
# or if you want to use the long form:
(! 798)-> clojure -Tclj-new create :template app :name cloverclj2/core2
Generating a project called core2 based on the 'app' template.
# or use the newer, simpler deps-new version if you don't need Leiningen templates:
(! 799)-> clojure -Tnew app :name cloverclj2/core3
Creating project from org.corfield.new/app in core3

andy.fingerhut22:04:34

In Calva, I have successfully used F12 (probably default keybindings?) for "Go to definition" on a Clojure function name, and then another keybinding to go back to the previous place in the code, and that even seems to "nest" multiple levels, which is nice. Does anyone know if there is a way on "Go to definition" to cause it to go to the definition in a separate pane or window, leaving the original calling location still visible on the screen? If that were a separate menu item or key binding from the default "Go to definition" behavior, so you could pick which behavior you wanted with different key bindings, that would probably be ideal.

Lukas Domagala00:04:35

I don’t know of a command that does that. Maybe “peek definition” does most of what you need?

rayat02:04:24

It's something like cmd + F12 or some variant of the modifier keys, lmk if that works for ya

andy.fingerhut03:04:57

On a mac, Cmd-Option-Click on the name of a function opened the definition in a separate window.

andy.fingerhut03:04:28

I couldn't find any variation of (modifiers) + F12 that did so, but I'm guessing lots of this is configurable.

andy.fingerhut03:04:54

Not exactly what I was asking for, but very similar. Option+F12 does "Peek definition", which pops up something that I don't know what to call it, but maybe a "sub-window"? That can be scrolled within, and press Escape key to remove it.

pez04:04:10

Key bindings are very configurable. Cmd+K, Cmd+S brings up a bindings editor.

pez04:04:02

Personally I have a strong distaste for those peek widgets.

😆 1
rayat04:04:30

@U0CMVHBL2 is opening the def in another window not what you're looking for?

andy.fingerhut04:04:42

Both peek and opening in another window are both useful to know about. Thanks.

🎉 1
andy.fingerhut04:04:58

Is there a way to look at bindings for clicking on things, or to change the behavior of what clicks-with-various-modifier keys do? I see the way to customize key bindings that do not involve clicks, but it isn't clear if modifiers+clicks can be redefined.

rayat05:04:08

Yeah not exactly that I know of unfortunately. You can swap which modifier key does the Go To between cmd and opt if you want though lol