Fork me on GitHub
#clojure
<
2022-12-26
>
Flawless03:12:58

hi all, im looking for a way to automatically create test ns for current ns with emacs if it doesn’t exist yet, i’m using cider, clojure-lsp, projectile and sometimes cljr. Usual to open test ns I use projectile-toggle-between-implementation-and-test and want to create new test ns if it doesn’t exists. It feels like pretty common use case and I believe there is a ready to use fn to do so, but I can’t find one.

Ben Sless05:12:42

I can't remember the var name but try to toggle and look in the message area it'll tell you the name to set to t so it will automatically create one

Flawless07:12:18

thanks, don’t know how I could miss it, maybe I have to stop working in early morning (: the variable is projectile-create-missing-test-files

ericdallo13:12:49

There is a clojure-lsp code action to create a teds for the current fn, creating the test ns and the function to be tested

Flawless08:12:43

yes, i saw such fn in clojure-lsp, but somehow it does nothing when i call it from emacs lsp-mode, either nothing appears both in lsp-log and messages buffers, even if the test ns already exists, maybe you know, where should I look also?

Flawless08:12:28

I believe clojure-lsp cannot recognise my tests because on lsp-clojure-show-test-tree it outputs No Clojure test tree data found. I’ve already added test to source paths (without alias) after i’ve tried to change classpath-cmd in lsp config.

Flawless14:12:30

looks good, but is it better than projectile?

pesterhazy14:12:17

Less magic, easier to figure out if it doesn't work

ericdallo15:12:14

@UJ1UZGJ75 if you have a simple repro, feel free to open a issue on clojure-lsp

Flawless15:12:56

Thanks, I should get rid of additional stuff in my config and try to reproduce it a in clean env.

Flawless15:12:38

I figured out the problem, lsp-mode incorrectly detected project root and started lsp in my projects directory, not in the directory of the project, where i do tests. It was fixed enabling lsp-auto-guess-option. thank you all for your help

👍 1
Carlo08:12:37

I use cider , and I remember that I was able to follow a definition from my code to a library I depend on, make some changes there, evaluate it, and have the new behavior in my code. I don't seem to be able to do that anymore. Did anything change in that respect recently?

p-himik08:12:53

More apt for #C0617A8PQ

🙌 1
Carlo08:12:58

the actual files are located in .emacs.d/local/.cache/workspace/.cache/file.clj

Carlo08:12:31

thanks, I probably have a better way of asking too, now!

Ben Sless08:12:35

Just so answer your question, the files are opened as read only by default, so toggle that mode

Carlo08:12:27

thanks @UK0810AQ2, I did that, made the change, but nothing seems to happen when I evaluate that file (the behavior doesn't change)

Carlo08:12:51

(probably because it's not considered part of the same CIDER session)

phill14:12:02

Do you use Leiningen? Did you access the library via a symlink in the "checkouts" directory?

Carlo14:12:58

No, I use deps.edn and reached the file via lookup-definition in doom emacs

kennytilton18:12:57

Yikes. So, in a collection scenario, I innocently conjed a value onto nil and got a list, and so subsequent collections kept adding to the front of the list. Now I know. So this could be a performance-sensitive deal. I recall vaguely things about Clojure vectors being faster because of the underlying Java. Is that recollection correct? Should I start off with [] so my collector creates a vector, or is a list as fast? Processing wise, I do expect to be wanting to read these sequentially encountering later items first.

Miķelis Vindavs18:12:16

I believe what makes vectors faster is that the values are colocated in memory (vectors store values in chunks, for each of which the underlying storage is an array). I think it's OK to start with an empty vector. In my experience, the vector is the go to data type for sequential data and I only use lists rarely

Miķelis Vindavs18:12:32

If you need more performance, you can look into transients and transducers

Miķelis Vindavs18:12:26

As an alternative to passing the empty vector as the initial value you could also (fnil conj [])

🙂 1
seancorfield18:12:00

It would very much depend on your planned pattern of access. Vectors are optimized for adding & removing items at the end -- and have indexed access (as well as sequential). Lists are optimized for adding & removing items at the front -- and for sequential access.

seancorfield18:12:59

(there's also a persistent queue if you need that kind of construction/access pattern)

kennytilton18:12:11

Thx, all! Much more, compute intensive processing will be done on the results than in collecting them, so colocation souds good. I'll go with vectors for a start.

Dan Boitnott20:12:52

Anybody know what the successor to the Friend library (https://github.com/cemerick/friend) is these days? I'm unhappy with my current permissions model and reckon there's got to be a standard, de-fact or otherwise, for modelling authorization.

p-himik20:12:24

Buddy. It's even mentioned in the README.

Dan Boitnott20:12:56

Looks like Buddy is also "in maintenance mode" unless I'm looking in the wrong place.

p-himik20:12:34

> plase use the individual modules

Dan Boitnott20:12:30

Checked there. The buddy-auth user guide also describes itself as "in a maintenance mode." https://funcool.github.io/buddy-auth/latest/user-guide.html

Dan Boitnott20:12:39

If people are out there using it I won't turn my nose up at it. Not everything has to have a commit in the last month. But gives one pause when starting a new project when a major dependency isn't being actively worked on.

p-himik20:12:47

People are using it. :) It's not described as deprecated. While the project is looking for a maintainer, the amount of open issues is small and "maintenance mode" means (at least to me) that its API is complete.

💯 2
Dan Boitnott20:12:20

I'm down with that. I'll dig into the docs. Thanks!

👍 1
cddr20:12:19

There's also keycloak

Dan Boitnott21:12:56

Just looking now. Seems like Keycloak is more an SSO service. I'm looking for something reasonably light that can handle "is user X allowed to do Y."

Ivar Refsdal18:12:33

How is user X abilities encoded/stored/retrieved? Is using JWTs and the https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3 an option? Edit: Some people (including me) wrote https://github.com/sikt-no/clj-jwt, a small wrapper over buddy, for unsigning JWTs and fetching keys easily.

Dan Boitnott18:12:16

Ideally I'd like them to be stored in something similar to AWS IAM policies.

👍 1
Anders Eknert22:12:58

I’m biased, but you might want to consider decoupling authorization :) https://github.com/anderseknert/clj-opa

Dan Boitnott16:12:30

That's pretty interesting. I'll take a look.

😃 1