-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset-nvim.sh
executable file
·62 lines (52 loc) · 1.97 KB
/
set-nvim.sh
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
#!/bin/bash
# Check if the script is being sourced
(return 0 2>/dev/null) || { echo "This script should be run sourced (e.g., '. ./set-nvim.sh' to change the default vi alias)"; exit 1; }
# Check if Neovim (nvim) is installed
if ! command -v nvim &> /dev/null
then
echo "Neovim is not installed. Installing Neovim..."
# Install prerequisites for Neovim
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt update
sudo apt install -y neovim
# Verify installation
if command -v nvim &> /dev/null
then
echo "Neovim has been successfully installed."
else
echo "Error: Neovim installation failed."
fi
fi
# Set Neovim as the default editor
sudo update-alternatives --set editor /usr/bin/nvim
# Replace any existing alias for vi in ~/.bashrc with the new one
if grep -q "^alias vi=" ~/.bashrc; then
echo "Replacing existing alias for vi in ~/.bashrc"
sed -i "s#^alias vi=.*#alias vi='nvim'#" ~/.bashrc
else
echo "alias vi='nvim'" >> ~/.bashrc
echo "Added alias to ~/.bashrc: alias vi='nvim'"
fi
alias vi='nvim'
echo "
Notes:
- nvim does not use ~/.vimrc, and instead uses ~/.config/nvim/init.vim
- nvim takes over the mouse-select-right-click function, instead of that it will
offer the nvim menu. If this is not wanted, use ':set mouse=' to turn it off.
Add that to the ~/.config/nvim/init.vim to make this the default behaviour.
"
# nvim Common Installation Locations
# /usr/bin/nvim
# /usr/local/bin/nvim
# User-specific Installations:
# User-specific install via a package manager or manually:
# $HOME/.local/bin/nvim (common for curl-based or appimage installations).
# If using Homebrew (macOS/Linux):
# /usr/local/bin/nvim (on macOS or older Linux Homebrew installations).
# /home/linuxbrew/.linuxbrew/bin/nvim (on Linux Homebrew installations).
# TinyVim is at:
# /usr/bin/vi
# /bin/vi
# /usr/bin/vim.tiny (specific to Debian-based systems)