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

Define configuration format #434

Open
lovesegfault opened this issue Aug 25, 2019 · 16 comments
Open

Define configuration format #434

lovesegfault opened this issue Aug 25, 2019 · 16 comments
Labels
enhancement New feature or request

Comments

@lovesegfault
Copy link

lovesegfault commented Aug 25, 2019

Right now the configuration file's format is a weird JSON variation with // comments, at least as I understand it.

It'd be nice if we, instead, used a more config-friendly format (such as TOML or even YAML) that allowed for things like comments. Moreover, it'd be useful if the file was called config.json or config.toml so that editors can pick-up the filetype automatically.

I'll leave a link to an article I enjoy on why JSON is a poor choice for a configuration language: https://www.lucidchart.com/techblog/2018/07/16/why-json-isnt-a-good-configuration-language/

@cafehaine
Copy link

That would mean breaking the compatibility with all installs of waybar. The user-base might be small, but this still would cause a lot of troubles.

@lovesegfault
Copy link
Author

lovesegfault commented Aug 26, 2019

@cafehaine Not necessarily, the old config could remain, but be removed from wiki/readme and left alongside the TOML one for some time. If you load the old config format it works with a deprecation warning.

A breaking change nonetheless, but with a nice adaption period.

@Alexays Alexays added the enhancement New feature or request label Aug 29, 2019
@asmigala
Copy link

The great thing about yaml is that you can actually use a yaml parser to parse json. So that would kind of ensure backwards compatibility with older configs, the only problem being the // comments.

A dirty way to convert old config to yaml:

cat ~/.config/waybar/config | sed 's|//.*$||' | yq -y .

(this won't work if you have // in a string somewhere, but you get the idea)

@eoli3n
Copy link

eoli3n commented Dec 12, 2019

+10 i'm really confused about that choice...

@eoli3n
Copy link

eoli3n commented Dec 30, 2019

Toml is a bad choice too : https://hitchdev.com/strictyaml/why-not/toml/
Yaml is still the easier and cleaner human readable configuration language and would be a great choice for that kind of project.

@lovesegfault
Copy link
Author

@eoli3n Agree to disagree and I'll avoid bikeshedding this 😆

@WhyNotHugo
Copy link
Contributor

FWIW, current format is just "a JSON variation", it's called jsonc, and actually used by plenty of tools. So I wouldn't discredit is as non-standard.

@eoli3n
Copy link

eoli3n commented Feb 11, 2021

Any news ?

@ghost
Copy link

ghost commented Oct 6, 2021

FWIW, current format is just "a JSON variation", it's called jsonc, and actually used by plenty of tools. So I wouldn't discredit is as non-standard.

I was only able to find that VS Code uses this format for configuration. What other tools were you talking about here?

@WhyNotHugo
Copy link
Contributor

Off the top of my head, nvim-coc uses jsonc, as do flatpak manifests (example). I guess waybar also counts on this list really. There's plenty of libraries for working with jsonc in various languages too.

I'm sure I've seen other applications, but my memory is bad.

Most of these tools use the .json extension, which is a bit annoying since editors are bad at figuring out it's actually jsonc.

I don't think popularity is that important though; it's very easy to explain that jsonc is just "json with comments", and it's not like end users have to learn an entirely new format.

That said, I don't disagree with the initial criticism of JSON. But there's also a lot of valid criticism for YAML (e.g.: type handling). TOML is bad for highly nested structures, or when you have a large set of files that share a schema. For a configuration format like waybars, it's actually not a bad candidate.

Ultimately though, I think this falls into bikeshedding a bit. A PR showing pros and cons of a change is probably best at this point.

@liiil825
Copy link

liiil825 commented May 14, 2023

I think it is unnecessary to criticize json or jsonc now, but it is necessary to add support for yaml files, and the format of yaml is obviously more beautiful

@sascha-wi
Copy link

sascha-wi commented Feb 23, 2024

It boggles my mind that I can't get syntax highlighting...

@xmalbertox
Copy link

It boggles my mind that I can't get syntax highlighting...

May I ask which editor you use? For vim you can use the jsonc syntax highliting by installing vim-polyglot.

@wille
Copy link

wille commented Jul 31, 2024

+1 for yaml configuration

@sascha-wi
Copy link

It boggles my mind that I can't get syntax highlighting...

May I ask which editor you use? For vim you can use the jsonc syntax highliting by installing vim-polyglot.

Did you read this issue thread at all?

@yvvki
Copy link

yvvki commented Nov 5, 2024

I just wanted to ask if we can have a defined schema too, especially in the current JSON config. The schema can be included in with the $schema key (See https://json-schema.org/).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests