Fork me on GitHub
#cider
<
2021-10-28
>
ericdallo01:10:59

I'd like to improve doom-emacs modeline icon where tells if cider is connected or not, I want to add a intermediate state telling if there is something being evaluated, is there any cider hook where I can rely on this?

ericdallo01:10:22

so when cider is not connected the icon would be:

ericdallo01:10:59

when connected but never evaluated nothing or there is something being evaluated it would be:

ericdallo01:10:41

and when connected and nothing evaluating/something was already evaluated:

ericdallo01:10:50

I managed to make almost everything work using cider-connected-hook , cider-disconnected-hook , cider-mode-hook and cider-file-loaded-hook , but the latter is not totally reliable for the intermediate state

ericdallo01:10:14

it'd be nice to have a pre-hook when cider is evaluating something and a pos-hook when it finished evaluated or it's cancelled

ericdallo01:10:58

BTW this already work on doom-emacs without the intermediate state, I made it some months ago My modeline:

ericdallo01:10:39

WDYT @bozhidar? if you agree, would you accept an PR adding those hooks?

ericdallo01:10:35

I see the hooks beeing important not for just modeline but anyone that would want to add some kind of UX feedback of cider state :)

dpsutton01:10:25

I thought these books existed and the spinner package was used for this

ericdallo01:10:49

AFAIK the spinner is used only for lsp-mode

ericdallo01:10:58

it seems cider has spinner indeed, but I never see it working, maybe doom disables it?

ericdallo02:10:30

I think it's related with the spinner running on the repl buffer, and the repl buffer has no modeline

ericdallo02:10:57

I managed to manually call cider code on my buffer and only this way works:

dpsutton02:10:12

ah we use spinner in CIDER but it's hardcoded with no hooks

ericdallo02:10:28

yeah I saw that, but even so I never saw this spinner working, does it always work for you @U11BV7MTK? I suspect doom-emacs does something that hides it

dpsutton02:10:55

been a while since i've used CIDER actually but yes it always worked

dpsutton02:10:20

you can check the value of the var cider-show-eval-spinner

dpsutton02:10:26

if doom sets this to nil it will never show

ericdallo02:10:26

I see, so probably a doom-emacs thing, anyway, I still think the hooks would improve how other can extend this behavior

dpsutton02:10:35

100% agree on the hooks

ericdallo02:10:35

it's true, I checked it

ericdallo02:10:05

I checked every variable related to the spinner, all are on the default value 🤷

dpsutton02:10:23

only thing i can think of is there are packages that dimish things in the modeline and i bet they are getting swept up in that

dpsutton02:10:28

but i forgot what its called

dpsutton02:10:35

might actuall be called diminish

dpsutton02:10:48

maybe diminished-mode-alist

ericdallo02:10:56

I have no variable or function with dimi as prefix :thinking_face:

dpsutton02:10:24

hmm. i bet there's another package that achieves the same thing. anything that claims to clean up the modeline. but this is all speculation

ericdallo02:10:34

yeah, it makes sense

ericdallo02:10:19

actually, doom-modeline is built-in on doom-emacs: https://github.com/hlissner/doom-emacs/blob/develop/modules/ui/modeline/+light.el I remember I coded there adding that cider repl icon

ericdallo02:10:39

but most doom-emacs people use the main modeline: https://github.com/seagle0128/doom-modeline I already used both and saw people using both, and never saw that spinner

dpsutton02:10:15

if you turn off modeline-mode does it show up when you eval?

ericdallo02:10:13

the modeline becomes huge 😂 I can't even know if it works

ericdallo02:10:26

but I suspect it's there....

ericdallo02:10:46

😂 yeah.. I'm used to keep only on the notebook without any extra monitor :man-shrugging:

dpsutton02:10:25

you'll need to kill some minor modes and hopefully it shows up

dpsutton02:10:43

haha. i guess proving the point of why its so useful lol

ericdallo03:10:29

Cleaned some minor modes, but no spinner:

dpsutton03:10:07

its still not clear to me that you can see all of them

dpsutton03:10:15

i don't see any space indicating the list has ended

dpsutton03:10:36

using the mouse can you click on them and choose which ones to see?

ericdallo03:10:39

I think the repl one was the last, I cleaned some more:

ericdallo03:10:00

Yeah, I actually wrote that code @U8QBZBHGD 😅

ericdallo03:10:33

this whole conversation was to have some hooks from cider to improve it even more :)

dpsutton03:10:19

if you do (require 'spinner) and then (spinner-start) do you see it now?

loading 2
dpsutton03:10:08

i also see this in spinner.el:

(unless (and (listp mode-line-process)
                 (memq 'spinner--mode-line-construct mode-line-process))
      (setq mode-line-process
            (list (or mode-line-process "")
                  'spinner--mode-line-construct)))

dpsutton03:10:44

check those constraints? mode-line-process. although i guess that's just adding it to the list and ensuring not to re-add it

ericdallo03:10:46

yes, running that works

ericdallo03:10:18

this show the cider spinner corectly:

(spinner-start cider-eval-spinner-type nil
                     cider-eval-spinner-delay)

ericdallo03:10:33

but that's the question, why it's not activating automatically

ericdallo03:10:18

anyway, thanks for the help @U11BV7MTK, I'd still like to have my repl icon instead of the spinner

dpsutton03:10:24

i'm gonna look into this: maybe spinner start isn't built into all interactive eval handlers?

1
dpsutton03:10:51

right. i agree. but my thinking is that the places where spinner calls are would be the place to swap in the hooks and have spinner as the default on the hook

dpsutton03:10:23

so once spinner works for you you'll know that your change works when the spinner keeps working on the hook, and then unhook it and set your own icon on the hook and it'll almost 100% work

dpsutton03:10:13

another thing to check, is define dummy functions for spinner-start and stop that just message "i was called and started" or whatever and see if CIDER is failing to call or spinner is failing to render

1
ericdallo03:10:47

good idea, let me try

ericdallo03:10:43

yeah, cider-spinner-start is being called for sure

ericdallo03:10:01

probably the buffer it's wrong, it's the repl one, not the active buffer where I'm coding :)

dpsutton03:10:02

well that's frustrating

dpsutton03:10:25

oh maybe! i haven't seen CIDER in a while so i'm not actually sure which buffer lol

😅 1
ericdallo03:10:27

with a hook, I'll be able to listen to the hook on other buffers

dpsutton03:10:51

and you'll dabble a toe into the waters of multiple connections and figuring out which repl buffer is connected

dpsutton03:10:22

that's an area where the workspace style editors are far easier: intellij and vs code. There aren't multiple projects open at once

ericdallo03:10:28

yes, but that's one of the things I like emacs, I don't need multiple emacs :p

dpsutton03:10:42

agree. i really like that about emacs. but it does make that particular problem harder

dpsutton03:10:14

actually one thing i don't like about lsp. I often look into lots of other projects and that spins up lsp servers just by looking at a clj file. i wish it was opt in per proejct

dpsutton03:10:28

i have to remember to lsp-workspace-shutdown if i go look at clojure source code or core.match, etc

ericdallo03:10:50

yeah, unless you opened the buffer from the current workspace which will open in a cache emacs folder using the same session, it will connect another session indeed

ericdallo03:10:32

yeah, maybe we could improve that on lsp-mode somehow

ericdallo03:10:57

anyway, I'll go to bed now, thank you for the help and chat @U11BV7MTK @U8QBZBHGD

👍 1
1
bozhidar12:10:41

Thanks one long thread! @UKFSJSM38 all sorts of improvements are more than welcome. 🙂

bozhidar12:10:16

I also also thinking it'd be nice to have some indication about whether a ns was evaluated or not, etc, but never got to doing those.

ericdallo12:10:10

Thanks! I'll try to open a PR adding those hooks so :)

bozhidar12:10:10

Btw, what are you using to see the variable values in the minibuffer? That looks cool!

bozhidar12:10:42

That's another thing we can do for CIDER as well, although I'm not sure how it will look for bigger values. 😄

ericdallo12:10:47

Haha, it's from doom-emacs I guess It uses ivy via shortcut SPC h vshowing all variables and it's values

bozhidar12:10:48

Hmm, I used ivy for years and I never knew it could do this. Oh, well... 😄

ericdallo12:10:22

Haha :man-shrugging: maybe some doom magic as well

bozhidar12:10:25

I didn't have time to test it properly, but the code is pretty straight-forward, so I'm optimistic it will work. bb.edn made implementing jack-in support pretty simple.

🎉 8
babashka 8
borkdude13:10:14

w00t! @bozhidar thank you!

borkdude13:10:23

@bozhidar just checking. does this assume anything about anyone writing an .nrepl-port file?

bozhidar13:10:10

No, it just assumes that you write the port to the terminal, the same wait that Lein does it.

borkdude13:10:26

@bozhidar cool. lein:

nREPL server started on port 63373 on host 127.0.0.1

borkdude13:10:33

$ bb nrepl-server
Started nREPL server at 127.0.0.1:1667
For more info visit: 

borkdude13:10:04

there is some code here that accounts for this: https://github.com/babashka/babashka/wiki/GNU-Emacs

borkdude13:10:36

nbb does it the way lein does (this time we could fix it in time)

bozhidar19:10:22

Yeah, it's trivial to have a dedicated command, but if we assume that most babashka projects use bb.edn, I think it makes more sense to make cider-jack-in-clj aware of babashka (which is what I did), than to introduce one more set of commands. Obviously with Emacs we always have infinite possibilities. 🙂

FiVo18:10:56

Did anyone run into issues with dependencies and deps.edn aliases recently? I sometimes jack-in and it just doesn't find the deps from some alias. No change in code. I jack-in again and it works. I can't reproduce it reliably. I also don't know if it is some cider issue or lower down. My dir-locals.el mostly contains something like (cider-clojure-cli-global-options . "-A:dev:test:build")

vemv18:10:17

Nothing comes to mind, however if the issue is flaky, perhaps tools.deps own caching .cpcache is into play

alexmiller18:10:42

this can happen if you are using local deps

alexmiller18:10:57

cache will not be recomputed if those change

alexmiller18:10:07

(but I am working on a fix for this!)

thom20:10:04

Doubt this is an issue but FYI you can specify aliases directly with cider-clojure-cli-aliases, instead of sending them as global options.

FiVo06:10:08

One project contains a local dep, but it was never a local dep I had issues with

alexmiller12:10:25

Well it would be something transitive from a local dep so could be about anything

alexmiller12:10:10

You should be able to fix it by using clj -Sforce from the command line (+ any aliases)

FiVo10:11:22

No seems to be a cider issue. Ran into it again a couple of times and the jack in command does not contain the aliases.

FiVo10:11:06

cider-clojure-cli-global-options seem to be nil in that case

tomd22:10:31

Are :indents and :alias-map the only options that cider can send to cljfmt? I'd like to enable :remove-multiple-non-indenting-spaces? for cider's use of cljfmt, but adding it to the cider-format-code-options plist doesn't work. Is there another way or will this need a code change to cider?

iarenaza10:10:02

@UE1N3HAJH Unfortunately only :indents and :alias-maps are currently supported. We'd need to change both cider--nrepl-format-code-request-map from cider-client.el in Cider code, and at least format-code-reply in Cider-nREPL code.

tomd11:10:36

Thanks @U8T05KBEW I thought as much. I may make a PR if I get around to it.