Replies: 2 comments 5 replies
-
Note that Personally (I'm an Emacs user primarily) on the rare occasions that I need something like Or to put it another way, as I see it, In any case, I don't expect to add the |
Beta Was this translation helpful? Give feedback.
-
Thanks for this suggestion! It is on my TODO since a while to have a look at how we could improve drag fwd/back, inspired by clojure-lsp's amazing treatment of the feature. Super well done! Also thanks for the overview and details offered. This would have taken me much time to figure out on my own. If we can expose clojure-lsp's drag operations as commands, then users can configure their keyboard shortcuts to prefer it over Calva's implementations. I think that is the best way to approach this with a minimal effort spent, since Calva will need to support this even when clojure-lsp is not running. Side-note: With more effort spent on this I would want to make clj-kondo analysis available to Calva. With that we could could enhance a lot of the structural awereness in Calva, and one place we could benefit from it would be to spiff up dragging. Please file an issue about this, @mainej. I suggest framing it as something like ”Enable users to bind keyboard shortcuts to clojure-lsp drag sexp commands”. And, of course, please consider contributing the implementation in Calva. 🙏 |
Beta Was this translation helpful? Give feedback.
-
I'd like to propose that Calva use
clojure-lsp
'sdrag-forward
anddrag-backward
commands as replacements for its current implementation. Theclojure-lsp
's version offers a few improvements over Calva's:clojure-lsp
uses context to decide how many elements to group together in a clause. Calva does this too, but I thinkclojure-lsp
handles a few more cases:binding
,doseq
,for
,let
,loop
,with-local-vars
,with-open
,with-redefs
.clj-kondo
analysis. This allows library- and user-defined code to participate in pair-wise movement by declaring that it establishes bindings via, for example,:lint-as {my.ns/my-let clojure.core/let}
. This is also the current mechanism of supporting pairwise movement within:let
forms infor
expressions.cond
,cond->
,cond->>
,assoc
,assoc!
andcase
. These are all careful to avoid dragging ineligible elements—for example in(cond-> {} a (assoc :a 1) b (assoc :b 2))
, thecond->
and{}
are not eligible. The optional final default expression incase
is not eligible. All of these—aside fromcond
—occasionally appear in threading expressions. When they do, the eligible elements are adjusted.condp
, or triples of elements in its ternary form. The first three elements are ineligible, as is the final default expression when present.clojure.test/are
, based on the number of args in the template.I'm the author of the
clojure-lsp
implementation, so whether or not it's a good fit for Calva, I'd love bug reports or feedback on ways it could be better. If the descriptions above aren't clear, there are pretty extensive tests starting here. If usingclojure-lsp
's version isn't feasible for some reason, feel free to borrow these features. Calva was the first editor that I'm aware of that did Clojure-aware dragging, and so I think it's only fair thatclojure-lsp
shares.Cheers!
Beta Was this translation helpful? Give feedback.
All reactions