#!/usr/bin/env bash

# omarchy:summary=Print the User settings directory of a VS Code-family editor on this OS
# omarchy:args=<cursor|code|codium>
# omarchy:hidden=true

# Based: the editor rows drop settings.json and keybindings.json where the
# editor actually reads them. On Debian, VS Code and VSCodium come from
# Flathub and read their sandboxed config dir; Cursor is a deb and reads
# ~/.config. On macOS every one of them reads ~/Library/Application Support.
editor=${1:-}

case $editor in
cursor) app=Cursor flatpak= ;;
code) app=Code flatpak=com.visualstudio.code ;;
codium) app=VSCodium flatpak=com.vscodium.codium ;;
*)
  echo "Usage: omarchy-code-config-dir <cursor|code|codium>" >&2
  exit 1
  ;;
esac

if [[ $(omarchy-os) == darwin ]]; then
  echo "$HOME/Library/Application Support/$app/User"
elif [[ -n $flatpak ]] && omarchy-pkg-flatpak-present "$flatpak"; then
  echo "$HOME/.var/app/$flatpak/config/$app/User"
else
  echo "$HOME/.config/$app/User"
fi
