-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnvim
More file actions
executable file
·75 lines (65 loc) · 2.5 KB
/
Copy pathnvim
File metadata and controls
executable file
·75 lines (65 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
set -e
# Binary locations (try multiple paths, in priority order)
NIX_NVIM_BINARY="$HOME/.nix-profile/bin/nvim"
NIXOS_NVIM_BINARY="/etc/profiles/per-user/$(whoami)/bin/nvim"
BREW_NVIM_BINARY="$DOTFILES_BREW_PREFIX/bin/nvim"
# On NixOS, ~/.nix-profile is a symlink to /etc/profiles/per-user/$USER, so the
# two paths above can be the same binary. Dedupe by resolved path to avoid a
# false-positive "multiple binaries" warning (readlink -f is Linux-only, but
# this situation cannot arise on macOS).
if [ -x "$NIX_NVIM_BINARY" ] && [ -x "$NIXOS_NVIM_BINARY" ] &&
[ "$(readlink -f "$NIX_NVIM_BINARY" 2>/dev/null)" = "$(readlink -f "$NIXOS_NVIM_BINARY" 2>/dev/null)" ]; then
NIXOS_NVIM_BINARY=""
fi
# Count available binaries
available_count=0
available_binaries=""
if [ -x "$NIX_NVIM_BINARY" ]; then
available_count=$((available_count + 1))
available_binaries="$available_binaries\n - $NIX_NVIM_BINARY (installed via Nix user profile)"
fi
if [ -x "$NIXOS_NVIM_BINARY" ]; then
available_count=$((available_count + 1))
available_binaries="$available_binaries\n - $NIXOS_NVIM_BINARY (installed via NixOS system profile)"
fi
if [ -x "$BREW_NVIM_BINARY" ]; then
available_count=$((available_count + 1))
available_binaries="$available_binaries\n - $BREW_NVIM_BINARY (installed via Homebrew)"
fi
# Check for conflicts
if [ $available_count -gt 1 ]; then
echo "Warning: Multiple nvim binaries found. Using priority order: Nix User > NixOS System > Homebrew"
echo -e "Available binaries:$available_binaries"
echo ""
fi
if [ -x "$NIX_NVIM_BINARY" ]; then
NVIM_BINARY="$NIX_NVIM_BINARY"
elif [ -x "$NIXOS_NVIM_BINARY" ]; then
NVIM_BINARY="$NIXOS_NVIM_BINARY"
elif [ -x "$BREW_NVIM_BINARY" ]; then
NVIM_BINARY="$BREW_NVIM_BINARY"
else
echo "Error: No nvim binary found."
echo "Please rebuild (neovim comes from nixpkgs via home-manager)."
exit 1
fi
# Inject Neovim build dependencies (managed by Nix, not on regular PATH)
NVIM_DEPS_PATH_FILE="$HOME/.config/nvim-deps-path"
if [ -f "$NVIM_DEPS_PATH_FILE" ]; then
# Append so per-project tooling (e.g. mise) takes precedence over these fallbacks
export PATH="$PATH:$(cat "$NVIM_DEPS_PATH_FILE")"
fi
# Check if NVIM_APPNAME is already set
if [ -z "$NVIM_APPNAME" ]; then
# Skip setting NVIM_APPNAME=nvim-fredrik on rpi5-homelab
HOSTNAME=$(hostname)
if [ "$HOSTNAME" = "rpi5-homelab" ]; then
$NVIM_BINARY "$@"
else
NVIM_APPNAME=nvim-fredrik $NVIM_BINARY "$@"
fi
else
echo "Warning: Using NVIM_APPNAME=$NVIM_APPNAME"
$NVIM_BINARY "$@"
fi