ron icon indicating copy to clipboard operation
ron copied to clipboard

Is there a formatter/linter for Ron?

Open sashinexists opened this issue 2 years ago • 12 comments

Is there a formatter or linter for ron available for vscode? The vscode-ron extension seems to do syntax highlighting but not formatting.

sashinexists avatar Apr 17 '22 16:04 sashinexists

I haven't seen any. It would be great to have!

kvark avatar Apr 18 '22 04:04 kvark

Yeah, and there could also be a ron::to_string_pretty()!Do you know how one would go about this? Would it just take a lot of regex and elbow grease?On 18 Apr 2022 2:03 pm, Dzmitry Malyshau @.***> wrote: I haven't seen any. It would be great to have!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

sashinexists avatar Apr 18 '22 05:04 sashinexists

There is ron::ser::to_string_pretty If you were looking for that :)

juntyr avatar Apr 18 '22 06:04 juntyr

Hello. There exists a formatter I have been using privately, it's based on an alternative RON implementation. I have now uploaded it here, including static binary files from the two platforms I use. Here is the link: https://gist.github.com/d86leader/c6d10e0fd329c75925cd42c8fc9ab7d5

P.S.
I also have it on good intel that the author of that alternative implementation will in the near future be releasing a ron-multitool with formatting and selecting different fields and other stuff. ;)
It should have come out in the early spring, but the war has delayed the plans.

maurges avatar May 18 '22 14:05 maurges

Can ron::ser::to_string_pretty and ron::ser::PrettyOptions be exported in lib.rs like ron::ser::to_string is (to make it accessable at ron::to_string_pretty), or is there a reason that is isn't?

Type1J avatar Jan 03 '23 17:01 Type1J

It definitely could, though I'm personally a bit sceptical of having too many items in the root module. If this is mainly about discovery, we could perhaps link to to_string_pretty in to_string's documentation.

juntyr avatar Jan 04 '23 08:01 juntyr

If that's a concern, then a documentation link may be the best solution.

I'm not sure how you'll address it, but here's my thoughts on the matter: I knew that to_string_pretty existed from the documentation, but it took me a while to realize that where I had imported ron::to_string should have been ron::ser::to_string before I could import both at the same scope like ron::ser::{to_string, to_string_pretty} .

Type1J avatar Jan 09 '23 18:01 Type1J

I also have it on good intel that the author of that alternative implementation will in the near future be releasing a ron-multitool with formatting and selecting different fields and other stuff. ;)

Any updates on that? I just started working on my own ron formatter (but in rust) but would be interested in any other implementations.

ModProg avatar Mar 12 '23 19:03 ModProg

If that's a concern, then a documentation link may be the best solution.

I'm not sure how you'll address it, but here's my thoughts on the matter: I knew that to_string_pretty existed from the documentation, but it took me a while to realize that where I had imported ron::to_string should have been ron::ser::to_string before I could import both at the same scope like ron::ser::{to_string, to_string_pretty} .

#440 finally adds some docs improvements and I've made the to_string_pretty more prominent in the README.

juntyr avatar Mar 13 '23 07:03 juntyr

This seems like an only option to format ron files atm: https://github.com/barafael/ronfmt

makscee avatar Aug 15 '23 13:08 makscee

This seems like an only option to format ron files atm: https://github.com/barafael/ronfmt

There is also ronda: https://github.com/ModProg/ronda I had written some time ago.

While it doesn't support any configuration, it preserves comments and can format either a list of files ronda *.ron or can format stdin cat file.ron | ronda > file.ron.

While I pushed some changes I made a while ago right now, I'm probably not really continuing this project for now, as I'm considering replacing my ron usages with rsn. Though I am always open for contributions.

ModProg avatar Aug 23 '23 09:08 ModProg

I was able to install ronfmt via cargo install ronfmt. Then I installed the VSCode extension Run on Save and configured it in settings.json like this:

"emeraldwalk.runonsave": {
    "commands": [
      {
        "match": "\\.ron$",
        "ronfmt ${file}"
      }
    ]
  }

Idk, just wanted to share this in case people find it useful.

tadeohepperle avatar Sep 27 '23 18:09 tadeohepperle