Fork me on GitHub
#cider
<
2020-11-05
>
theeternalpulse06:11:13

What's the most I guess effective way to work with macros in clojurescript when connected to the cljs repl? I noticed I can't really eval macros in the clj file so kind doing rapid testing in the same ns while creating it like I would anything else.

Louis Kottmann10:11:51

in cider you have cider-macroexpand-(1|all)

Louis Kottmann10:11:08

otherwise in the REPL you can just (macroexpand 'myform)

devn21:11:29

hello friends. how do I find all usages of a particular fn definition?

devn21:11:08

I was thinking C-c C-? r

devn21:11:52

but perhaps I need to load all namespaces for it to work? wondering how people typically do this. I’m looking to check for usages, and then jump through them

dpsutton22:11:40

CIDER is always nrepl based so its just whatever is in the running instance. clj-refactor might have some tools for this and i know that lsp certainly has tricks for this

devn22:11:11

normally i’m not jealous of of Cursive, but I’m wondering how people do “Find Usages” in emacs/cider land

bozhidar08:11:45

I've always found projectile-ag to yield great results for me, but your mileage might vary. 🙂 CIDER's built-in find-usages functionality works only on loaded namespaces and only for Clojure. clj-refactor and anacondo-mode might give you better results, as an alternative to using LSP. Too many options these days. 😄

devn22:11:51

I suppose I’ve always just grepped around, but I’m doing a bunch of reorganization right now. It’s in a project with 3 source dirs: a cljs src dir, a clj src dir, and a cljc shared source dir that is referenced by both the cljs and clj src dirs

dpsutton22:11:20

can't recommend lsp enough

dpsutton22:11:56

if you're consistent with your imports its also often easy to look for alias/var-name to find them as well

devn23:11:20

@dpsutton cheers. i’ve been hearing about lsp for ages, but haven’t taken the plunge. do you have any suggested reading?

devn23:11:31

im using a pretty stock emacs setup + cider

dpsutton23:11:59

me too. i think there's some good stuff in the readme for lsp

devn23:11:02

and is it complementary to CIDER, or a replacement? i guess i’ve always been a bit confused

devn23:11:16

my former coworker wrote clojure-lsp. should have asked him when he was around 😄

dpsutton23:11:35

you worked with snoe?

dpsutton23:11:03

complimentary to CIDER. or at least that's how i used it. it offers no repl.

dpsutton23:11:14

ah cool. i was at aclaimant until about a month ago with him

devn23:11:36

nice. i was at outpace with him about 5 years ago. came back to outpace a couple years ago after he’d moved on.

dpsutton23:11:07

ahh i've heard them talk about it

devn23:11:50

@dpsutton so do you have clojure-lsp running with emacs?

dpsutton23:11:11

i did but not at my new job

dpsutton23:11:06

(when personal/work-machine
    (use-package lsp-mode
      :load-path "~/projects/elisp/lsp-mode"
      :hook ((clojure-mode . lsp)
             (clojurec-mode . lsp)
             (clojurescript-mode . lsp))
      :init
      (setq lsp-enable-completion-at-point nil)
      ;; (setq indent-region-function #'clojure-indent-function)
      :config
      (require 'lsp-clojure)
      (dolist (m '(clojure-mode clojurec-mode clojurescript-mode))
        (add-to-list 'lsp-language-id-configuration `(,m . "clojure")))
      (setq lsp-clojure-server-command '("bash" "-c" "cd ~/projects/clojure/clojure-lsp && lein run")
            lsp-enable-indentation nil)
      ;; (add-hook 'clojure-mode-hook #'lsp)
      ;; (add-hook 'clojurescript-mode-hook #'lsp)
      ;; (add-hook 'clojurec-mode-hook #'lsp)
      ))
almost straight out of the readme. i prefer CIDER's completion and not indenting with lsp

devn23:11:06

and then when you enter a cl[j/jc/js] file how do you start it?

devn23:11:49

i added lsp-mode and configured it like the README suggests, and put the clojure-lsp binary on my PATH

devn23:11:43

I see you require lsp-clojure — where does that come from?

dpsutton23:11:25

that's part of lsp emacs package. when you enter a clj/cljc/cljs file it should start due to the hooks in the snippets

devn23:11:33

hrmmm, doesn’t seem to be starting or hooking in for some reason

dpsutton23:11:35

was the buffer already open when you evaluated the use-package form above?

devn23:11:51

nah im restarting emacs to make sure

dpsutton23:11:10

not sure then.

devn23:11:15

I do see lsp-log in my buffers

devn23:11:18

The following clients were selected based on priority: (server-id clojure-lsp, priority 0)

devn23:11:14

I keep getting “no language servers associated with this buffer”