install.sh 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. #!/bin/sh
  2. #Set Variable to master is not set differently
  3. LVBRANCH="${LVBRANCH:-master}"
  4. USER_BIN_DIR="/usr/local/bin"
  5. set -o nounset # error when referencing undefined variable
  6. set -o errexit # exit when command fails
  7. installnodemac() {
  8. brew install lua
  9. brew install node
  10. brew install yarn
  11. }
  12. installnodeubuntu() {
  13. sudo apt install nodejs
  14. sudo apt install npm
  15. }
  16. installnodetermux() {
  17. apt install nodejs
  18. }
  19. moveoldlvim() {
  20. echo "Not installing LunarVim"
  21. echo "Please move your ~/.local/share/lunarvim folder before installing"
  22. exit
  23. }
  24. installnodearch() {
  25. sudo pacman -S nodejs
  26. sudo pacman -S npm
  27. }
  28. installnodefedora() {
  29. sudo dnf install -y nodejs
  30. sudo dnf install -y npm
  31. }
  32. installnodegentoo() {
  33. echo "Printing current node status..."
  34. emerge -pqv net-libs/nodejs
  35. echo "Make sure the npm USE flag is enabled for net-libs/nodejs"
  36. echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)"
  37. read -r answer
  38. [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm
  39. sudo emerge -avnN net-libs/nodejs
  40. }
  41. installnode() {
  42. echo "Installing node..."
  43. [ "$(uname)" = "Darwin" ] && installnodemac
  44. grep -q Ubuntu /etc/os-release && installnodeubuntu
  45. [ -f "/etc/arch-release" ] && installnodearch
  46. [ -f "/etc/artix-release" ] && installnodearch
  47. [ -f "/etc/fedora-release" ] && installnodefedora
  48. [ -f "/etc/gentoo-release" ] && installnodegentoo
  49. [ -d "/data/data/com.termux" ] && installnodetermux
  50. [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
  51. sudo npm i -g neovim
  52. }
  53. installpiponmac() {
  54. sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  55. python3 get-pip.py
  56. rm get-pip.py
  57. }
  58. installpiponubuntu() {
  59. sudo apt install python3-pip >/dev/null
  60. }
  61. installpipontermux() {
  62. apt install python
  63. }
  64. installpiponarch() {
  65. sudo pacman -S python-pip
  66. }
  67. installpiponfedora() {
  68. sudo dnf install -y pip >/dev/null
  69. }
  70. installpipongentoo() {
  71. sudo emerge -avn dev-python/pip
  72. }
  73. installpip() {
  74. echo "Installing pip..."
  75. [ "$(uname)" = "Darwin" ] && installpiponmac
  76. grep -q Ubuntu /etc/os-release && installpiponubuntu
  77. [ -f "/etc/arch-release" ] && installpiponarch
  78. [ -f "/etc/fedora-release" ] && installpiponfedora
  79. [ -f "/etc/gentoo-release" ] && installpipongentoo
  80. [ -d "/data/data/com.termux" ] && installpipontermux
  81. [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
  82. }
  83. installpynvim() {
  84. echo "Installing pynvim..."
  85. if [ -f "/etc/gentoo-release" ]; then
  86. echo "Installing using Portage"
  87. sudo emerge -avn dev-python/pynvim
  88. else
  89. pip3 install pynvim --user
  90. fi
  91. }
  92. installpacker() {
  93. git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim
  94. }
  95. cloneconfig() {
  96. if [ -d "/data/data/com.termux" ]; then
  97. sudo() {
  98. eval "$@"
  99. }
  100. USER_BIN_DIR="$HOME/../usr/bin"
  101. fi
  102. echo "Cloning LunarVim configuration"
  103. mkdir -p ~/.local/share/lunarvim
  104. case "$@" in
  105. *--testing*)
  106. cp -r "$(pwd)" ~/.local/share/lunarvim/lvim
  107. ;;
  108. *)
  109. git clone --branch "$LVBRANCH" https://github.com/ChristianChiarulli/lunarvim.git ~/.local/share/lunarvim/lvim
  110. ;;
  111. esac
  112. mkdir -p "$HOME/.config/lvim"
  113. sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "$USER_BIN_DIR"
  114. sudo chmod a+rx "$USER_BIN_DIR"/lvim
  115. cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example-no-ts.lua" "$HOME/.config/lvim/config.lua"
  116. nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \
  117. +'autocmd User PackerComplete sleep 100m | qall' \
  118. +PackerInstall
  119. nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \
  120. +'autocmd User PackerComplete sleep 100m | qall' \
  121. +PackerSync
  122. printf "\nCompile Complete\n"
  123. if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
  124. echo 'config.lua already present'
  125. else
  126. cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example.lua" "$HOME/.config/lvim/config.lua"
  127. fi
  128. }
  129. asktoinstallnode() {
  130. echo "node not found"
  131. printf "Would you like to install node now (y/n)? "
  132. read -r answer
  133. [ "$answer" != "${answer#[Yy]}" ] && installnode
  134. }
  135. asktoinstallgit() {
  136. echo "git not found, please install git"
  137. exit
  138. }
  139. asktoinstallpip() {
  140. # echo "pip not found"
  141. # echo -n "Would you like to install pip now (y/n)? "
  142. # read answer
  143. # [ "$answer" != "${answer#[Yy]}" ] && installpip
  144. echo "Please install pip3 before continuing with install"
  145. exit
  146. }
  147. installonmac() {
  148. brew install ripgrep fzf
  149. npm install -g tree-sitter-cli
  150. }
  151. installonubuntu() {
  152. sudo apt install ripgrep fzf
  153. sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
  154. pip3 install neovim-remote
  155. npm install -g tree-sitter-cli
  156. }
  157. installtermux() {
  158. apt install ripgrep fzf
  159. pip install neovim-remote
  160. npm install -g tree-sitter-cli
  161. }
  162. installonarch() {
  163. sudo pacman -S ripgrep fzf
  164. pip3 install neovim-remote
  165. npm install -g tree-sitter-cli
  166. }
  167. installonfedora() {
  168. sudo dnf groupinstall "X Software Development"
  169. sudo dnf install -y fzf ripgrep
  170. }
  171. installongentoo() {
  172. sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib
  173. npm install -g tree-sitter-cli
  174. }
  175. installextrapackages() {
  176. [ "$(uname)" = "Darwin" ] && installonmac
  177. grep -q Ubuntu /etc/os-release && installonubuntu
  178. [ -f "/etc/arch-release" ] && installonarch
  179. [ -f "/etc/artix-release" ] && installonarch
  180. [ -f "/etc/fedora-release" ] && installonfedora
  181. [ -f "/etc/gentoo-release" ] && installongentoo
  182. [ -d "/data/data/com.termux" ] && installtermux
  183. [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
  184. }
  185. # Welcome
  186. echo 'Installing LunarVim'
  187. case "$@" in
  188. *--overwrite*)
  189. echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag'
  190. rm -rf "$HOME/.local/share/lunarvim"
  191. rm -rf "$HOME/.cache/nvim"
  192. rm -rf "$HOME/.config/lvim"
  193. ;;
  194. esac
  195. # move old lvim directory if it exists
  196. [ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim
  197. # install node and neovim support
  198. (command -v git >/dev/null && echo "git installed, moving on...") || asktoinstallgit
  199. # install pip
  200. (command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip
  201. # install node and neovim support
  202. (command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode
  203. # install pynvim
  204. (pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim
  205. if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then
  206. echo 'packer already installed'
  207. else
  208. installpacker
  209. fi
  210. if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
  211. echo 'LunarVim already installed'
  212. else
  213. # clone config down
  214. cloneconfig "$@"
  215. # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc
  216. # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc
  217. fi
  218. if [ "$(uname)" != "Darwin" ]; then
  219. if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then
  220. echo 'Desktop file already available'
  221. else
  222. mkdir -p "$HOME/.local/share/applications"
  223. cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop"
  224. fi
  225. fi
  226. echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
  227. # echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc'