Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISCUSSION] Descisions about a formatter for yuck #1287

Closed
DOD-101 opened this issue Feb 13, 2025 · 2 comments
Closed

[DISCUSSION] Descisions about a formatter for yuck #1287

DOD-101 opened this issue Feb 13, 2025 · 2 comments

Comments

@DOD-101
Copy link

DOD-101 commented Feb 13, 2025

Greetings all! Hope you are having a lovely day.

I have taken it upon myself to write a formatter for yuck. After some discussion in #1241 & #1232 and a great suggestion by @elkowar to use Tree Sitter for a formatter, I came across topiary.

It's a great tool to create simple formatters using Tree Sitter queries, which is exactly what I have done.

Now I come to you, everyone using eww, to ask for your input.

Q 1:

Formatting Style:

There are two prominent formatting styles, that I can think of, both of which are already in use in the eww examples:

(defwidget animalButton [emoji]
  (box
    :class "animalLayout"
    (eventbox
      :class `animal ${selected == emoji ? "selected" : ""}`
      :cursor "pointer"
      :onhover "eww update selected=${emoji}"
      emoji
    )
  )
)

or

(defwidget animalButton [emoji]
  (box
    :class "animalLayout"
    (eventbox
      :class `animal ${selected == emoji ? "selected" : ""}`
      :cursor "pointer"
      :onhover "eww update selected=${emoji}"
      emoji)))

Which of these do you prefer, and are there any other formatting nit-pics that you would like addressed?

For the current formatting style, you can check out my eww config in my dotfiles here.

Q 2:

Assuming topiary would be willing to have the yuck query files in upstream, would you prefer to have them there, or as a separate repo?

Having a separate repo would allow for more freedom at the cost of a slightly more cumbersome install.

@elkowar
Copy link
Owner

elkowar commented Feb 16, 2025

I would very strongly argue in favor of the second syntax -- once you got used to that, it's 100x nicer to work with than the first version.

I'd also optimally advocate for the style that I've been using throughout, which is

(thing :property1 "foo"
       :another "thing"
  child1
  child2)

I think having a separate repo would likely be nicer to maintain -- technically, packages could still package both tools together. It'd still be easily possible to merge a potential formatter into this repo after the fact, once something has been stabilzed

@DOD-101
Copy link
Author

DOD-101 commented Feb 23, 2025

Thank you for your input. Sadly, your second request doesn't seem possible using topiary.

topiary-yuck

@DOD-101 DOD-101 closed this as completed Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants