zed icon indicating copy to clipboard operation
zed copied to clipboard

Add parinfer

Open cap10morgan opened this issue 1 year ago • 3 comments

Check for existing issues

  • [X] Completed

Describe the feature

In #5292 @shaunsingh mentioned that it would be nice to have parinfer when editing Clojure. And I think that's a splendid idea. That issue was closed with a request to make additional issues for anything else that came up in those comments.

At a very basic level, parinfer infers where to nest code based on its indentation. So e.g. if I have this:

(foo "bar")

...and then want to add new arguments to that fn call on the next line, I just indent them at least one space to the right and parinfer moves the closing ) to the that line. So you end up with:

(foo "bar"
 "baz")

...just by typing [space]"baz" on the second line. That's a very simple example; it does a whole lot more than that. But hopefully that gets the basic idea across.

There is a Rust implementation at https://github.com/eraserhd/parinfer-rust.

Ideally it would be good to have parinfer's "smart mode."

This is hugely helpful for Lisps like Clojure, but can be really nice in other kinds of languages too.

The major alternative (and older) approach to this–and honestly one preferred by a lot of Lispers–is called paredit. It's a much more explicit system where keyboard shortcuts are used to manipulate the abstract syntax tree represented by the nested Lisp data-as-code-structures. I only mention it here to point out that it does not fulfill this request and if anyone wants it, they should feel encouraged to open a separate issue for it. :)

If applicable, add mockups / screenshots to help present your vision of the feature

No response

cap10morgan avatar Feb 15 '24 15:02 cap10morgan

Amazing to see Clojure support in Zed. Seconding that Parinfer support would be fantastic.

eneroth avatar Feb 22 '24 20:02 eneroth

Reading the extension dev docs, I'm not sure it's currently possible to add parinfer (i.e. https://github.com/eraserhd/parinfer-rust) via an extension. Wondering if a Zed dev could let us know one way or another?

cap10morgan avatar Feb 23 '24 17:02 cap10morgan

No, the current scope of extensions is quite limited:

Extensions currently support language syntax highlighting and themes, and we're actively working to add language server support.

Extension points other than that will be further away most likely.

eneroth avatar Feb 26 '24 07:02 eneroth