Fork me on GitHub
#calva
<
2022-01-18
>
Yuner Bekir09:01:44

Hello guys! I have the following issue in the main project. When I try to evaluate anything in the repl it gets stuck, for example see image. But if I create a new project the repl runs without any problems. I can still evaluate the page and any function calls will not get stuck.

pez09:01:27

Hi! Do things get stuck even if you don't use the output window for evaluating things? Like if you close the output window and evaluate things in the files. Trying to see if we can isolate the problem some. Also please check the nREPL log (there is a command for enabling this).

Yuner Bekir09:01:33

tried closing the window and evaluating single line calls got stuck. I opened the nREPL log, nothing useful there

Yuner Bekir09:01:18

Would it be possible for it to fail silently? Because of a broken dependency in the project or something similar. It was working fine till a reset catch up

pez10:01:31

So, the messages are sent, but no answer is received... Something can definitely be failing silently. Does it work if you check out the code before you did the catch-up?

Yuner Bekir10:01:30

I checked out the code before the failing, it wasn't working. Then I restarted vs code, it started working, after that I caught up with the latest changes and it started working. So the issue was with vs code

pez10:01:18

This has started to happen a lot lately... Thanks for updating!

Yuner Bekir10:01:16

You are welcome 🙂

pinkfrog09:01:19

Is it possible to wrap a list with extra space in between? For example

(| (some-list) ), 
instead of
(|(some-list))
The reason is that, by leaving extra space, things like auto-suggestion won’t interfere with the adjacent (. E.g.,
(some-text| (some-list))
instead of
(some-text|(some-list))

pez10:01:37

Not sure I understand the full problem. But here is a maybe way:

|(some-list)
Type (some
(some|)(some-list)
Paredit Slurp forward
(some| (some-list))

pez10:01:12

(Edited with the actual suggestion now 😄)

pinkfrog11:01:04

Thanks. That somehow solves the problem. Yet, just to confirm, we cannot wrap with extra space for the moment right?

pinkfrog11:01:07

Another use case which the above example fails to solve is

1. (some-java-instance)
2. (.method)(some-java-instance)
3. (.method some-java-instance)
When typing .method, there is no way to auto-complete it.

pez11:01:01

It should. But there is some issue with the Java interop support.

pinkfrog14:01:38

> It should. But there is some issue with the Java interop support. When youa are in step2 typing the .method part, why does the java completion work? the some-java-instance is in another s expression though.

pez15:01:29

I'm confused now. I though you said there was no way to auto-complete it.

pez15:01:22

Hmmm, maybe if you post some screen shots this will be easier to follow.

pinkfrog15:01:55

> I’m confused now. I though you said there was no way to auto-complete it. Yeah. I was saying there was no way to auto complete it.

pinkfrog15:01:18

Actually, how do you write in this case to get the auto completion?

pez15:01:50

You also say: > When youa are in step2 typing the .method part, why does the java completion work? Which is why I am confused. 😃

pinkfrog15:01:07

> It should. But there is some issue with the Java interop support. Aha. I was referring to your reply it should. Thought it should be it shouldn't indeed.

pez15:01:59

Or, related... that is the current issue we have where you can add datapoints and questions around java completion.

pinkfrog15:01:57

But back to my input issue, I am interested to know how you type java methods.

pez15:01:28

What's different with them from any other call, for you? (Except completions not working.)

pinkfrog23:01:23

> What’s different with them from any other call, for you? (Except completions not working.) No difference other than completion. I ask this question because I want to find out a proper way of inputing the s expression so that I can have auto completion (provided the nrepl / calva backed for java interop is functioning).

pez05:01:49

There is some issue with Java completion. I don’t quite understand what it is.

puzzler12:01:02

Hi, I'm just giving Calva a spin, and I'm on Windows. 1. When I tried to run the recommended Getting Started REPL, I got an error. I get the impression that it is a known bug on Windows, correct? 2. I couldn't find any way to create a project from within Calva. It looks like you need to create a project using an external tool, and then you can open the file in Calva. Is that correct? 3. When I first created a REPL and jacked-in, the namespace was displayed with odd boxes around the colon and space characters in the ns. I had to hover over the boxes and disable them in the settings (it was boxing them , it said, because they were non-standard unicode characters). Is it normal for these boxes to be present by default? If so, why? 4. I tried to disable paredit in the settings by disabling the paredit keymap, and unchecking the box to have paredit commands override the VS Code commands. Despite making those changes, when I type ( a corresponding ) appears. How can I turn that off? 5. I called a function that returned a long list. The output window displayed it on one long line that scrolled way off to the side, rather than inserting linebreaks to display the list vertically. I checked the user guide and it claims that the default printer is pprint with a line-width of 40, but this is definitely not the behavior I'm seeing. What is the actual default? 6. Any other "These are the first settings you should change..." suggestions? Thanks.

pez13:01:24

Hello! 1. A bug in some Java installs on Windows. Should work with Java 16 and up (maybe 17, i don't remember). 2. Correct. 3. https://github.com/BetterThanTomorrow/calva/issues/1475 4. It's not paredit. It is a VS Code setting. (And you are not disabling paredit, just making it hard to use it, FYI.) 5. Something is broken with the defaults. Set calva.prettyPrintingOptions -> printEngine to pprint (or any option you fancy) 6. Not from me. I created most of the defaults. 😃

Lukas Domagala13:01:32

@U0ETXRFEW 2. Is this something we want to address at some point? I think its pretty hard for a beginner to go from the “getting started repl” to a working project, especially if they choose deps.edn

puzzler13:01:43

What do you mean when you say that you're not disabling paredit, just making it hard to use it? So it's always active and you just won't have any keys to manipulate the forms?

pez13:01:30

@U02EMBDU2JU I think it is reasonable to expect of programmers that they will be able to follow the instructions on http://clojure.org about how to create a project. That said, I have been thinking a bit about smoothing the path for the beginner while they are mainly exploring.: • With some rather small tweaks, we can make the getting started REPLs do a bit of this. Today they create small starter projects in the temp directory of the computer. We could tweak that so that the user can create them in some location of their choice. Things are a bit prepared for this by these repls being defined in a separate repository. Though, I haven't found a configuration format I want to start scaling it yet. • I also have been looking into making a Gitpod prepared template repository that has babashka, deps-new, clj-new, shadow-cljs, etcetera and a combination of Calva support and instructions to easily get your first projects going. A combination of those might also work, and there are possibly other tools to consider. It is a matter of priorities and that someone has enough time to focus on this for a while, because it really needs hammocking a lot.

puzzler13:01:58

I think I found the setting for auto-close brackets. It is currently set to "languageDefined", which suggests to me that it is getting the setting from Calva, but I gather that's not the case from what you said. So if I turn off the auto-close bracket, is it going to wreak havoc with the built-in paredit?

pez13:01:24

Calva is providing defaults for that setting in the "[clojure]" scope of VS Code settings. Depending on wether you want autoclosing brackets in other languages or not, you might want to tweak just that clojure-scoped setting. (Type clojure in settings.json and accept the completion/snippet suggestion and you will get all defaults inserted and can tweak this.) No, won't wreak havoc with paredit. Paredit is mostly an on-demand feature so as long as you don't use the Paredit commands you are not using it.

puzzler15:01:32

That page doesn't say what the possible settings are for auto closing brackets and quotes other than "always". Is the opposite "never"? Is there any other setting between those extremes? Thanks.

puzzler15:01:24

I tried disabling it for all languages in the settings, but it didn't seem to make any difference.

pez15:01:39

There are some other notches, but I don't recall which ones right now. They probably are the same as for the general setting. VS Code will help you with the options in the json editor.

pez15:01:40

Might be that the clojure scope overrides the general setting. You can test that by seeing how it behaves in some other language. Removing it from the clojure scope should let you control it with the general setting. (Or tweak the clojure scope one).

vemv16:01:20

In case you're interested, enrich-classpath finally has an answer for tools.deps compatibility https://github.com/clojure-emacs/enrich-classpath/commit/8751d73f809d6207c34b1c1c3e78082daff626ac it boils down to a .sh wrapper around clojure . Could be a babashka script as well for Windows compat, I left it out of mvp for now. Full release within a few days, it also will need some QAing between Emacs users. LMK if it's something you'd keep on the radar, there's Go to definition sometimes works for Java sources #1436 but perhaps not an issue specific to this possible integration

🙏 1
🎉 3
pez16:01:18

Oh, yes, I want to follow this. I created an issue for it now. https://github.com/BetterThanTomorrow/calva/issues/1486 P

🍻 1
sashton20:01:48

Is it possible to re-trigger lsp/`clj-kondo` initialization to read latest config.edn and update linting — specifically related to clj-kondo hooks? I observe it happens only at window launch time. I am not able to trigger an update when starting/restarting a repl. Details: • my app deps.edn refers to local filesystem library my/lib {:local/root "…."} • I have a .clj-kondo/config.edn in my app, which refers to my lib: {:config-paths ["my/lib"]}my/lib defines a clj_kondo/.../config.edn which includes hooks • I open my app open VSCode, and clj-kondo reads current hooks info as defined in my/lib. • I switch over to a separate VSCode window containing my/lib , and I update the definition of the hook. • I switch back to my app window, and would like to re-trigger the lsp/`clj-kondo` initialization without reloading the window. Is this possible?

ericdallo20:01:05

clojure-lsp/kondo has nothing related with repl, if you re-load the window it should retrigger project scan

ericdallo20:01:25

also, both changes on clj-kondo config and clojure-lsp config don't need restarts

ericdallo20:01:58

unless you made a change in a hook that affect multiple file lints, then you need to restart clojure-lsp with window reload to lint the project again

sashton20:01:10

Okay, that answers the question then. Only a window reload will refresh clj-kondo definitions from dependencies, right?

ericdallo20:01:11

> would like to re-trigger the `lsp`/`clj-kondo` initialization without reloading the window. Is this possible? Sounds possible to me, since your config-path point to a local path which clj-kondo will check when liniting again

ericdallo20:01:40

> Only a window reload will refresh clj-kondo definitions from dependencies, right? yes, for dependencies you need to restart indeed

sashton20:01:20

I wonder if it would be possible to add some sort of command which could retrigger it manually. If I add a new dependency, or change a dependency version, I’d like to have the linting updated without reloading my VSCode window. Does that seem like a reasonable idea?

pez20:01:41

FWIW, @U08TWB99B. You can take advantage of that VS Code keeps the state of its terminal process between reloads. It doesn't work with the jack-in process, because reasons, but if you start the REPL yourself in a VS Code terminal and then connect to it, then you can reload the window and pay only the work of connecting. Not sure if this makes sense, please let me know wether it does.

ericdallo20:01:47

We could have a command on calva to restart LSP, I don't see a issue with that as well

sashton20:01:09

I wasn’t as concerned about restarting the repl, just trying to avoid window reloads, especially when developing a clj-kondo hook

👍 1
pez20:01:20

Indeed. @U9A1RLFNV and I have discussed a restart-lsp command.

ericdallo20:01:10

BTW @U08TWB99B, AFAIK clj-kondo copy the configs to a local dir, so your config should be avaialbel at .clj-kondo/my/lib/config.edn which changing that should not require a restart

pez20:01:55

For me the highest price payed for reloading a window is restarting the REPL. But I haven't been developing clj-kondo hooks...

👍 1
sashton20:01:57

yeah, i guess when I look at where the time is spent: 1. reloading the window 2. lsp re-running 3. reconnecting to repl I’m probably not saving much by avoiding 1, and 2 is what I want to happen anyway, and takes a lot longer than the UI reload. So, maybe this isn’t worth the work.

sashton20:01:49

I guess just knowing what I need to do to get the lsp/clj-kondo refreshed is enough. I was trying repl restarts, deps.edn file updates, etc.

ericdallo20:01:33

yes, I need to confess that usually when I develop a hook I run clj-kondo manually from the CLI since it's faster than reload whole project

👍 1
puzzler21:01:57

Does anyone happen to know which of the Calva pretty-printers show record tags and which don't?

pez21:01:24

Not sure what is meant by record tags, but I can tell you about that a difference between server side and client side pretty printing is that on the client side it is fully static and no tags will be expanded.

puzzler08:01:08

What I mean is if you say (defrecord P [x y]) and then enter (P. 1 2) into the REPL, will it print like an ordinary map: {:x 1, :y 2} or will it print in a way that shows it is clearly a record #mynamespace.core.P{:x 1, :y 2} ? pprint prints it just as a map, which is more compact but can be very confusing if you have a bunch of different records with similar fields. My personal preference would be something that prints as #P{:x 1, :y 2} and then you hover over the P to see the full name of the namespace, giving you the benefits of both compactness and clearly identifying the extra info that it's a record and what kind, but I don't think there's any printer that works like that. So I'd just like to know all the options.

pez08:01:38

There are only a few options since you can't tweak things like this on the printer through Calva. I would try all printers if I were you. I think that if you want to use the zprint option, you'll need to have it as a dependency in your project. I also recall that the calva option, which is client side, uses zprint, but I could remember that wrong. In theory you should be able to provide your own printer function, but I don't think anyone has tried that yet so it is unclear if it really works.

Lukas Domagala12:01:45

@U0518RMLD my options are:

"calva.prettyPrintingOptions": {
        "enabled": true,
        "width": 80,
        "maxLength": 100,
        "printEngine": "calva"
    },
and i get what you want:
(defrecord P [x y])
(P. 1 2)
=> #user.P {:x 1, :y 2}

🙏 1
pez13:01:28

With pretty printing disabled:

#sieve.P{:x 1, :y 2}
About the calva option: It will make Calva disable nrepl pretty printing. This nrepl sends the raw/non-prettified text to Calva and Calva uses zprint on the client side to prettify it. Like so:
(defn pretty-print
  "Parses the string `s` as EDN and returns it pretty printed as a string.
   Accepts that s is an EDN form already, and skips the parsing, if so.
   Formats the result to fit the width `w`."
  [s opts]
  (let [result (try
                 {:value
                  (zprint-str s (assoc opts :parse-string? (string? s)))}
                 (catch js/Error e
                   {:value s
                    :error (str "Plain printing, b/c pprint failed. (" (.-message e) ")")}))]
    result))