This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-31
Channels
- # announcements (20)
- # asami (14)
- # aws (6)
- # babashka (15)
- # beginners (83)
- # biff (6)
- # calva (93)
- # cider (3)
- # clj-kondo (21)
- # cljdoc (106)
- # cljs-dev (32)
- # clojure (165)
- # clojure-dev (78)
- # clojure-europe (54)
- # clojure-italy (9)
- # clojure-nl (9)
- # clojure-norway (24)
- # clojure-uk (4)
- # clojurescript (6)
- # community-development (2)
- # conjure (2)
- # core-typed (14)
- # datahike (4)
- # datomic (2)
- # emacs (40)
- # events (1)
- # fulcro (11)
- # graalvm-mobile (29)
- # graphql (8)
- # honeysql (19)
- # java (1)
- # jobs (1)
- # lsp (232)
- # malli (5)
- # membrane (112)
- # nextjournal (11)
- # off-topic (63)
- # portal (12)
- # re-frame (6)
- # reagent (3)
- # reitit (4)
- # rewrite-clj (2)
- # shadow-cljs (25)
- # tools-deps (6)
Hi all, quick question about paredit.[forward/backward]UpSexp
. I'm able to successfully move from
(def x (inc |3))
to
(def x (inc 3))|
But, if there are multiple top level s-exprs, forward and backward do not navigate further.
(def x 1)|
(def y 2)
I'd expect forwardUpSexp to move
(def x 1)
(def y 2)|
but instead the cursor does not move. Is this intended? Can it be changed?(ns test)
(def x 1)|
(def y 2)
Opening a file with only these contents has the same behaviorLatest - just installed VS code and calva today. Not sure if this is the place to find the extension version, but the Calva extension homepage says v2.0.060
Yes, and I know what it is now. VIM. Calva things that cursor is inside the paren. At least I think that's what's going on. You should be able to confirm by moving backwards sexp from that position. It should move inside the form then.
I have not figured out a way to solve it. At one level it is about not knowing that VIM is in COMMAND mode. At another level it is about knowing where the user thinks the cursors is. Because it is not where you thought it was. 😃
Actually, if I put the cursor on a blank line calva is still confused about what to do
You can actually see it in the gif when my cursor is on ln 37 - I tried to go back and forward and nothing happens
actually, a/b testing forwardSexp works at root level in Normal mode, but forwardUpSexp doesn't
If you think the feature with showing the command name is neat, you can tell me, because I added that. 😃
Best thing about that feature 😛. Otherwise you wouldn't know what I'm doing cuz I've got one off keybindings so I can remember them all.
Thanks. That looks like it work exactly as intended. Where does it not do what you expect?
Tis true. I'm trying to match my cursive settings where I use forwardSexp
to nav within sexp, when at the end of the sexp go up, and nav around top level
calva forwardSexp is contained to the sexp, so I'm trying to get a best fit with forwardUp
Sounds a bit like this one, even if it is not this one https://github.com/BetterThanTomorrow/calva/issues/1487
there's a strict version I think. I use this to quickly jump around and out. I have this bound to J, K
, but line absolute up/down/left/right commands bound to hjlk
still. I get a little absolute and a little ast behavior at once 🙂
Did you check out the video on that ticket I posted? Seems like a super quick way to move around.
I've found after alot of iteration that for me fewer more general commands get me around much quicker than actually remembering all the specific commands. That might fit the bill as well, but I've rewired my brain over the past year or two to this setup
We could maybe add some when
contexts that informs about the cursor being at the beginning/end of a list and then you could bind the same keys to forward/backwardUp
in that context as with forward/backwardSexp
in the context where it is not at the boundaries.
:thinking_face: that's a pretty good idea. I don't think that would work with vim though? Unless it respects action whens and I've not seen it yet
The potentially problematic thing with that is that @U037TPXKBGS is working on adding multicursor support and we've already seen that break havoc with some existing cursor when contexts.
I don't know anything about how the vim extension binds keys. Maybe it doesn't make when contexts available. Sound boring if it doesn't.
I was thinking in terms of settings and I don't fancy those. But a separate command makes perfect sense.
Sorry for derailing this issue for so long, not having read your original question properly!
Thanks for taking a look at this with me 🙂. Glad to know calva paredit is working as expected across oses at least 😛
How about naming the commands forward/backwardSexpOrUp
. I'm thinking that ”lax” is a bit too open for interpretation.
LMK if you'd like me to refactor out the common bits between the fwd, fwdUp, and fwdSexpOrUp
versions. I don't use typescript regularly so wasn't sure how to write that. (though I can figure it out 🙂 )
Now thinking about what might be the best approach for avoiding the duplication... Maybe something like so?
function _forwardSexpRange(
doc: EditableDocument,
offset = Math.max(doc.selection.anchor, doc.selection.active),
goPastWhitespace = false,
goPastClosingBracket = false
): [number, number] {
const cursor = doc.getTokenCursor(offset);
cursor.forwardWhitespace();
if (cursor.forwardSexp(true, true)) {
if (goPastWhitespace) {
cursor.forwardWhitespace();
}
return [offset, cursor.offsetStart];
} else {
if (goPastClosingBracket && cursor.upList()) {
return [offset, cursor.offsetStart];
}
return [offset, offset];
}
}
export function forwardSexpRange(
doc: EditableDocument,
offset = Math.max(doc.selection.anchor, doc.selection.active),
goPastWhitespace = false
): [number, number] {
return _forwardSexpRange(doc, offset, goPastWhitespace, false)
}
export function forwardSexpOrUpRange(
doc: EditableDocument,
offset = Math.max(doc.selection.anchor, doc.selection.active),
goPastWhitespace = false
): [number, number] {
return _forwardSexpRange(doc, offset, goPastWhitespace, true);
}
(Not tested)That could maybe also simplify the tests - just 1 instead of 2 or 3 that I was planning
Hi. Is there a way to tell calva to preload the namespaces of different projects? When I press f12 to navigate to the implementation of something it always opens bytecode (which is unchangable) and I have to manually open the file eval the namespace and then everything starts working as expected.
Never seen bytecode show. 😃 Does it work to first use the command Calva: Load current file and dependencies?
Doesn't help. By bytecode :rolling_on_the_floor_laughing: I mean that it opens a file in read-only mode
Some clarification. The product I am working on is made up from a whole bunch of separate projects.
Yeah this happens to me too, always thought this was just an accepted limitation. For me, if I hover over the editor tab it reveals that the filepath of the readonly file is within what I assume is the local maven cache. I'm not at my computer currently, but that's more or less what I recall it being. It doesn't open the actual file in my monorepo.
I am depending on the other projects. What I have seen colleagues using intellij do is that they import all projects separately via the editor somehow.
Having some fun: https://twitter.com/pappapez/status/1509571419188994048