dan-t / rusty-tags

Create ctags/etags for a cargo project
Other
408 stars 32 forks source link

Support XDG base directories spec for reading config file #93

Open Lehmanator opened 18 hours ago

Lehmanator commented 18 hours ago

The configuration is currently loaded from the file at the path: ~/.rusty-tags/config.toml, which doesn't comply with the XDG Base Directories specification.

On Linux, a compliant program would read the configuration directory base path from the environment variable $XDG_CONFIG_HOME, which is set to the directory ~/.config by default. So the new default config path would be: ~/.config/rusty-tags/config.toml.

This program uses the dirs crate, which makes it easy to support the spec, using the appropriate directories across platforms.

Currently, there is a call to dirs::home_dir(), which can be replaced with a call to dirs::config_dir() to get the XDG spec compliant base directory.

Not sure how much fallback to the existing config path would be desired or if the program also uses the ~/.rusty-tags directory for things other than config (like cache & data) that would also need to be moved to comply with the spec.

I can make a PR to implement this if necessary.

dan-t commented 11 hours ago

Hi Sam,

I‘m fine with a PR.

It should just work, regardless where the config file lies. If a config file is at both places it should result in an error. The caching can be moved according to the XDG spec and the old cache should be deleted.

Greetings, Daniel