Fork me on GitHub
#emacs
<
2023-03-11
>
Joseph Graham10:03:03

Good morning all! Does anybody know why I'm getting this indentation? Using clojure-mode, paredit rainbow delimiters.

practicalli-johnny14:03:50

If you can share the code then we can try replicate. Seems unusual indentation to me though.

Joseph Graham14:03:10

(defn render-due-tasks []
  (let [tasks (r/atom {:error nil :items []})
        fields (r/atom {:color "" :task_id #{}})
        pagename (.-value (.getElementById js/document "pagename"))]
    (update-tasks tasks pagename)
    (fn []
      ;; when it re-paints, we need to reset the checkboxes
      (swap! fields #(assoc % :task_id #{}))

      [:div
       [:table
        [:colgroup
         [:col {:style {:width "2em"}}]
         [:col {:style {:width "100%"}}]]
        [:tbody
         (for [task (:items @tasks)]
           ^{:key task}
           [:tr (when
                    (:highlight task)
                  {:style {:background-color (:highlight task)}})
            [:td [:input {:type "checkbox"
                          :name "task_id"
                          :value (:task_id task)
                          :on-change #(toggle-checkbox fields %)}]]
            [:td (:task_name task)]])]]
       [:p {:style {:color "red"}} (:error @tasks)]

       ;; delete button
       [:button {:on-click #(delete-tasks fields tasks pagename)} "delete"] " "

       ;; highlight button
       [:select {:name "color"
                 :on-change #(handle-highlight fields % tasks pagename)}
        [:option {:value nil} "highlight"]
        (for [color (keys shared/colormap)]
          ^{:key color} [:option {:value color} color])]

       ;; defer button
       [:select {:name "defer" :on-change ()}
        [:option {:value nil} "defer"]
        ]
       ])))

practicalli-johnny14:03:00

Curious. When I format the above code with cider-format-buffer (with the REPL started) then I get what I consider the correct indentation

[:tr (when
      (:highlight task)
       {:style {:background-color (:highlight task)}})
However, RTN after the when form positions the cursor further indented, exactly as your example To me this suggests either lsp (cljfmt) or clojure-mode is causing the different indentation (although I dont know why that would be the case) Personally I'd move the when condition to the same line and try forget about the unusual indent
(when (:highlight task)
 ,,,)

Joseph Graham15:03:03

yep I guess that's nicer

vemv15:03:50

whenever you get a unusual indent, it can be considered clojure-mode's way of telling you that the newline placement wasn't that idiomatic

practicalli-johnny17:03:18

@U45T93RA6 Is that a specific feature of clojure-mode (I couldnt find any docs) or a consequence of clojure-mode not having an applicable rule to apply? Or perhaps a general tip from experience? Thanks.

Derek19:03:35

Has anyone played around with elpaca? https://github.com/progfolio/elpaca

Akiz19:03:48

Hi, does anyone know why I don’t get Clojure documentation with Corfu (popupinfo)? I am running Eglot and Cider…

elken20:03:05

You're hovering over a snippet

Akiz20:03:50

@U043RSZ25HQ What do you mean? I am calling corfu-info-documentation which returns “No documentation available for …“.

elken20:03:31

The candidate you're selecting is a snippet, it doesn't have any docs

Akiz20:03:27

Ah, that’s just an example, it doesn’t work anywhere. (however, C-c C-d d works over snippets, so I wouldn’t mind if Corfu could do it too)

Akiz20:03:59

@U043RSZ25HQ If it works for you, could you share your configuration 🙏?

elken21:03:50

I don't use eglot but my doom config is here: https://github.com/elken/doom

bozhidar09:03:46

@UBRV1HXPD It's possible we haven't implemented something required in CIDER. This doc integration had a special API in Company mode, not sure how the situation looks in Corfu.

bozhidar09:03:51

I've yet to try it.

Akiz09:03:04

@U051BLM8F To be honest, I don't care about Cider much. I'd prefer it to work with clojure-lsp and eglot. That is, to have documentation even when the repl isn't running.

bozhidar09:03:10

Fair enough. I can't comment on the integration between elgot and corfu, though, as I've never used them.

👍 2
elken09:03:33

Seems to be an eglot problem, in a vanilla emacs with clojure-mode, lsp-mode & corfu everything works fine