install-nv-code.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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/opt/packer.nvim
  50. }
  51. cloneconfig() {
  52. echo "Cloning NVCode configuration"
  53. git clone https://github.com/ChristianChiarulli/nvcode.git ~/.config/nvcode
  54. nvim --headless +PackerInstall +qall >/dev/null 2>&1
  55. }
  56. asktoinstallnode() {
  57. echo "node not found"
  58. echo -n "Would you like to install node now (y/n)? "
  59. read answer
  60. [ "$answer" != "${answer#[Yy]}" ] && installnode
  61. }
  62. asktoinstallpip() {
  63. # echo "pip not found"
  64. # echo -n "Would you like to install pip now (y/n)? "
  65. # read answer
  66. # [ "$answer" != "${answer#[Yy]}" ] && installpip
  67. echo "Please install pip3 before continuing with install"
  68. exit
  69. }
  70. installonmac() {
  71. brew install ripgrep fzf ranger
  72. }
  73. pipinstallueberzug() {
  74. which pip3 >/dev/null && pip3 install ueberzug || echo "Not installing ueberzug pip not found"
  75. }
  76. installonubuntu() {
  77. sudo apt install ripgrep fzf ranger
  78. sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
  79. pip3 install ueberzug
  80. pip3 install neovim-remote
  81. }
  82. installonarch() {
  83. sudo pacman -S install ripgrep fzf ranger
  84. which yay >/dev/null && yay -S python-ueberzug-git || pipinstallueberzug
  85. pip3 install neovim-remote
  86. }
  87. installextrapackages() {
  88. [ "$(uname)" == "Darwin" ] && installonmac
  89. [ -n "$(uname -a | grep Ubuntu)" ] && installonubuntu
  90. [ -f "/etc/arch-release" ] && installonarch
  91. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  92. }
  93. # Welcome
  94. echo 'Installing NVCode'
  95. # install pip
  96. which pip3 >/dev/null && echo "pip installed, moving on..." || asktoinstallpip
  97. # install node and neovim support
  98. which node >/dev/null && echo "node installed, moving on..." || asktoinstallnode
  99. # install pynvim
  100. pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on..." || installpynvim
  101. # move old nvim directory if it exists
  102. # [ -d "$HOME/.config/nvim" ] && moveoldnvim
  103. [ -f "~/.local/share/nvim/site/pack/packer/opt/packer.nvim" ] || installpacker
  104. # clone config down
  105. cloneconfig
  106. echo 'export PATH=$HOME/.config/nvcode/utils/bin:$PATH' >>~/.zshrc
  107. echo 'export PATH=$HOME/.config/nvcode/utils/bin:$PATH' >>~/.bashrc
  108. echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
  109. echo "I also recommend you add 'set preview_images_method ueberzug' to ~/.config/ranger/rc.conf"
  110. echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH appending to zshrc/bashrc'