Skip to content

Commit b1e585f

Browse files
committed
Fix nvim theme location
1 parent 221fb29 commit b1e585f

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

‎migrations/user/1781158082.sh‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
echo "Relink Neovim theme to Omarchy current state"
2+
3+
theme_link="$HOME/.config/nvim/lua/plugins/theme.lua"
4+
legacy_absolute_target="$HOME/.config/omarchy/current/theme/neovim.lua"
5+
legacy_relative_target="../../../omarchy/current/theme/neovim.lua"
6+
legacy_home_target="~/.config/omarchy/current/theme/neovim.lua"
7+
current_relative_target="../../../../.local/state/omarchy/current/theme/neovim.lua"
8+
9+
[[ -L $theme_link ]] || exit 0
10+
11+
target=$(readlink "$theme_link") || exit 0
12+
13+
case "$target" in
14+
"$legacy_absolute_target"|"$legacy_relative_target"|"$legacy_home_target")
15+
ln -sfn "$current_relative_target" "$theme_link"
16+
;;
17+
esac

‎test/cli‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,21 +378,51 @@ MIGRATION_TMPDIR=$(mktemp -d)
378378
mkdir -p \
379379
"$MIGRATION_TMPDIR/.config/omarchy/current/theme" \
380380
"$MIGRATION_TMPDIR/.config/alacritty" \
381+
"$MIGRATION_TMPDIR/.config/hypr" \
381382
"$MIGRATION_TMPDIR/.config/hyprland-preview-share-picker" \
382383
"$MIGRATION_TMPDIR/.config/btop/themes"
383384
printf 'tokyo-night\n' >"$MIGRATION_TMPDIR/.config/omarchy/current/theme.name"
384385
printf 'x\n' >"$MIGRATION_TMPDIR/.config/omarchy/current/theme/colors.toml"
385386
printf 'general.import = [ "~/.config/omarchy/current/theme/alacritty.toml" ]\n' >"$MIGRATION_TMPDIR/.config/alacritty/alacritty.toml"
386387
printf 'stylesheets: ["../omarchy/current/theme/hyprland-preview-share-picker.css"]\n' >"$MIGRATION_TMPDIR/.config/hyprland-preview-share-picker/config.yaml"
388+
cat >"$MIGRATION_TMPDIR/.config/hypr/hyprland.lua" <<'LUA'
389+
package.path = os.getenv("HOME")
390+
.. "/.config/?.lua;"
391+
.. (os.getenv("OMARCHY_PATH") or "/usr/share/omarchy")
392+
.. "/?.lua;"
393+
.. package.path
394+
LUA
387395
ln -s "$MIGRATION_TMPDIR/.config/omarchy/current/theme/btop.theme" "$MIGRATION_TMPDIR/.config/btop/themes/current.theme"
388396
HOME="$MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/user/1781043107.sh" >/dev/null
389397
[[ -f $MIGRATION_TMPDIR/.local/state/omarchy/current/theme.name ]] || fail "current theme migration moves theme name"
390398
[[ ! -e $MIGRATION_TMPDIR/.config/omarchy/current ]] || fail "current theme migration removes legacy config state"
391399
grep -Fq '~/.local/state/omarchy/current/theme/alacritty.toml' "$MIGRATION_TMPDIR/.config/alacritty/alacritty.toml" || fail "current theme migration updates alacritty import"
392400
grep -Fq '../../.local/state/omarchy/current/theme/hyprland-preview-share-picker.css' "$MIGRATION_TMPDIR/.config/hyprland-preview-share-picker/config.yaml" || fail "current theme migration updates relative stylesheet"
401+
grep -Fq '/.local/state/?.lua;' "$MIGRATION_TMPDIR/.config/hypr/hyprland.lua" || fail "current theme migration keeps Hyprland theme modules discoverable"
393402
[[ $(readlink "$MIGRATION_TMPDIR/.config/btop/themes/current.theme") == "$MIGRATION_TMPDIR/.local/state/omarchy/current/theme/btop.theme" ]] || fail "current theme migration updates btop symlink"
394403
pass "current theme migration moves state and rewrites shipped references"
395404

405+
NVIM_MIGRATION_TMPDIR=$(mktemp -d)
406+
nvim_theme_link="$NVIM_MIGRATION_TMPDIR/.config/nvim/lua/plugins/theme.lua"
407+
nvim_expected_target="../../../../.local/state/omarchy/current/theme/neovim.lua"
408+
nvim_expected_resolved_target="$NVIM_MIGRATION_TMPDIR/.local/state/omarchy/current/theme/neovim.lua"
409+
mkdir -p \
410+
"$(dirname "$nvim_theme_link")" \
411+
"$NVIM_MIGRATION_TMPDIR/.config/omarchy/current/theme" \
412+
"$NVIM_MIGRATION_TMPDIR/.local/state/omarchy/current/theme"
413+
touch "$NVIM_MIGRATION_TMPDIR/.local/state/omarchy/current/theme/neovim.lua"
414+
for nvim_legacy_target in \
415+
"../../../omarchy/current/theme/neovim.lua" \
416+
"$NVIM_MIGRATION_TMPDIR/.config/omarchy/current/theme/neovim.lua"; do
417+
ln -sfn "$nvim_legacy_target" "$nvim_theme_link"
418+
HOME="$NVIM_MIGRATION_TMPDIR" bash -euo pipefail "$ROOT/migrations/user/1781158082.sh" >/dev/null
419+
nvim_actual_target=$(readlink "$nvim_theme_link")
420+
nvim_resolved_target=$(readlink -f "$nvim_theme_link")
421+
[[ $nvim_actual_target == $nvim_expected_target ]] || fail "nvim theme migration updates theme symlink"
422+
[[ $nvim_resolved_target == $nvim_expected_resolved_target ]] || fail "nvim theme migration points to current theme"
423+
done
424+
pass "nvim theme migration relinks current theme"
425+
396426
cp "$NEXT_THEME/colors.toml" "$CURRENT_THEME/colors.toml"
397427
cp "$NEXT_THEME/vscode-theme.json" "$CURRENT_THEME/vscode-theme.json"
398428

0 commit comments

Comments
 (0)