This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-13
Channels
- # ai (5)
- # announcements (4)
- # babashka (34)
- # beginners (78)
- # biff (6)
- # calva (41)
- # cider (47)
- # clerk (1)
- # clj-commons (3)
- # clj-http (1)
- # clojure (72)
- # clojure-europe (51)
- # clojure-nl (1)
- # clojure-norway (87)
- # clojure-romania (1)
- # clojure-uk (5)
- # clojuredesign-podcast (2)
- # community-development (1)
- # conjure (2)
- # cursive (11)
- # datomic (6)
- # docker (4)
- # emacs (13)
- # exercism (20)
- # hyperfiddle (56)
- # matrix (6)
- # membrane (4)
- # nbb (11)
- # off-topic (88)
- # pathom (7)
- # pedestal (1)
- # polylith (20)
- # portal (16)
- # practicalli (1)
- # re-frame (13)
- # reagent (4)
- # reitit (2)
- # remote-jobs (7)
- # shadow-cljs (49)
- # sql (4)
What is a good way to have a command that removes a comment literal #_
before a form, from the relative cursor location/selection inside the code to be disabled.
I am used to using ;
comments liberally (in cursive) to temporarily disable code, but without reliable parinfer, they break my code if it is a line with trailing brackets.
Plus they turn off some of the linting and navigation links I would prefer to have active.
(rich comment code can be production ready and ready to eval)
I want to use a keyboard shortcut to easily toggle on/off entire forms (ideally at multiple levels: current token, current form, top-level form; like the repl eval contexts)
I currently have a working vscode snippet to add symbol before form: #_ (myfn ...)
. But removing it seems more like a refactor action.
Also, adding #_
in front can mess with indenting logic. So a proper solution would consider the calva formatter..?
I'm not aware of Calva directly supporting that action, but it looks like the Joyride docs have an example a of a script which toggles #_
:
https://github.com/BetterThanTomorrow/joyride/tree/master/examples#structural-editing
I was about to suggest you look at that example. Noticing that we don’t link as we should to the actual example: https://github.com/BetterThanTomorrow/joyride/blob/master/examples/.joyride/scripts/ignore_form.cljs I hope you add formatting and file a PR for updating the example. 😃 Let me know if you need any assistance.
Any idea why [x]
always gets highlighted in my source code?
does the highlight go away if you have (defn foo [x] x)
? If so, the highlight is likely warning that the variable is unused. You can silence this by using x
or renaming it to _x
or just _
indicating you are aware it is unused and intend it to not be used
No, it's always there
I guess that depends on what it refers to. The yellow squiggle disappeared. 😃
I eerily recognize the problem, but can’t reach to where in my memory that would be stored… A few suggestions:
1. Is there hover info about it?
2. Is it just [x]
that this happens with, or does it happen with [y]
, or [x y]
too?
3. There’s an inspector something something Tokens and Scopes something something, that you can start from the command palette. See if it says something special about this token.
4. See if it happens with another theme.
5. If you haven’t installed VS Code Insiders, that will be a completely fresh install, with no settings and extensions. So that is a way to test if it is settings or extensions that causes this.
a. If you don’t see it in a fresh VS Code Insiders you can start bisecting.
i. Copy everything in regular VS Code’s settings.json
to Insiders. (There’s a VS Code command for opening user settings.) If it appears, you know it is a setting. If it doesn’t appear, it could be an extension.
b. If you are at where you now suspect an extension, it is probably easier to go back to regular VS Code and start Extension Bisect. It’s available from the command palette as well as from the meatballs menu in the Extensions panel.
Now I ran out of ideas. Need more coffee. I can recommend Stuart Halloway’s talk about Sherlock Holmes. Haha.
Thanks @U0ETXRFEW! I'll follow your steps. Meanwhile, the highlighting only appears if the [x]
is on an new line. Does not happen with [y]
That’s interesting. My main suspect is now an extension. I’m pretty sure it isn’t Calva, even though it is a bloat of an extension. 😃
It happens in any file!
And I found the culprit. It is the extension "Todo Tree".
It sure does!
(wrapped because outer light brackets become invisible)
It seems to think it's a markdown TODO. Maybe I need to look at this
Sweet! If you want to keep the highlight in markdown lists, Github style, maybe it is the sole ^
regex alternative there that you should remove.
Parens are a gift...
After 5 years it didn’t 😅 actually I had a idea whether Clojure can be read without parens thus my question ;)
Interesting! If you find something, please let us know. Are you talking about only parens here, or is it curlies and hard brackets too? I’m trying to imagine reading Clojure code totally without brackets, and I fail. 😃
I don’t think you can make do without them completely, but you could make them very faint in the theme I guess. Parinfer kind of turns Clojure into an indentation-based language, but even so I wouldn’t want to not see them. Paren balancing can still get screwed up when copying/pasting. Still, it would be theoretically interesting to turn them off completely and only show them if there’s a balancing error.
Right fun exercise to make. I will try to play with theme settings and we will see how it gonna work ;)
Some really nice https://code.visualstudio.com/updates/v1_83. My favorites: • Option for having pinned tabs on separate row ◦ Compact tab height is also nice. Especially in combo with the above. • Debugger controls in the command center (it has been such a big annoyance to me to keep moving this around so that it doesn’t hide anything) There is also an upcoming change that will change everything. https://code.visualstudio.com/updates/v1_83#_floating-editor-windows-exploration!
The floating editor windows highlights my main grudge with the VS Code UI: Special layout for different content categories. Editors can only go to some places, panel content only to some. There is a thing that is Sidebar contents. And so on. Means I can’t arrange my content however I want. It’s totally unecessary. https://theia-ide.org/ proves this. Now when the VS Code team will deliver what must be the most wanted feature in a VERY long time, it will soon be followed by requests from people who want to float the Problems view. Or the File Explorer. Or the terminals (that may actually come out of the box, because they allow us to place terminals in the place for EDITORS) . Or the Debug console. Or… Why, oh, why have it like this? Yes, I should bring this to the VS Code team and not rant about it here. Thing is I have. https://github.com/microsoft/vscode/issues/68831. They closed it.
How could I set a binding such that RCF tests always evaluate when run from a REPL thread but not the main thread that is loading the namespaces?
it is a tool to keep tests out of prod and inhibit execution on namespace load, particularly tests in libraries
it is supposed to be controlled at the entrypoint, but if the test is sent to the REPL thread you always want it to run
Is there a way to test if a namespace is being loaded in the repl? If so we could do (rcf/enable! (is-repl?))
.
Otherwise. How about this keybinding?
{
"key": "ctrl+alt+c ctrl+alt+enter",
"when": "calva:connected",
"command": "runCommands",
"args": {
"commands": [
{
"command": "calva.runCustomREPLCommand",
"args": "(clojure.core/refer-clojure) (require 'hyperfiddle.rcf) (hyperfiddle.rcf/enable! true) (println \"rcf tests enabled\")"
},
{
"command": "calva.loadFile"
},
{
"command": "calva.runCustomREPLCommand",
"args": "(hyperfiddle.rcf/enable! false) (println \"rcf tests disabled\") *3"
},
]
}
}
It gets a bit chatty in the output window. The following output is from a fresh jack-in:
1. Loading a namespace which doesn’t have any rcf-tests, but that requires one that has
2. Loading the same namespace again
3. Loading the namespace that has the rcf-tests
; Jack-in done.
clj꞉user꞉>
; Evaluating file: without-rcf-tests.clj
clj꞉some.namespace.without-rcf-tests꞉>
rcf tests enabled
nil
clj꞉some.namespace.without-rcf-tests꞉>
✅✅✅✅:last-form-in-the-file
clj꞉some.namespace.without-rcf-tests꞉>
rcf tests disabled
:last-form-in-the-file
clj꞉some.namespace.without-rcf-tests꞉>
; Evaluating file: without-rcf-tests.clj
rcf tests enabled
nil
clj꞉some.namespace.without-rcf-tests꞉>
:last-form-in-the-file
clj꞉some.namespace.without-rcf-tests꞉>
rcf tests disabled
:last-form-in-the-file
clj꞉some.namespace.without-rcf-tests꞉>
clj꞉some.namespace.with-rcf-tests꞉>
; Evaluating file: with-rcf-tests.clj
rcf tests enabled
nil
clj꞉some.namespace.with-rcf-tests꞉>
✅✅✅✅:rcf
clj꞉some.namespace.with-rcf-tests꞉>
rcf tests disabled
:rcf
clj꞉some.namespace.with-rcf-tests꞉>
Am I not supposed to be able to "Go to definition" from the usage of fs
here?: https://github.com/matthiasn/meins/blob/main/src/cljs/meins/electron/main/screenshot.cljs#L3C20-L3C20
I'm getting a "No definitions found for fs" message
Opening this file with Cursive, on the usage of fs
there and doing "Go to declaration" points me at an external library under the name folder Leiningen: org.clojure/clojure:1.10.1 where it has the JAR clojure-1.10.1.jar which says google-closure-library something, and it's doing var fs = require('fs');
, which looks like some kind of library that wraps Node.js API