Fork me on GitHub
#vim
<
2022-04-26
>
Dumch21:04:24

Hey, does anyone have a mapping to insert a form comment (#_)? Ideally to toggle one? I am using this now (with https://github.com/guns/vim-sexp plugin) <Plug>(sexp_move_to_prev_bracket)i#_<C-[>l=af But it only allow to insert and not toggle.

sheluchin15:04:25

There are some solutions discussed in https://clojurians.slack.com/archives/C0DF8R51A/p1638731389109100 but I'm also wondering if there are better solutions. Maybe this could be a https://clojure-lsp.io/capabilities/#refactorings?

Dumch09:04:47

@UKFSJSM38, what do you think about making it a part of lsp?

ericdallo15:04:38

This fits into a code snippet that is already possible to customize on clojure-lsp: https://clojure-lsp.io/settings/#snippets

sheluchin16:04:02

Hmm, I can see how a snippet would be used to add the discard #_, but I'm not sure I understand how a snippet could toggle the discard.

ericdallo17:04:49

yeah, the snippet would just add code not toggle or remove anything

sheluchin17:04:26

Do you think it's an appropriate candidate for an LSP refactoring? At least in my workflow toggling comments on individual elements or their parent form is a common operation.

ericdallo18:04:39

I think so, could you explain again the desired behavior?

sheluchin19:04:40

Given a form like (prn 1 2 3), have a way to toggle a discard macro in front of either one of the arguments, or in front of the whole expression.

(prn |1 2 3)
Can transformed to
(prn #_1 2 3)
Or to
#_(prn 1 2 3)
And the same action would allow going in the opposite direction to remove the discard macro. Does that match what you're thinking @UL05W6AEM?

1
ericdallo19:04:38

I see, like a cycle-comment-form code action, but that would work for current form right?

sheluchin19:04:30

Yep, that's right.

ericdallo19:04:10

sounds good, feel free to open an issue with those details on clojure-lsp

sheluchin19:04:36

Thanks @UKFSJSM38, I'll log it.

👍 1