install.sh 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
  108. echo 'lv-config already present'
  109. else
  110. cp "$HOME/.local/share/lunarvim/lvim/utils/installer/lv-config.example.lua" "$HOME/.config/lvim/lv-config.lua"
  111. fi
  112. }
  113. asktoinstallnode() {
  114. echo "node not found"
  115. printf "Would you like to install node now (y/n)? "
  116. read -r answer
  117. [ "$answer" != "${answer#[Yy]}" ] && installnode
  118. }
  119. asktoinstallpip() {
  120. # echo "pip not found"
  121. # echo -n "Would you like to install pip now (y/n)? "
  122. # read answer
  123. # [ "$answer" != "${answer#[Yy]}" ] && installpip
  124. echo "Please install pip3 before continuing with install"
  125. exit
  126. }
  127. installonmac() {
  128. brew install ripgrep fzf
  129. npm install -g tree-sitter-cli
  130. }
  131. installonubuntu() {
  132. sudo apt install ripgrep fzf
  133. sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
  134. pip3 install neovim-remote
  135. npm install -g tree-sitter-cli
  136. }
  137. installonarch() {
  138. sudo pacman -S ripgrep fzf
  139. pip3 install neovim-remote
  140. npm install -g tree-sitter-cli
  141. }
  142. installonfedora() {
  143. sudo dnf groupinstall "X Software Development"
  144. sudo dnf install -y fzf ripgrep
  145. }
  146. installongentoo() {
  147. sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib
  148. npm install -g tree-sitter-cli
  149. }
  150. installextrapackages() {
  151. [ "$(uname)" = "Darwin" ] && installonmac
  152. grep -q Ubuntu /etc/os-release && installonubuntu
  153. [ -f "/etc/arch-release" ] && installonarch
  154. [ -f "/etc/artix-release" ] && installonarch
  155. [ -f "/etc/fedora-release" ] && installonfedora
  156. [ -f "/etc/gentoo-release" ] && installongentoo
  157. [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
  158. }
  159. # Welcome
  160. echo 'Installing LunarVim'
  161. case "$@" in
  162. *--overwrite*)
  163. echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag'
  164. rm -rf "$HOME/.local/share/lunarvim"
  165. rm -rf "$HOME/.cache/nvim"
  166. rm -rf "$HOME/.config/lvim"
  167. ;;
  168. esac
  169. # move old lvim directory if it exists
  170. [ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim
  171. # install pip
  172. (command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip
  173. # install node and neovim support
  174. (command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode
  175. # install pynvim
  176. (pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim
  177. if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then
  178. echo 'packer already installed'
  179. else
  180. installpacker
  181. fi
  182. if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then
  183. echo 'LunarVim already installed'
  184. else
  185. # clone config down
  186. cloneconfig "$@"
  187. # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc
  188. # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc
  189. fi
  190. if [ "$(uname)" != "Darwin" ]; then
  191. if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then
  192. echo 'Desktop file already available'
  193. else
  194. mkdir -p "$HOME/.local/share/applications"
  195. cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop"
  196. fi
  197. fi
  198. echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
  199. # echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc'