install.sh 6.6 KB

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