pyjarrett / septum

Context-based code search tool
Apache License 2.0
374 stars 7 forks source link

[Feature] Use XDG directories for config files on Linux #37

Open onox opened 2 years ago

onox commented 2 years ago

Is your feature request related to a problem? Please describe. septum init creates a file .septum/config in the current working directory, but I would like to create it relative to the home directory.

Describe the solution you'd like When Septum tries to create .septum/config in the home directory, it should instead store it relative to $XDG_CONFIG_HOME. If this environment variable is not defined, it should have the value $HOME/.config. Thus the full path becomes $HOME/.config/septum/config.

Similarly, cache files (don't know if Septum has any) could be relative to $XDG_CACHE_HOME (which is by default $HOME/.cache).

onox commented 2 years ago

I can try to implement this if you can tell me how to tell Septum to create the file in the home directory instead of the current working directory :slightly_smiling_face:

pyjarrett commented 2 years ago

Maybe there should be a crate for doing this? This isn't part of the Ada standard lib and I ran across similar code in Alire yesterday to do this.

onox commented 2 years ago

I think it's just a matter of using Ada.Command_Line.Environment?

Edit: hmm, maybe it's a good idea to create a crate for it.

onox commented 2 years ago

Might not be needed: Ada.Environment_Variables.Value does the job.

onox commented 2 years ago

So it's something like this:

Env_Home           : constant String := Ada.Environment_Variables.Value ("HOME", "~");
Env_XDG_Config     : constant String := Ada.Environment_Variables.Value ("XDG_CONFIG_HOME", Env_Home & "/.config");
Septum_Config_Path : constant String := Env_XDG_Config & "/septum/.config";