LunarVim/utils/installer/install.sh

273 lines
7.2 KiB
Bash
Raw Normal View History

2021-07-09 00:57:58 +02:00
#!/bin/sh
2021-07-11 01:25:35 +02:00
#Set Variable to master is not set differently
LVBRANCH="${LVBRANCH:-master}"
2021-08-02 18:04:26 +02:00
USER_BIN_DIR="/usr/local/bin"
2021-03-19 05:10:21 +01:00
set -o nounset # error when referencing undefined variable
set -o errexit # exit when command fails
2021-03-15 03:25:28 +01:00
2021-03-19 05:10:21 +01:00
installnodemac() {
2021-07-19 18:20:54 +02:00
brew install lua
brew install node
brew install yarn
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
installnodeubuntu() {
2021-07-19 18:20:54 +02:00
sudo apt install nodejs
sudo apt install npm
2021-03-15 03:25:28 +01:00
}
2021-08-02 18:04:26 +02:00
installnodetermux() {
apt install nodejs
}
2021-07-20 04:50:07 +02:00
moveoldlvim() {
2021-07-19 18:20:54 +02:00
echo "Not installing LunarVim"
2021-07-20 04:50:07 +02:00
echo "Please move your ~/.local/share/lunarvim folder before installing"
2021-07-19 18:20:54 +02:00
exit
2021-03-24 00:48:07 +01:00
}
2021-03-19 05:10:21 +01:00
installnodearch() {
2021-07-19 18:20:54 +02:00
sudo pacman -S nodejs
sudo pacman -S npm
2021-03-15 03:25:28 +01:00
}
installnodefedora() {
2021-07-19 18:20:54 +02:00
sudo dnf install -y nodejs
sudo dnf install -y npm
}
installnodegentoo() {
2021-07-19 18:20:54 +02:00
echo "Printing current node status..."
emerge -pqv net-libs/nodejs
echo "Make sure the npm USE flag is enabled for net-libs/nodejs"
echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)"
read -r answer
[ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm
sudo emerge -avnN net-libs/nodejs
}
2021-03-19 05:10:21 +01:00
installnode() {
2021-07-19 18:20:54 +02:00
echo "Installing node..."
[ "$(uname)" = "Darwin" ] && installnodemac
grep -q Ubuntu /etc/os-release && installnodeubuntu
[ -f "/etc/arch-release" ] && installnodearch
[ -f "/etc/artix-release" ] && installnodearch
[ -f "/etc/fedora-release" ] && installnodefedora
[ -f "/etc/gentoo-release" ] && installnodegentoo
2021-08-02 18:04:26 +02:00
[ -d "/data/data/com.termux" ] && installnodetermux
2021-07-19 18:20:54 +02:00
[ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
sudo npm i -g neovim
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
installpiponmac() {
2021-07-19 18:20:54 +02:00
sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
installpiponubuntu() {
2021-07-19 18:20:54 +02:00
sudo apt install python3-pip >/dev/null
2021-03-15 03:25:28 +01:00
}
2021-08-02 18:04:26 +02:00
installpipontermux() {
apt install python
}
2021-03-19 05:10:21 +01:00
installpiponarch() {
2021-07-19 18:20:54 +02:00
sudo pacman -S python-pip
2021-03-15 03:25:28 +01:00
}
installpiponfedora() {
2021-07-19 18:20:54 +02:00
sudo dnf install -y pip >/dev/null
}
installpipongentoo() {
2021-07-19 18:20:54 +02:00
sudo emerge -avn dev-python/pip
}
2021-03-19 05:10:21 +01:00
installpip() {
2021-07-19 18:20:54 +02:00
echo "Installing pip..."
[ "$(uname)" = "Darwin" ] && installpiponmac
grep -q Ubuntu /etc/os-release && installpiponubuntu
[ -f "/etc/arch-release" ] && installpiponarch
[ -f "/etc/fedora-release" ] && installpiponfedora
[ -f "/etc/gentoo-release" ] && installpipongentoo
2021-08-02 18:04:26 +02:00
[ -d "/data/data/com.termux" ] && installpipontermux
2021-07-19 18:20:54 +02:00
[ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
installpynvim() {
2021-07-19 18:20:54 +02:00
echo "Installing pynvim..."
if [ -f "/etc/gentoo-release" ]; then
echo "Installing using Portage"
sudo emerge -avn dev-python/pynvim
else
pip3 install pynvim --user
fi
2021-03-15 03:25:28 +01:00
}
2021-03-19 06:20:38 +01:00
installpacker() {
2021-07-20 04:50:07 +02:00
git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim
2021-03-19 06:20:38 +01:00
}
2021-03-19 05:10:21 +01:00
cloneconfig() {
2021-08-02 18:04:26 +02:00
if [ -d "/data/data/com.termux" ]; then
sudo() {
eval "$@"
}
USER_BIN_DIR="$HOME/../usr/bin"
fi
2021-07-19 18:20:54 +02:00
echo "Cloning LunarVim configuration"
2021-07-20 17:05:35 +02:00
mkdir -p ~/.local/share/lunarvim
case "$@" in
*--testing*)
cp -r "$(pwd)" ~/.local/share/lunarvim/lvim
;;
*)
git clone --branch "$LVBRANCH" https://github.com/ChristianChiarulli/lunarvim.git ~/.local/share/lunarvim/lvim
;;
esac
2021-07-20 04:50:07 +02:00
mkdir -p "$HOME/.config/lvim"
2021-08-02 18:04:26 +02:00
sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "$USER_BIN_DIR"
sudo chmod a+rx "$USER_BIN_DIR"/lvim
cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example-no-ts.lua" "$HOME/.config/lvim/config.lua"
2021-07-20 04:50:07 +02:00
nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \
2021-07-19 18:20:54 +02:00
+'autocmd User PackerComplete sleep 100m | qall' \
+PackerInstall
2021-07-09 01:03:25 +02:00
2021-07-20 04:50:07 +02:00
nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \
2021-07-19 18:20:54 +02:00
+'autocmd User PackerComplete sleep 100m | qall' \
+PackerSync
2021-07-09 01:03:25 +02:00
2021-07-19 18:20:54 +02:00
printf "\nCompile Complete\n"
if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
echo 'config.lua already present'
else
cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example.lua" "$HOME/.config/lvim/config.lua"
fi
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
asktoinstallnode() {
2021-07-19 18:20:54 +02:00
echo "node not found"
printf "Would you like to install node now (y/n)? "
read -r answer
[ "$answer" != "${answer#[Yy]}" ] && installnode
2021-03-15 03:25:28 +01:00
}
2021-08-04 05:12:05 +02:00
asktoinstallgit() {
echo "git not found, please install git"
2021-08-04 07:35:02 +02:00
exit
2021-08-04 05:12:05 +02:00
}
2021-03-19 05:10:21 +01:00
asktoinstallpip() {
2021-07-19 18:20:54 +02:00
# echo "pip not found"
# echo -n "Would you like to install pip now (y/n)? "
# read answer
# [ "$answer" != "${answer#[Yy]}" ] && installpip
echo "Please install pip3 before continuing with install"
exit
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
installonmac() {
2021-07-19 18:20:54 +02:00
brew install ripgrep fzf
npm install -g tree-sitter-cli
2021-03-15 03:25:28 +01:00
}
2021-03-19 05:10:21 +01:00
installonubuntu() {
2021-07-19 18:20:54 +02:00
sudo apt install ripgrep fzf
sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
pip3 install neovim-remote
npm install -g tree-sitter-cli
2021-03-15 03:25:28 +01:00
}
2021-08-02 18:04:26 +02:00
installtermux() {
apt install ripgrep fzf
pip install neovim-remote
npm install -g tree-sitter-cli
}
2021-03-19 05:10:21 +01:00
installonarch() {
2021-07-19 18:20:54 +02:00
sudo pacman -S ripgrep fzf
pip3 install neovim-remote
npm install -g tree-sitter-cli
2021-03-15 03:25:28 +01:00
}
installonfedora() {
2021-07-19 18:20:54 +02:00
sudo dnf groupinstall "X Software Development"
sudo dnf install -y fzf ripgrep
}
installongentoo() {
2021-07-19 18:20:54 +02:00
sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib
npm install -g tree-sitter-cli
}
2021-03-19 05:10:21 +01:00
installextrapackages() {
2021-07-19 18:20:54 +02:00
[ "$(uname)" = "Darwin" ] && installonmac
grep -q Ubuntu /etc/os-release && installonubuntu
[ -f "/etc/arch-release" ] && installonarch
[ -f "/etc/artix-release" ] && installonarch
[ -f "/etc/fedora-release" ] && installonfedora
[ -f "/etc/gentoo-release" ] && installongentoo
2021-08-02 18:04:26 +02:00
[ -d "/data/data/com.termux" ] && installtermux
2021-07-19 18:20:54 +02:00
[ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
2021-03-15 03:25:28 +01:00
}
# Welcome
2021-04-15 06:17:48 +02:00
echo 'Installing LunarVim'
2021-03-15 03:25:28 +01:00
2021-07-19 18:20:54 +02:00
case "$@" in
*--overwrite*)
2021-07-20 04:50:07 +02:00
echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag'
rm -rf "$HOME/.local/share/lunarvim"
2021-07-19 18:20:54 +02:00
rm -rf "$HOME/.cache/nvim"
2021-07-20 17:05:35 +02:00
rm -rf "$HOME/.config/lvim"
2021-07-19 18:20:54 +02:00
;;
esac
2021-07-20 04:50:07 +02:00
# move old lvim directory if it exists
[ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim
2021-03-24 00:50:20 +01:00
2021-08-04 05:12:05 +02:00
# install node and neovim support
(command -v git >/dev/null && echo "git installed, moving on...") || asktoinstallgit
2021-03-15 03:25:28 +01:00
# install pip
2021-07-19 18:33:31 +02:00
(command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip
2021-03-15 03:25:28 +01:00
# install node and neovim support
2021-07-19 18:33:31 +02:00
(command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode
2021-03-15 03:25:28 +01:00
# install pynvim
2021-07-19 18:20:54 +02:00
(pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim
2021-03-15 03:25:28 +01:00
2021-07-20 04:50:07 +02:00
if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then
2021-07-19 18:20:54 +02:00
echo 'packer already installed'
2021-03-19 06:26:09 +01:00
else
2021-07-19 18:20:54 +02:00
installpacker
2021-03-19 06:26:09 +01:00
fi
2021-07-20 04:50:07 +02:00
if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
2021-07-19 18:20:54 +02:00
echo 'LunarVim already installed'
2021-03-19 06:26:09 +01:00
else
2021-07-19 18:20:54 +02:00
# clone config down
2021-07-20 17:05:35 +02:00
cloneconfig "$@"
2021-07-19 18:20:54 +02:00
# echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc
# echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc
2021-03-19 06:26:09 +01:00
fi
2021-03-19 06:20:38 +01:00
2021-07-27 00:26:37 +02:00
if [ "$(uname)" != "Darwin" ]; then
if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then
echo 'Desktop file already available'
else
mkdir -p "$HOME/.local/share/applications"
cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop"
fi
fi
2021-03-15 03:25:28 +01:00
echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
2021-07-03 23:13:35 +02:00
# echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc'