Fork me on GitHub
#calva
<
2023-12-28
>
silian17:12:34

Suppose I want any comment form to have special background-highlight to distinguish it from code not inside comment form. Simple way to do this? Motivation: Sometimes I am navigating a file from bottom to top and I run across a form that I start to pay attention to, only to realize it's inside (comment ...) and therefore something I have as a "reference" but not a function "active" in my project. (It's a cognitive "distraction".)

pez17:12:46

It’s already italics, but that’s obviously to subtle. 😃 You can change it via the setting calva.highlight.commentFormStyle, see also https://calva.io/syntax-highlighting/#extra-highlighting.

1
❤️ 2
David Yang15:01:17

I use Joyride for this and it’s awesome: I have a Joyride script:

(defn set-comment-opacity [val]
  (.update (.getConfiguration vscode/workspace)
           "calva.highlight.commentFormStyle"
           #js {:fontStyle "italic"
                :opacity val}
           true))

(defn toggle-comment-opacity []
  (let [path "calva.highlight.commentFormStyle"
        current-opacity (.-opacity (.getConfiguration vscode/workspace path))]
    (js/console.log current-opacity)
    (if (= current-opacity "0.3")
      (set-comment-opacity "1")
      (set-comment-opacity "0.3"))))

👍 1
🆒 1
David Yang15:01:35

and then I do something like this in my keyboard shortcuts:

{
    "key": "ctrl+alt+cmd+c",
    "command": "joyride.runCode",
    "args": "(user-scripts/toggle-comment-opacity)"
  },

David Yang15:01:55

I have the exact same problem, comments throughout file, makes it hard to scan for what’s revlevant

pez15:01:12

Interesting. Maybe you can use Joyride to fold all comment forms?

pez15:01:10

I also want to promote Calva’s support for fiddle files.

David Yang16:01:52

nice, didn’t see the fiddle file thing before, will consider moving some stuff to it. The folding would be nice but seemed a bit more involved than just toggling the opacity, which works well for me