lazygit/pkg
Blake Williams 59f0650173 Add support for ~/.config/lazygit without setting XDG_CONFIG_HOME
Currently lazygit looks for its config file in `XDG_CONFIG_HOME` if it's
available, but if not it falls back to the defaults defined by the
[xdg](https://github.com/adrg/xdg) package. Unfortunately the defaults
the package falls back to isn't what CLI applications commonly fall back
to on macOS. Specifically, it looks in `~/Library/Application Support`
instead of `~/.config`.

This updates the app config logic to:

- Look for `~/.config/lazygit` first if `XDG_CONFIG_HOME` is not set
  and we're on macOS.
- Fallback to the existing `xdg` package location if the configuration
  file exists there.
- Default to `~/.config/lazygit/config.yml` if `XDG_CONFIG_HOME` is not
  set, we're on macOS, and there is no existing configuration file.

This change did feel a bit like having to thread a needle and I didn't
see any existing tests for this behavior (which is reasonable, since it's
complicated and OS dependent) so I did test a few variations of the
configuration locally by building with this change included and running
a `brew` installed lazygit.

It seemed to work properly, falling back to the existing location when
`XDG_CONFIG_HOME` isn't set, using `~/.config/lazygit` when `config.yml`
is present, and creating `~/.config/lazygit/config.yml` when it's not.

I think this should resolve https://github.com/jesseduffield/lazygit/issues/1341
2024-12-31 13:38:55 +11:00
..
app Fix moving a commit across a branch boundary in a stack 2024-12-23 12:18:48 +01:00
cheatsheet Initialize translation set after reading user config 2024-08-18 10:24:52 +02:00
commands Fix hang when returning from shell command 2024-12-28 14:53:57 +01:00
common Make common.UserConfig an atomic.Pointer for safe concurrent access 2024-08-18 10:24:52 +02:00
config Add support for ~/.config/lazygit without setting XDG_CONFIG_HOME 2024-12-31 13:38:55 +11:00
constants Make the links in the status panel point to the current version rather than master 2024-03-22 08:13:59 +01:00
env
fakes
gui Don't preserve commit message when it's unchanged from initial message 2024-12-23 12:28:52 +01:00
i18n Allow deleting a merge commit 2024-12-23 12:12:45 +01:00
integration Don't preserve commit message when it's unchanged from initial message 2024-12-23 12:28:52 +01:00
jsonschema Let schema/config.json end with a line feed 2024-11-30 15:03:29 +01:00
logs
snake
tasks Use ScanLinesAndTruncateWhenLongerThanBuffer instead of bufio.ScanLines 2024-05-15 13:27:01 +02:00
theme Highlight inactive selection in bold 2024-06-23 14:43:13 +02:00
updates Change direct access to Common.UserConfig to a getter 2024-08-18 10:24:52 +02:00
utils Return arrays with line indices from WrapViewLinesToWidth 2024-12-23 12:24:09 +01:00