install-nv-code.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/bin/bash
  2. set -o nounset # error when referencing undefined variable
  3. set -o errexit # exit when command fails
  4. installnodemac() {
  5. brew install lua
  6. brew install node
  7. brew install yarn
  8. }
  9. installnodeubuntu() {
  10. sudo apt install nodejs
  11. sudo apt install npm
  12. }
  13. installnodearch() {
  14. sudo pacman -S nodejs
  15. sudo pacman -S npm
  16. }
  17. installnode() {
  18. echo "Installing node..."
  19. [ "$(uname)" == "Darwin" ] && installnodemac
  20. [ -n "$(uname -a | grep Ubuntu)" ] && installnodeubuntu
  21. [ -f "/etc/arch-release" ] && installnodearch
  22. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  23. sudo npm i -g neovim
  24. }
  25. installpiponmac() {
  26. sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  27. python3 get-pip.py
  28. rm get-pip.py
  29. }
  30. installpiponubuntu() {
  31. sudo apt install python3-pip >/dev/null
  32. }
  33. installpiponarch() {
  34. pacman -S python-pip
  35. }
  36. installpip() {
  37. echo "Installing pip..."
  38. [ "$(uname)" == "Darwin" ] && installpiponmac
  39. [ -n "$(uname -a | grep Ubuntu)" ] && installpiponubuntu
  40. [ -f "/etc/arch-release" ] && installpiponarch
  41. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  42. }
  43. installpynvim() {
  44. echo "Installing pynvim..."
  45. pip3 install pynvim --user
  46. }
  47. installpacker() {
  48. git clone https://github.com/wbthomason/packer.nvim\
  49. ~/.local/share/nvim/site/pack/packer/start/packer.nvim
  50. }
  51. cloneconfig() {
  52. echo "Cloning NVCode configuration"
  53. git clone https://github.com/ChristianChiarulli/nvcode.git ~/.config/nvcode
  54. mv $HOME/.config/nvcode/init.lua $HOME/.config/nvcode/init.lua.tmp
  55. mv $HOME/.config/nvcode/utils/init.lua $HOME/.config/nvcode/init.lua
  56. nvim -u $HOME/.config/nvcode/init.lua --headless +PackerSync +qall
  57. rm $HOME/.config/nvcode/init.lua
  58. mv $HOME/.config/nvcode/init.lua.tmp $HOME/.config/nvcode/init.lua
  59. }
  60. asktoinstallnode() {
  61. echo "node not found"
  62. echo -n "Would you like to install node now (y/n)? "
  63. read answer
  64. [ "$answer" != "${answer#[Yy]}" ] && installnode
  65. }
  66. asktoinstallpip() {
  67. # echo "pip not found"
  68. # echo -n "Would you like to install pip now (y/n)? "
  69. # read answer
  70. # [ "$answer" != "${answer#[Yy]}" ] && installpip
  71. echo "Please install pip3 before continuing with install"
  72. exit
  73. }
  74. installonmac() {
  75. brew install ripgrep fzf ranger
  76. }
  77. pipinstallueberzug() {
  78. which pip3 >/dev/null && pip3 install ueberzug || echo "Not installing ueberzug pip not found"
  79. }
  80. installonubuntu() {
  81. sudo apt install ripgrep fzf ranger
  82. sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
  83. pip3 install ueberzug
  84. pip3 install neovim-remote
  85. }
  86. installonarch() {
  87. sudo pacman -S install ripgrep fzf ranger
  88. which yay >/dev/null && yay -S python-ueberzug-git || pipinstallueberzug
  89. pip3 install neovim-remote
  90. }
  91. installextrapackages() {
  92. [ "$(uname)" == "Darwin" ] && installonmac
  93. [ -n "$(uname -a | grep Ubuntu)" ] && installonubuntu
  94. [ -f "/etc/arch-release" ] && installonarch
  95. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  96. }
  97. # Welcome
  98. echo 'Installing NVCode'
  99. # install pip
  100. which pip3 >/dev/null && echo "pip installed, moving on..." || asktoinstallpip
  101. # install node and neovim support
  102. which node >/dev/null && echo "node installed, moving on..." || asktoinstallnode
  103. # install pynvim
  104. pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on..." || installpynvim
  105. # move old nvim directory if it exists
  106. # [ -d "$HOME/.config/nvim" ] && moveoldnvim
  107. if [ -a "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]; then
  108. echo 'packer already installed'
  109. else
  110. installpacker
  111. fi
  112. if [ -a "$HOME/.config/nvcode/init.lua" ]; then
  113. echo 'nvcode already installed'
  114. else
  115. # clone config down
  116. cloneconfig
  117. echo 'export PATH=$HOME/.config/nvcode/utils/bin:$PATH' >>~/.zshrc
  118. echo 'export PATH=$HOME/.config/nvcode/utils/bin:$PATH' >>~/.bashrc
  119. fi
  120. echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
  121. echo "I also recommend you add 'set preview_images_method ueberzug' to ~/.config/ranger/rc.conf"
  122. echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH appending to zshrc/bashrc'