install.sh 6.2 KB

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