-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinstall-nvim.sh
More file actions
executable file
·90 lines (73 loc) · 3.09 KB
/
Copy pathinstall-nvim.sh
File metadata and controls
executable file
·90 lines (73 loc) · 3.09 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/sh
# Define variables
NEOVIM_REPO="neovim/neovim"
NEOVIM_INSTALL_DIR="$HOME/.config/nvim/neovim"
# Fetch Neovim releases using curl and parse JSON with jq
RELEASES=$(gh release list --repo "$NEOVIM_REPO" --limit 100 | tail -n +2 | awk '{print $3}')
# Fallback if API returns nothing (rate limited or error)
if [ -z "$RELEASES" ]; then
echo "⚠️ Failed to fetch releases (possibly rate-limited). Falling back to 'stable'..."
SELECTED_RELEASE="stable"
else
# Display releases using fzf for interactive selection
echo "Select a Neovim release:"
SELECTED_RELEASE=$(echo "$RELEASES" | fzf --reverse)
# If user cancels fzf, fallback to stable
if [ -z "$SELECTED_RELEASE" ]; then
echo "⚠️ No selection made. Falling back to 'stable'..."
SELECTED_RELEASE="stable"
fi
fi
# Fetch the actual commit SHA associated with the selected release tag
# This gets the actual release commit, not just the branch it was created from
NEOVIM_COMMIT_HASH=$(curl -s "https://api.github.com/repos/$NEOVIM_REPO/git/refs/tags/$SELECTED_RELEASE" | jq -r '.object.sha')
# Allow the user to select build type
echo "Select build type:"
BUILD_TYPES="RelWithDebInfo\nRelease\nDebug"
SELECTED_BUILD_TYPE=$(echo -e "$BUILD_TYPES" | fzf --reverse)
# Ask if user wants to keep the source directory for debugging
echo "Keep source directory for debugging? (y/n)"
read -r KEEP_SOURCE
KEEP_SOURCE=$(echo "$KEEP_SOURCE" | tr '[:upper:]' '[:lower:]')
# Create the installation directory if it doesn't exist
mkdir -p "$NEOVIM_INSTALL_DIR"
# Clone Neovim repository
git clone "https://github.com/$NEOVIM_REPO" "$NEOVIM_INSTALL_DIR"
# Move to Neovim directory
cd "$NEOVIM_INSTALL_DIR" || exit 1
# Reset to the specified commit
git reset --hard "$NEOVIM_COMMIT_HASH"
# Remove existing Neovim installation (if any)
sudo rm -f /usr/local/bin/nvim
sudo rm -rf /usr/local/share/nvim/
# Build and install Neovim with the selected build type
echo "Building Neovim with CMAKE_BUILD_TYPE=$SELECTED_BUILD_TYPE..."
make CMAKE_BUILD_TYPE="$SELECTED_BUILD_TYPE"
sudo make install
# Check if the installation was successful
if [ $? -eq 0 ]; then
echo "Neovim (commit hash $NEOVIM_COMMIT_HASH) from release $SELECTED_RELEASE has been successfully built and installed!"
# Check for debug symbols
echo "Checking debug symbols:"
if file /usr/local/bin/nvim | grep -q "not stripped"; then
echo "✅ Debug symbols present"
else
echo "⚠️ Debug symbols missing"
fi
# Check Neovim version
neovim_version=$(nvim --version | head -n 1)
echo "Installed Neovim version: $neovim_version"
# Clean up based on user choice
if [ "$KEEP_SOURCE" != "y" ]; then
echo "Removing source directory..."
cd "$HOME" || exit 1
rm -rf "$NEOVIM_INSTALL_DIR"
echo "Source directory removed."
else
echo "Source directory kept at: $NEOVIM_INSTALL_DIR"
echo "You can use this for debugging purposes."
fi
else
echo "❌ Neovim installation failed!"
echo "The source directory has been kept at: $NEOVIM_INSTALL_DIR for troubleshooting."
fi