Let Neovim's current line and status line show the terminal background on existing installs (#15024)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier HanssonandClaude Opus 5.5 authored and GitHub committed 2026-10-11 22:30:32 +09:00
1 parent 88de9ecc6c
commit 5f25ef1da8
2 files changed
+139

No files matched your search

+55
View File
@@ -0,0 +1,55 @@
echo "Let Neovim's current line and status line show the terminal background"
# ~/.config/nvim is copied once from omarchy-nvim, so it misses the package's
# later changes. Bring in the transparency file and lualine spec it now ships.
config="$HOME/.config/nvim"
package="/usr/share/omarchy-nvim/config"
files=(plugin/after/transparency.lua lua/plugins/lualine-transparent.lua)
[[ -d $config ]] || exit 0
# Dotfile managers may own a file or a parent directory through a symlink.
# Preserve that layout rather than detaching or editing its target.
for file in "${files[@]}"; do
path="$config/$file"
while [[ $path != "$HOME" && $path != / ]]; do
if [[ -L $path ]]; then
echo "Preserving symlink-managed Neovim config: $path"
exit 0
fi
path=$(dirname "$path")
done
done
# Updates install packages before migrations. An older package leaves this
# pending rather than copying files it does not have yet.
if [[ ! -f $package/${files[1]} ]]; then
echo "Update omarchy-nvim to 2026.9.21-5 or newer before rerunning this migration." >&2
exit 1
fi
# A copy staged beside its target and moved into place whole, so a failed
# write leaves the original for a retry.
staged=""
trap 'rm -f -- ${staged:+"$staged"}' EXIT
install_from_package() {
staged=$(mktemp "$config/$1.new.XXXXXX")
install -m 0644 "$package/$1" "$staged"
mv -fT -- "$staged" "$config/$1"
}
# Only a transparency file still as Omarchy shipped it is replaced, so one the
# user changed is kept.
if [[ -f $config/${files[0]} ]]; then
case $(sha256sum <"$config/${files[0]}") in
bd833dc094e3546b5fad512e61cfb09f3032c2a4461c23be7bd90851de80688e* | \
6e31b917f13e16514ac94ff9270d47f24e76509a3e559ca85116a5aa2d61306a* | \
33d29360df84ed48c70606580749536520384ec64afe650151d4e26e7922b410*)
install_from_package "${files[0]}"
;;
esac
fi
if [[ -d $config/lua/plugins && ! -e $config/${files[1]} ]]; then
install_from_package "${files[1]}"
fi
+84
View File
@@ -0,0 +1,84 @@
#!/bin/bash
set -euo pipefail
source "$(dirname "$0")/base-test.sh"
test_dir=$(mktemp -d)
trap 'rm -rf "$test_dir"' EXIT
config="$test_dir/.config/nvim"
package="$test_dir/package"
transparency="plugin/after/transparency.lua"
lualine="lua/plugins/lualine-transparent.lua"
mkdir -p "$package/plugin/after" "$package/lua/plugins"
printf -- '-- new transparency\n' >"$package/$transparency"
printf -- '-- lualine\n' >"$package/$lualine"
printf -- '-- shipped transparency\n' >"$test_dir/shipped.lua"
# The real package and shipped files live outside this repo, so the migration
# reads a stand-in package and knows the stand-in shipped file by its hash.
shipped_hash=$(sha256sum <"$test_dir/shipped.lua" | cut -c1-64)
sed -e "s@/usr/share/omarchy-nvim/config@$package@" \
-e "s@6e31b917f13e16514ac94ff9270d47f24e76509a3e559ca85116a5aa2d61306a@$shipped_hash@" \
"$ROOT/migrations/1791723398.sh" >"$test_dir/migration.sh"
run_migration() {
HOME="$test_dir" bash -euo pipefail "$test_dir/migration.sh" >/dev/null 2>&1
}
reset_config() {
rm -rf "$config"
mkdir -p "$config/plugin/after" "$config/lua/plugins"
cp "$test_dir/shipped.lua" "$config/$transparency"
}
reset_config
run_migration
run_migration
cmp -s "$config/$transparency" "$package/$transparency" && cmp -s "$config/$lualine" "$package/$lualine" ||
fail "a shipped config takes the package's transparency file and lualine spec"
[[ -z $(find "$config" -name '*.new.*') ]] || fail "no staged files are left behind"
pass "a shipped config takes the package's transparency file and lualine spec"
reset_config
printf -- '-- mine\n' >"$config/$transparency"
printf -- '-- my lualine\n' >"$config/$lualine"
run_migration
[[ $(<"$config/$transparency") == "-- mine" && $(<"$config/$lualine") == "-- my lualine" ]] ||
fail "files the user changed or added are kept"
pass "files the user changed or added are kept"
reset_config
mkdir -p "$test_dir/dotfiles"
mv "$config/plugin" "$test_dir/dotfiles/plugin"
ln -s "$test_dir/dotfiles/plugin" "$config/plugin"
run_migration
cmp -s "$config/$transparency" "$test_dir/shipped.lua" && [[ ! -e $config/$lualine ]] ||
fail "a config a dotfile manager links in is left alone"
pass "a config a dotfile manager links in is left alone"
# An older package leaves the migration pending to run again after the update.
reset_config
mv "$package/$lualine" "$test_dir/lualine.lua"
if run_migration; then
fail "an older package leaves the migration pending"
fi
mv "$test_dir/lualine.lua" "$package/$lualine"
pass "an older package leaves the migration pending"
reset_config
chmod a-w "$config/plugin/after"
if run_migration; then
chmod u+w "$config/plugin/after"
fail "a write that fails leaves the migration pending"
fi
chmod u+w "$config/plugin/after"
cmp -s "$config/$transparency" "$test_dir/shipped.lua" || fail "a write that fails leaves the file as it was"
pass "a write that fails leaves the migration pending and the file as it was"
rm -rf "$config"
run_migration
[[ ! -e $config ]] || fail "a missing Neovim config is not created"
pass "a missing Neovim config is not created"