zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.79k stars 3.15k forks source link

Add parinfer #7843

Open cap10morgan opened 9 months ago

cap10morgan commented 9 months ago

Check for existing issues

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

eneroth commented 9 months ago

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

cap10morgan commented 9 months ago

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?

eneroth commented 9 months ago

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.