Fork me on GitHub
#clojure
<
2022-01-13
>
Panel00:01:13

Anyone here is using a lightweight syntax highlighting on emacs ? I want to try something else than the default setup that highlight too much in my opinion, maybe with a focus on data. Here for example everything is "highlighted" so it might as well not be. My setup is clojure-mode | cider | cojure-lsp and they all provide support for syntax highlighting, so I'm not sure how they integrate and if they can be tuned.

andy.fingerhut01:01:35

#cider channel might be another good place to ask.

didibus04:01:37

I think there's a few things you can do

didibus04:01:59

You can customize the colors of things. font-lock-keyword-face font-lock-function-face font-lock-variable-name-face Those dictate the appearance of keywords, functions and variables respectively.

didibus04:01:55

And the easiest you can do is just: (setq cider-font-lock-dynamically nil) That's going to disable dynamic font highlighting, so basically you get the same highlight as if you did not connect to a REPL

Martynas Maciulevičius04:01:32

If you don't like blue color you may as well want to change your color scheme. I use ample-zen:

didibus04:01:41

Ya, I was going to say, everything blue and a blue line highlight is a bit much, my theme (spacemacs-dark) looks like:

Martynas Maciulevičius04:01:47

Also my theme looks like this (with similar code to your snippet):

didibus04:01:00

@U028ART884X You either are not connected to a REPL or don't have full Cider dymamic font highlight, otherwise users should be the same orange color on both places

Martynas Maciulevičius04:01:27

I have no special config for highlighting. I think it's the theme. But I may be wrong. Also I'm on develop branch. And I am connected because I can evaluate the forms.

didibus05:01:15

Ya, you need to add:

(with-eval-after-load "cider-mode"
    ;; Enable CIDER dynamic syntax highlighting so that custom fn and macro gets highlighted as such
    (setq cider-font-lock-dynamically t))
And then it'll highlight all variables, functions and macros, not just clojure.core ones

hiredman00:01:06

there are lots of things that change how forms are highlighted

hiredman00:01:41

for me that looks like

didibus04:01:02

That's if you don't have Cider connected to a REPL

hiredman00:01:17

which is just whatever theme I have plus a likely old version of clojure-mode

hiredman00:01:30

I believe both cider and clojure-lsp fiddle with highlighting, but how much and to what degree I don't know (never used clojure-lsp and haven't used cider in a long long time)

ericdallo01:01:50

@avocabio with clojure-lsp semantic tokens:

didibus04:01:32

I think that's what they don't want haha. I think it's great, but if your font has very similar colors for functions, keywords and variables I can see their point

Panel07:01:30

Can semantic tokens or maybe it's emacs be dialled down to, for ex, only highlight some token ?

didibus07:01:44

I answered you for Emacs in your original thread for that

ericdallo11:01:44

It's possible to customize each token color as well on lsp-mode side

Cora (she/her)02:01:58

semantic tokens are so nice

thanks 1
pinkfrog14:01:04

A little bit lost on the -X part of invoking a function in the command line:

clojure [clj-opts] -X[aliases] my/fn? [kpath v ...] kv-map?
Can someone give me an example covering the [kpath v …] kv-map? part

Alex Miller (Clojure team)14:01:01

it's mostly like invoking a kwargs function (other than using vectors as a key path)

pinkfrog14:01:46

The notation is the one part that confuses me

clojure [clj-opts] -X[aliases] my/fn? [kpath v ...] kv-map?
For example, the ? in fn? does it mean my/fn? is optional in the command line?

pinkfrog14:01:08

or something callable shall be passed.

pinkfrog14:01:15

Also for

[kpath v ...] kv-map?
the two part existing together is meaningless.

Alex Miller (Clojure team)15:01:39

? means it is optional (can be supplied in :exec-fn in alias)

Alex Miller (Clojure team)15:01:06

I don't know what "the two part existing together" means, sorry

pinkfrog15:01:20

The example says

# Override the arguments to my-fn
clj -X:a-tool my-fn :val 789 '{:val 123}'

pinkfrog15:01:45

Why doesn’t directly specify

clj -X:a-tool my-fn '{:val 789}'

Alex Miller (Clojure team)15:01:29

you could, but just trying to demonstrate syntax

Alex Miller (Clojure team)15:01:57

but when I get a chance I'll try to improve that

pinkfrog15:01:57

Really appreciate your work though.

manutter5114:01:14

If you were going to build a desktop app for your own personal use these days, what would you use? I’ve tried cljfx, but I can’t quite wrap my head around it for anything more complex than “Hello, world.” I’ve done electron apps years ago, but I’m not sure where that project has gone lately. What’s good these days?

Ben Sless15:01:22

I'd try #membrane

manutter5115:01:36

Ah, haven’t heard of that one before, thanks!

Ben Sless15:01:48

It's kind of raw but with my zero experience in building ui I managed to build something in less than a day

MatElGran18:01:16

I’m currently looking for solutions to this, and have stumbled upon https://tauri.studio/en/, which is in beta, but I successfully wrapped a webapp of mine in less than an hour (mainly spent watching cargo download and compile rust dependencies)

MatElGran18:01:28

also, but using F#, https://fsprojects.github.io/Fabulous/ seems interesting

phronmophobic18:01:06

I'd be happy to answer any questions about membrane. If you're already familiar with web technologies, then electron is still a good choice.

manutter5118:01:53

Cool, maybe I'll have another look at electron, but membrane is certainly intriguing. What I'd really like is a tree widget, but a quick look thru the docs didn't turn one up. Is there a way to call JavaFX stuff without too much ceremony? (Just looking for a high-level yes/no here, until I get a chance to really sit down with the docs).

phronmophobic18:01:40

short answer is not currently. You can embed membrane in a JavaFX UI, but it's not documented. For example, I've used membrane to build reveal widgets.

manutter5119:01:52

Ok, no biggie, the first project I'd like to work on would be porting a web app that builds a "tree widget" out of <div>s, so I expect I can do the same with membrane as-is.

phronmophobic19:01:34

Yep, I've built several tree widgets, but I haven't made a standard one.

👍 1
delaguardo19:01:52

https://github.com/HumbleUI/HumbleUI There's is also very raw but already useful framework build with skija bindings

✔️ 1
winsome20:01:52

Does anybody have any advice on testing with the cognitect/aws-api library? I don't want to have my tests actually call out to aws, and I'd like to be able to see the data I'm sending, as well as mock a response

Darin Douglass20:01:22

i’d suggest just spinning up a localstack container and “mocking” our aws instead

lispyclouds20:01:12

we use localstack too here in the aws pod for babashka: https://github.com/into-docker/unixsocket-http/issues/17 its using the aws-api lib too

Darin Douglass20:01:44

given how accessible almost all services are nowadays with docker containers, community supported tools, etc, i generally think mocking out a 3rd party service (i.e. a database, kafka, aws, etc) is a fools-errand for testing

Darin Douglass20:01:21

you’re more likely to waste more time mocking out and simulating those services than your are spinning them up in a container

kenny21:01:07

Each invoke call should be passed in as a function taking the request and returning a response. This way, you've made the function pure and easily testable.

Jim Rootham20:01:01

I am resurrecting a clojure project. When I try to run the uberjar it gives me class not found for main. It did work in the past. There is a genclass in the clj defining -main and a :main entry in project.clj. The uberjar manifest has a main class entry and that class defines a main function (per javap). My current theory is java having been updated in the interim. Is this plausible? What are the other possibilities? A search on Stack Overflow for main not found came up empty.

noisesmith20:01:26

I usually don't generate a class for main, instead I use java -cp my-uber.jar clojure.main -m my.ns to run the jar, relying on clojure's precompiled main

noisesmith20:01:07

that said, if your main class is missing and that's actually a problem, then you need to use the :aot config in lein, or :gen-class to generate that main class - nothing creates it implicitly

Jim Rootham20:01:07

The main class is there, I am just getting the error. I just looked at the Leiningen docs and they are still recommending Java 8. My default is Java 11. Is this the problem?

noisesmith20:01:21

• (deleted erroneous message)

noisesmith20:01:29

this has nothing to do with your java version

Jim Rootham20:01:50

Relevant project.clj lines: > :main ^:skip-aot voting-server.core > :aot [voting-server.core]

noisesmith20:01:10

^:skip-aot is your problem

noisesmith20:01:45

also you don't need the :aot entry - it's implicit with :main

Jim Rootham20:01:09

OK, when I sliced that out lein run failed is there a magic incantation for both?

noisesmith20:01:06

that's a good question for #leiningen - I don't use lein run so I'd have to do some research to answer

noisesmith20:01:06

(and not using aot skips a lot of the worst parts of lein)

Jim Rootham20:01:21

Still fails, same error

Jim Rootham20:01:43

Also lein spit some warnings.

Jim Rootham20:01:59

about not using AOT

noisesmith20:01:57

I'm starting to think the thing that broke is that your project.clj doesn't work properly with newer lein

noisesmith20:01:21

you can use lein upgrade <version> to switch to the version of lein that was current when your project worked

noisesmith20:01:41

(this is easy to undo via lein upgrade which gives you the latest again)

Jim Rootham20:01:10

OK, I will need to figure out what that version is. Are there notable changes in this area?

noisesmith20:01:32

if it's feasible to change your process startup so it uses java -cp uber.jar clojure.main -m your.ns that's an easy long term fix for all this nonsense

noisesmith20:01:28

every lein release should have a version listed here: https://mvnrepository.com/artifact/leiningen/leiningen and they are all timestamped

Jim Rootham20:01:55

This is a web server that should run as a systemd service. I'm not sure that is a feasible fix. What's the start point if you do that?

noisesmith20:01:38

start point is clojure.main

noisesmith20:01:12

if you need lifecycle support, I made a small java jsvc app that loads your clojure code based on a system property setting: https://github.com/noisesmith/clj-jsvc-adapter - may or may not be useful, my use case was wanting system level log management of stdio, start / stop / restart via normal system controls, without using aot in my clojure code (it's so small that a full rewrite for your own needs would likely take less than an hour)

Jim Rootham20:01:31

Egg egg egg. It was leaving out the -jar to java

noisesmith21:01:06

that would do it

Jim Rootham21:01:37

I should have posted in beginners, I seem to be back there.

noisesmith21:01:02

and I should have asked to see the exact command line you ran and the error message

Jim Rootham21:01:06

While we are here. What is the issue with aot?

noisesmith21:01:08

it violates the normal load / run / reload / run expectations of a repl based workflow

noisesmith21:01:32

leads to "it worked on my machine, fails in ci" errors very frequently

noisesmith21:01:12

makes the mental model needed to understand when things are evaluated more complex, leading to surprises

Jim Rootham21:01:15

So, not an issue if you don't use repl?

noisesmith21:01:56

if you don't use a repl I'm surprised there's any appeal to clojure - but it's more than that, it leads to a more complex evaluation model- I think that's the case even if you don't use a repl

noisesmith21:01:19

but regardless, there's nothing in clojure that gets simpler when you aot, and many things that become more complex

noisesmith21:01:58

(except maybe the need to use -cp rather than -jar on the command line, and explicitly stating the main class and entrypoint ns)

Jim Rootham21:01:29

OK, thanks. This might not be hugely relevant in the future. I have fallen in love with Maybe types so I am not sure how much I will be doing with Clojure.

Jim Rootham21:01:23

The warning suggested putting the aot in an uberjar profile. Which makes sense.

Jim Rootham21:01:36

In any event, thanks very much.

mpenet21:01:18

That clojure.core/iteration looks really nice. Can't wait for the next release

ghadi21:01:02

Ask me anything about it. The docstring is a mouthful.

🎉 2
Darin Douglass21:01:20

i’ve been super pumped for iteration since i learned it was going to be a thing, thanks for writing it! i’ve been copying the latest patch whenever i need the functionality :) i agree with you that docstring is pretty chunky. it was one of the biggest blockers when i was introducing it to my coworkers. is there a reason you went with :kf and :vf instead of (something like) :next-key-fn and :value-fn which are akin to what data.json offers?

lilactown21:01:18

I don't understand what "opaque continuation data" means

ghadi21:01:19

@U02EA2T7FEH I think both Rich and I generally prefer succinct names

ghadi22:01:07

kf = key function, vf = value function

Darin Douglass22:01:55

gotcha, figured it was something like that (though i’d still lobby for more expressive names 😄). thanks for the response!

ghadi22:01:12

(step! k) returns a "ret" -- could be anything (some? ret) = is there something here in this ret? (vf ret) = if so, extract that something -- useful when the ret is an "envelope" and you want the contents (kf ret) = get the k for next step! call ... call (step! k) again, repeat

ghadi22:01:00

@U4YGF4NGM oftentimes the call for fetching the first of a series of things (like consuming a paginated API) differs from fetching subsequent things

ghadi22:01:11

k is usually some sort of token that you pass to get the next thing

ghadi22:01:57

"opaque continuation data". At the beginning of the process, you don't have a k, therefore it is nil by default (although you can override that with the :initk arg)

ghadi22:01:41

(defn list-log-groups
  "list _all_ CloudWatch Log Groups, given an AWS client"
  [client]
  (->> (iteration
        (fn [token]
          (aws/invoke client (cond-> {:op :DescribeLogGroups}
                               token (merge {:request {:nextToken token}}))))
        :kf :nextToken)
       (mapcat :logGroups)))

lilactown22:01:14

I see. at first I thought it was a literal continuation i.e. a function that ought to be called when some async thing was done

hiredman21:01:35

those most recent commits on clojure are all so interesting

ghadi21:01:33

which speak to you?

Alex Miller (Clojure team)21:01:07

maybe if Maven central would stop sucking I could release a new alpha 🙁

emccue22:01:24

Are there any tools for deps.edn that handle downloading/etc javadocs and sources jars for dependencies?

Alex Miller (Clojure team)22:01:31

if you tap into a suitably low level of tools.deps, it is possible to request those things programmatically but the Clojure CLI doesn't have anything to do so

vemv00:01:53

Yes it's working nicely, as bundled with CIDER. deps.edn compat is drafted in a PR, initially I was hoping to get a PR from anyone using deps.edn regularly (I use deps.edn through Lein). The PR itself works but it's 'MVP quality' - use at your own risk :) Finally it looks like I'll take said PR into my own hands, any day of these. cc/ @U3JH98J4R