Fork me on GitHub
#cider
<
2020-02-23
>
EmmanuelOga03:02:12

Talking about documentation, maybe slightly related: I just found that my JDK sources folder was wrong and had to jump through a few hoops to set it right. In case anybody is interested, I documented what I found here: https://github.com/clojure-emacs/cider/issues/2745#issuecomment-590022133

EmmanuelOga03:02:53

If I get it right this should also gimme better javadocs for some stuff? Not sure... but jumping to source is for sure really useful 🙂

jumar08:02:06

I tried your advice and this gives me access to Clojure sources but unfortunately it doesn't work with JDK sources for some reason. I added tha java.base module subpath but still nothing:

("~/workspace/clojure/clojure/clojure-1.10.1-sources" "~/workspace/java/jdk-sources/jdk-14-src" "~/workspace/java/jdk-sources/jdk-14-src/java.base" ...)

jumar08:02:38

Oh, no - I was too optimistic - It doesn't work for clojure sources either. It's just that I added clojure source artifact directly to my project.clj in one particular project; but it doesn't work without this in another project

EmmanuelOga09:02:25

got it, sorry to hear that

EmmanuelOga09:02:51

perhaps there's a way you can instrument cider.el to print the paths it is using to look for the sources

jumar09:02:03

That's an interesting tip. Without going through the whole machinery I tried this in ielm and that looks good:

(cider-resolve-java-class "java.lang.String")
".../workspace/java/jdk-sources/jdk-14-src/java.base/java/lang/String.java"

jumar09:02:56

I'm trying cider-find-var and also jump-to-definition but neither one works (while it works for Clojure sources when I add them as a dependency in project.clj)

jumar09:02:00

I suspect it's something broken with JDK 8+ but your trickwith adding java.base subdirectory looked promising...

jumar09:02:12

Ouch, so it works only in stacktraces! That's indeed where I've found the only reference to cider-resolve-java-class : https://github.com/clojure-emacs/cider/blob/052290d080f58edc814dd7aa00b014d639c62974/cider-stacktrace.el#L560 @U051BLM8F is that intentional?

EmmanuelOga09:02:02

what version of cider is this?

EmmanuelOga09:02:55

bah, I'm sure you are using a recent one 🙂

jumar09:02:57

Yes, I updated it the last week

pez07:02:39

Using Evil in spacemacs, I fail to evaluate top level forms using C-c C-e when in command mode, because i can't place the cursor outside the closing paren. I need to be in insert mode. Is there something I can do about it?

jumar08:02:10

I don’t remember its name but there’s a setting which allows you to move the cursor beyond the last column in a row

jumar10:02:13

It's evil-move-beyond-eol - this is what I have in my .spacemacs file:

;; evil-move-byond-eol true will alow you to move one position after the last char
  ;; which makes evaluation of Clojure sexps with Cider much more convenient
  (setq evil-move-beyond-eol t)

practicalli_john13:02:42

@U0ETXRFEW Why do you need to go to the end of a line to evaluate an expression? cider-eval-defun-at-point will evaluate the top-level form under the cursor. Or simply go to next line and evaluate the last sexp using cider-eval-last-sexp Also not sure why you are using Emacs keybindings if you are using Evil? In spacemacs you have , e f , , e e , , e ; and many more useful keybindings that dont require any changes to the way Evil works.

pez13:02:33

@U05254DQM it is all I remember from my short endeavour with Emacs some four years ago. 😃 That and M-x which I use for discovering commands. Is there a spacemacs equivalent?

pez13:02:28

(I only very seldom use Emacs, and only to investigate how something works there, since it is a source of Calva inspiration.)

practicalli_john13:02:19

SPC SPC is the Spacemacs M-x in Evil mode, or strangely enough M-x in Emacs (holy) mode. It did take me a while to learn Evil and get the most out of it, but its definately been worth it.

pez13:02:41

I use Evil in order to be able to do anything at all in Emacs. 😃

practicalli_john13:02:51

I am at the same point as well, I am lost without Evil. C-x C-e is the only Emacs shortcut I can remember, as I used it so much :)

practicalli_john13:02:08

If you want to know the Clojure commands in Spacemacs, just press , with a Clojure buffer open and you will get a which-key menu which has the command names organised by what they do 🙂

pez14:02:49

Cool! (A somewhat equiv in Calva is cmd+shift+p then type Calva, FYI, in case you get to help some Calva users.)

jumar19:02:53

For me, cider-eval-last-sexp is quite useful to evaluate and that's what I use the setting for.

practicalli_john19:02:24

Emacs can be configured to do anything. It just seems a little strange to modify the behaviour of Evil when there are plenty of alternatives built in for evaluating Clojure. Evaluating the last sexp is great for nested expressions. It seems strange to jump to the end of a top level and then move past the end of the expression just to eval the top level, when you have , e f. When using Evil, then jumping to the next empty line after the top level is typically less keys than jumping past the end of expression on the same line. Of course you should use what ever works for you though, this is one of the benefits of Emacs.

bfay18:02:01

I personally use cider-eval-sexp-at-point, which lets me eval from the beginning from the form rather the end. I'm using the vim keybindings so I just bound ; to eval this. Move the cursor to the first paren of the thing I want to eval, then hit ; and boom, it's eval'ed The config to do this goes in dotspacemacs/user-config

(evil-define-key 'normal clojurescript-mode-map ";" 'cider-eval-sexp-at-point)
  (evil-define-key 'normal clojure-mode-map ";" 'cider-eval-sexp-at-point)

practicalli_john20:02:44

@U0MF00YRX that command is already bound to , e v in the Clojure layer, assuming you are on a recent develop branch, along with several others commands that were missing. , e ; is already bound to cider-eval-defun-to-comment to match Spacemacs conventions.

bfay20:02:39

Oh nice - I just mean use ; without even using , e , e ; actually will still work for eval to comment. Maybe there's a stock vim keybinding I'm breaking by overriding ;? I personally really like it, it's nice to be able to eval things with one keystroke

bfay20:02:15

Oh, by default vim apparently uses ; to navigate to your most recently searched character from a f or t motion. So I guess I can't use that with my change, but this seems more useful to me.

practicalli_john21:02:44

Ah, ; works the same in Spacemacs, that's handy. I never knew that, thanks.

jmckitrick13:02:05

When running both CLJ and CLJS connections, I find that sometimes a code buffer reports ‘not connected’ or seems to drop the connection. This happens most often with CLJS, but sometimes with CLJ as well. The workaround is to open the REPL buffer and then go back to the code buffer, an CIDER generally has re-connected the buffer to the backend.

jmckitrick14:02:54

I should add, the CLJS connection is shadow, if that matters.

dpsutton15:02:07

i don't think it matters. due to a limitation in the api of sesman CIDER only knows about the last connection. So when the clj repl last had focus the cljs code buffer thinks the repl type is clj and therefore not connected. you should see similar behavior if you have the cljs repl focused and a clj code buffer opened.

jmckitrick15:02:09

Ah! ok, good to know.

jmckitrick15:02:32

Yes, that’s exactly what I see.