Fork me on GitHub
#cider
<
2019-04-18
>
Ahmed Hassan08:04:29

I'm working in Fulcro on Cider mode. How can I keep indentation two spaces deep? (which I think is ideal for Clojure??) It is too much indentation as you can see.

manuel08:04:31

probably leveraging define-clojure-indent? I have this:

(define-clojure-indent
    (for-all 1)
    (defroutes 'defun)
    (GET 2)
    (POST 2)
    (PUT 2)
    (DELETE 2)
    (HEAD 2)
    (ANY 2)
    (context 2)
    (reporting 1))
Maybe adding defsc there can fix your problem.

Ahmed Hassan08:04:38

Did this, it doesn't work.

bozhidar08:04:26

There’s also a global config for this, but it will force 2-space indentation everywhere.

Ahmed Hassan08:04:27

So 2-space is not ideal globally?

bozhidar08:04:16

Depends on your perspective. 🙂 It’s not aligned with classic Lisp traditions, but many Clojure devs like it. That’s why the option exists.

bozhidar08:04:24

(but it’s not the default)

bozhidar08:04:14

(setq clojure-indent-style 'always-indent)

Ahmed Hassan08:04:16

It's not working in this case too.

bozhidar08:04:35

What’s your clojure-mode version? I’m 100% that this works.

Ahmed Hassan08:04:01

Version: 20190413.909

bozhidar08:04:47

So, you evaluated this and nothing changed in clojure-mode? I can’t imagine how this can happen.

Ahmed Hassan09:04:43

I added this to init.el file.

benedek09:04:18

@dpsutton any idea how to make add-libspec or the refactoring work in clojure-lsp? when i try to run them i get lsp--send-request-async: No workspace could handle workspace/executeCommand [2 times]

dpsutton12:04:06

been looking into this over coffee. it looks like you have to register all of the actions at startup

dpsutton12:04:45

so need to make the hashmap have all of these

(def refactorings
  {"cycle-coll" #'refactor/cycle-coll
   "thread-first" #'refactor/thread-first
   "thread-first-all" #'refactor/thread-first-all
   "thread-last" #'refactor/thread-last
   "thread-last-all" #'refactor/thread-last-all
   "move-to-let" #'refactor/move-to-let
   "introduce-let" #'refactor/introduce-let
   "expand-let" #'refactor/expand-let
   "clean-ns" #'refactor/clean-ns
   "add-missing-libspec" #'refactor/add-missing-libspec})

benedek12:04:14

oi, thx. i am bit slow tho… or just the def confusing me… so i need to put those pairs into :action-handlers

dpsutton12:04:23

yeah. but i'm not sure exactly what the values of the hash table are, but the keys are the refactoring commands here

dpsutton12:04:28

interestingly, lsp-code-actions-at-point can look these up dynamically and returns a hash table suitable for us i think

benedek13:04:57

the params need to be templated in somehow i suppose…

benedek13:04:14

so you can get the args with (gethash "arguments" action)

benedek14:04:08

hm… no joy so far. as far as i see action-handlers are good when you want to handle the whole call yourself. eg. it is a hook *before* the request is sent to the server

dominicm10:04:36

@snoe is the person to bother about clojure-lsp I think 🙂

bozhidar10:04:45

Indeed. I think he works with @dpsutton, therefore the assumption he’s also quite familiar with the project.

benedek10:04:52

they are both probably in a timezone where it is still pretty early maybe..

dpsutton11:04:47

I just woke up. Unfortunately I’m not sure and it just works in neocon

benedek11:04:47

good morning and thx :)

frozenlock14:04:41

My understanding is that CIDER launches with the :dev profile. Is there a way to specify another one?

dpsutton14:04:29

cider launches lein which defaults to the dev profile. you can do a one-off by jacking-in with a prefix arg to edit the command

dpsutton14:04:40

i'm looking up the var you can set to always use an arg

dpsutton14:04:22

i think you want to edit cider-lein-global-options (usually in dir-locals

frozenlock14:04:56

I'll take a look, thank you very much!

frozenlock18:04:48

Is there a way to get a hold of project-dir once inside a CIDER buffer?

ghadi18:04:20

how hard would it be to make the buffer readonly when you jumped to a source within ~/.gitlibs ?

ghadi18:04:01

accidentally editing/saving something in there would be catastrophic

dpsutton18:04:28

Do You need to distinguish when in the buffer normally versus when there from navigation or is it always read only

bozhidar19:04:22

@ghadi Not hard at all. You can simply add a find-file-hook that checks the directory of the file you’re visiting and makes its buffer read-only.

bozhidar19:04:09

That’s something you can add to your global Emacs config, as it’s not really tied to CIDER in any way.

ghadi19:04:28

😎. Learned something new. Thanks!

dominicm19:04:22

It might be worth tools.gitlibs making that directory read only

ghadi19:04:49

there's no such thing

ghadi19:04:04

readonly directory means you cannot add or remove to it

ghadi19:04:12

modifying an existing file is still fair play

timvisher19:04:31

Is there a way to get println statements to go to stdout in the terminal running the main process?

timvisher19:04:53

I'm running nrepl via an embedded server.

timvisher19:04:45

(defn nrepl-handler
  []
  (require 'cider.nrepl)
  (ns-resolve 'cider.nrepl 'cider-nrepl-handler))

(defonce the-nrepl-server (nrepl-server/start-server :bind "0.0.0.0"
                                                     :handler (nrepl-handler)))

timvisher19:04:27

:dependencies [[org.clojure/clojure "1.10.0"]
                 [org.clojure/data.json "0.2.6"]                                                       
                 [org.clojure/tools.nrepl "0.2.13"]
                 [cider/cider-nrepl "0.17.0"]]

bozhidar19:04:09

> 😎. Learned something new. Thanks!

bozhidar19:04:35

You’re welcome! Btw, another thing you can do is to just put .dir-locals.el there making everything in the directory read-only. Might be even simpler.

bozhidar19:04:02

I’ve got a cool little commit that I’d like to share with all of you - https://github.com/clojure-emacs/cider/commit/fc4362a745df1ef959af579679408582167be898

bozhidar19:04:04

Now definition and documentation lookup should work even without cider-nrepl being present. That’s part of the initiative to make more of the core functionality work without middleware.

❤️ 16
dpsutton19:04:18

won't work for cljs though 😞

bozhidar19:04:02

@dpsutton Yeah, we’ll need a different code path there, but it’s perfectly doable IMO.

dpsutton19:04:15

same thing for repl utils. been meaning to raise a ticket

dpsutton19:04:50

i like the notion of fallbacks like how inf-clojure would do it

dpsutton19:04:08

really digging what parseedn will let us do

bozhidar19:04:29

The only problem with the fallbacks is that you have to inline them in the Elisp code, which is kind of annoying. When we implement the client-side nREPL code injection the clients would be able to just load a few Clojure files themselves which would be more elegant.

bozhidar19:04:44

Still, we’re making progress.

bozhidar19:04:29

Yep, parseedn opens a lot of possibilities - before this dealing with native Clojure data was so much pain… I had to convert everything to a list of strings. 😄

bozhidar19:04:12

@timvisher Did you try this?

bozhidar19:04:14

(defcustom cider-redirect-server-output-to-repl  t
  "Controls whether nREPL server output would be redirected to the REPL.
When non-nil the output would end up in both the nrepl-server buffer (when
available) and the matching REPL buffer."
  :type 'boolean
  :group 'cider
  :safe #'booleanp
  :package-version '(cider . "0.17.0"))

timvisher19:04:23

Hmm… No I didn't. Correct me if I'm wrong but if I'm cider-connecting to a running nrepl server there shouldn't be an nrepl-server buffer in play?

timvisher19:04:00

Looks like this might be closeish…

(require '[ :as io])
(with-open [out (io/writer System/out)]
  (binding [*out* out]
    (println (json/write-str {:type "SCHEMA"}))))

timvisher22:04:44

Actually I think I was wrong. That was not closesish. 🙂

timvisher22:04:53

Huh. I'm stumped. 🙂