install-nv-code.sh 4.2 KB

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