Closed phiresky closed 1 year ago
Would solve #53, #42, #47, #38, #36, #28, #14, possibly #52.
Type: Reply 💬
It would be nice, if format of configuration file will not JSON.
In my opinion YAML is the best config format for human editing; TOML is a good alternative.
I already wrote 9 issues about this problem for another tools. Example; another issues referenced below.
Thanks.
Counterpoints:
YAML is a bad format with many unexpected caveats and questionable design decisions. Especially that e.g. hello: on
is interpreted as on being a boolean instead of the string "on".
"Anyone who uses YAML long enough will eventually get burned when attempting to abbreviate Norway."
Example:
NI: Nicaragua NL: Netherlands NO: Norway # boom!
NO
is parsed as a boolean type, which with the YAML 1.1 spec, there are 22 options to write "true" or "false."
Sources: https://github.com/cblp/yaml-sucks https://www.arp242.net/yaml-config.html
TOML is ok, though the array syntax is fairly weird and it is very unknown outside of the Rust community
ini is very restricted and defining arrays is not possible without syntax additions
JSON has a restricted and simple syntax
Is the only format (apart from JSON) I know of that , and has integrated and automatic support of schema validation and autocomplete in a major editor (VSCode).
See these screenshots:
I'd love to use a different format, I'm looking at JSON5, but so far I've not really found a worthy replacement.
Specifically, the format "JSON with comments" (extension jsonc) is supported well in VSCode:
Sure, but only if you manage to get your Automatic settings UI editor to work. I'd love to ship a html file so I can add a rga --config-ui
command that just opens a GUI editor of the configuration.
Type: Reply 💬
Did you try StrictYAML? Rust implementation (I didn’t test it).
Refusing to parse the ugly, hard to read and insecure features of YAML like the Norway problem.
YAML is a bad format with many unexpected caveats and questionable design decisions. Especially that e.g. hello: on is interpreted as on being a boolean instead of the string "on".
I don’t think, that YAML (issue) or ruamel.yaml (issue) is ideal, but:
JSON has a restricted and simple syntax
Simple example:
YAML:
custom_adapters:
- name: calibre
JSON:
{
"custom_adapters": [
{
"name": "calibre"
}
]
}
Extra symbols (1 -
for YAML) for this small example:
TOML (…) is very unknown outside of the Rust community
May I ask what this opinion is based on?
Currently, on 9 June 2020, GitHub has 156 thousands TOML code results; most matches of toml
word on Python. Also, TOML has 13,6 thousands GitHub stars.
I don’t think, that TOML is “very unknown”.
Some Node.js projects have a cosmiconfig dependency. Users of these projects can have YAML, JSON or JavaScript configuration (see official repository for details) files.
Confinode also can support another formats, include TOML.
Is something like this possible in Rust? So that ripgrep-all users themselves can choose preferable config format.
I found (but not tested) config-rs Rust repository.
Read from JSON, TOML, YAML, HJSON, INI files
Possibly, it may help.
Thanks.
This will be added in 1.0.0 and is already present in 1.0.0-alpha.4
Since there's many feature requests for different file formats now, many of which do not have corresponding nice and fast Rust libraries, I think the best solution is to allow specifying "custom" preprocessors via a config file.
This comes with the question about how this would differ than just using
rg
with the--pre
directive directly:Future additions that might be possible here (no promises) that will probably not appear in rg core are:
The baseline implementation of this should be pretty easy, more features can be added later. Main decision is the config file format, whether or not to change existing SpawningFileAdapters to build on top of this and how to document it.