install.sh 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. moveoldnvim() {
  16. echo "Not installing LunarVim"
  17. echo "Please move your ~/.config/nvim 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/nvim/site/pack/packer/start/packer.nvim
  85. }
  86. cloneconfig() {
  87. echo "Cloning LunarVim configuration"
  88. git clone --branch "$LVBRANCH" https://github.com/ChristianChiarulli/lunarvim.git ~/.config/nvim
  89. cp "$HOME/.config/nvim/utils/installer/lv-config.example-no-ts.lua" "$HOME/.config/nvim/lv-config.lua"
  90. nvim --headless \
  91. +'autocmd User PackerComplete sleep 100m | qall' \
  92. +PackerInstall
  93. nvim --headless \
  94. +'autocmd User PackerComplete sleep 100m | qall' \
  95. +PackerSync
  96. printf "\nCompile Complete\n"
  97. rm "$HOME/.config/nvim/lv-config.lua"
  98. cp "$HOME/.config/nvim/utils/installer/lv-config.example.lua" "$HOME/.config/nvim/lv-config.lua"
  99. # nvim --headless -cq ':silent TSUpdate' -cq ':qall' >/dev/null 2>&1
  100. }
  101. asktoinstallnode() {
  102. echo "node not found"
  103. printf "Would you like to install node now (y/n)? "
  104. read -r answer
  105. [ "$answer" != "${answer#[Yy]}" ] && installnode
  106. }
  107. asktoinstallpip() {
  108. # echo "pip not found"
  109. # echo -n "Would you like to install pip now (y/n)? "
  110. # read answer
  111. # [ "$answer" != "${answer#[Yy]}" ] && installpip
  112. echo "Please install pip3 before continuing with install"
  113. exit
  114. }
  115. installonmac() {
  116. brew install ripgrep fzf
  117. npm install -g tree-sitter-cli
  118. }
  119. installonubuntu() {
  120. sudo apt install ripgrep fzf
  121. sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
  122. pip3 install neovim-remote
  123. npm install -g tree-sitter-cli
  124. }
  125. installonarch() {
  126. sudo pacman -S ripgrep fzf
  127. pip3 install neovim-remote
  128. npm install -g tree-sitter-cli
  129. }
  130. installonfedora() {
  131. sudo dnf groupinstall "X Software Development"
  132. sudo dnf install -y fzf ripgrep
  133. }
  134. installongentoo() {
  135. sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib
  136. npm install -g tree-sitter-cli
  137. }
  138. installextrapackages() {
  139. [ "$(uname)" = "Darwin" ] && installonmac
  140. grep -q Ubuntu /etc/os-release && installonubuntu
  141. [ -f "/etc/arch-release" ] && installonarch
  142. [ -f "/etc/artix-release" ] && installonarch
  143. [ -f "/etc/fedora-release" ] && installonfedora
  144. [ -f "/etc/gentoo-release" ] && installongentoo
  145. [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported"
  146. }
  147. # Welcome
  148. echo 'Installing LunarVim'
  149. case "$@" in
  150. *--overwrite*)
  151. echo '!!Warning!! -> Removing all nvim related config because of the --overwrite flag'
  152. rm -rf "$HOME/.config/nvim"
  153. rm -rf "$HOME/.cache/nvim"
  154. rm -rf "$HOME/.local/share/nvim/site/pack/packer"
  155. ;;
  156. esac
  157. # move old nvim directory if it exists
  158. [ -d "$HOME/.config/nvim" ] && moveoldnvim
  159. # install pip
  160. (command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip
  161. # install node and neovim support
  162. (command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode
  163. # install pynvim
  164. (pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim
  165. if [ -e "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]; then
  166. echo 'packer already installed'
  167. else
  168. installpacker
  169. fi
  170. if [ -e "$HOME/.config/nvim/init.lua" ]; then
  171. echo 'LunarVim already installed'
  172. else
  173. # clone config down
  174. cloneconfig
  175. # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc
  176. # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc
  177. fi
  178. echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
  179. # echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc'