|
| 1 | +#!/usr/bin/env sh |
| 2 | +# |
| 3 | +# NormalNvim installer. |
| 4 | +# Supports: Arch, Ubuntu, MacOS, Termux |
| 5 | + |
| 6 | + |
| 7 | +# Detect OS |
| 8 | +IS_ARCH=$(if [ -f /etc/os-release ] && grep -q "NAME=\"Arch Linux\"" /etc/os-release; then echo "true"; else echo "false"; fi) |
| 9 | +IS_UBUNTU=$(if [ -f /etc/os-release ] && grep -q "NAME=\"Ubuntu\"" /etc/os-release; then echo "true"; else echo "false"; fi) |
| 10 | +IS_MACOS=$(if [ -d /Applications ] && [ -d /System ]; then echo "true"; else echo "false"; fi) |
| 11 | +IS_TERMUX=$(if [ -x "$(command -v pkg)" ] && [ -d "$HOME/.termux" ]; then echo "true"; else echo "false"; fi) |
| 12 | + |
| 13 | +# Currently unused |
| 14 | +IS_WSL=$(if grep -q Microsoft /proc/version; then echo "true"; else echo "false"; fi) |
| 15 | +IS_FEDORA=$(if [ -f /etc/fedora-release ]; then echo "true"; else echo "false"; fi) |
| 16 | +IS_NIXOS=$(if [ -d /etc/nixos ] && [ -f /etc/os-release ] && grep -q "NAME=\"NixOS\"" /etc/os-release; then echo "true"; else echo "false"; fi) |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +## INSTALL NormalNvim |
| 22 | +############################################################################### |
| 23 | +echo "Welcome to NormalNvim!" |
| 24 | +echo "==================================================================" |
| 25 | +echo "This installer will ask you for confirmation on every step before:" |
| 26 | +echo "==================================================================" |
| 27 | +echo "1) Clone NormalNvim on '~/.config/nvim'." |
| 28 | +echo "2) (optional) We will ask you to fork NormalNvim on GitHub, and provide your GitHub username so we can change git remote origin to your fork." |
| 29 | +echo "3) (optional) Install system dependencies, to unlock all features." |
| 30 | +echo "==================================================================" |
| 31 | +echo |
| 32 | +echo |
| 33 | +echo |
| 34 | +echo |
| 35 | +echo "Step 1: Cloning NormalNvim on ~/.config/nvim" |
| 36 | +echo "------------------------------------------------------------------" |
| 37 | +if [ -d ~/.config/nvim ]; then |
| 38 | + echo "ERROR: The directory '~/.config/nvim' already exist. "\ |
| 39 | + "Please move it to a different location before installing NormalNvim." |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | +echo "INFO: Installing NormalNvim in '~/.config/nvim'" |
| 43 | +git clone https://github.com/NormalNvim/NormalNvim.git ~/.config/nvim |
| 44 | +cd ~/.config/nvim || echo 2>&1 |
| 45 | +echo "------------------------------------------------------------------" |
| 46 | +echo "SUCCESS: NormalNvim installed correctly" |
| 47 | +echo "------------------------------------------------------------------" |
| 48 | +printf "PRESS ENTER TO CONTINUE" |
| 49 | +read -r |
| 50 | +echo |
| 51 | +echo |
| 52 | +echo |
| 53 | +echo |
| 54 | + |
| 55 | + |
| 56 | +## DETECT REMOTE ORIGIN |
| 57 | +############################################################################### |
| 58 | +echo "Step 2: Change git remote origin (optional)" |
| 59 | +echo "------------------------------------------------------------------" |
| 60 | +echo "* We recommend forking NormalNvim." |
| 61 | +echo "* You can do it now." |
| 62 | +echo "* We are gonna ask your GitHub username to set your" |
| 63 | +echo " git remote URL to git://github.com/<your_username>/NormalNvim.git" |
| 64 | +echo "" |
| 65 | +printf "Please, enter your GitHub username [leave blank to skip]: " |
| 66 | +read -r github_username |
| 67 | + |
| 68 | +# Check if the username is not empty |
| 69 | +if [ -n "$github_username" ]; then |
| 70 | + # Change the remote URL |
| 71 | + git remote set-url origin "git://github.com/$github_username/NormalNvim.git" |
| 72 | + echo "------------------------------------------------------------------" |
| 73 | + echo "SUCCESS: GitHub username provided. You will get updates from:" |
| 74 | + echo " git://github.com/$github_username/NormalNvim.git" |
| 75 | + echo "------------------------------------------------------------------" |
| 76 | +else |
| 77 | + echo "------------------------------------------------------------------" |
| 78 | + echo "SKIPPED: No GitHub username provided. You will get updated from:" |
| 79 | + echo " git://github.com/NormalNvim/NormalNvim.git" |
| 80 | + echo "------------------------------------------------------------------" |
| 81 | +fi |
| 82 | +echo |
| 83 | +echo |
| 84 | +echo |
| 85 | +echo |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +## INSTALL DEPENDENCIES |
| 91 | +############################################################################### |
| 92 | +echo "Step 3: Install system dependencies (optional)" |
| 93 | +echo "------------------------------------------------------------------" |
| 94 | +printf "Do you want to install the dependencies? [Y/n]" |
| 95 | +read answer |
| 96 | +answer_lowercase=$(echo "$answer" | tr '[:upper:]' '[:lower:]') |
| 97 | +if [ -z "$answer_lowercase" ] || [ "$answer_lowercase" = "y" ] || [ "$answer_lowercase" = "yes" ]; then |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + ## ARCH INSTALLER (dependencies) |
| 103 | + ############################################################################# |
| 104 | + if [ "$IS_ARCH" = "true" ]; then |
| 105 | + echo "Arch Linux detected." |
| 106 | + |
| 107 | + # DETECT AUR CLIENT |
| 108 | + # ----------------- |
| 109 | + if command -v paru > /dev/null 2>&1; then AUR_CMD="paru"; |
| 110 | + elif command -v yay > /dev/null 2>&1; then AUR_CMD="yay"; fi |
| 111 | + |
| 112 | + # INSTALL DEPENDENCIES |
| 113 | + # -------------------- |
| 114 | + if [ -n "$AUR_CMD" ]; then |
| 115 | + "$AUR_CMD" -S --needed ranger-git python-pynvim fd git-delta grcov rustup yarn python-pytest dotnet-sdk swift-bin && yarn global add jest typedoc jdoc && cargo install cargo-nextest && "$AUR_CMD" -S --needed mingw-w64 dotnet-runtime dotnet-sdk aspnet-runtime-bin mono jdk-openjdk dart kotlin elixir npm nodejs typescript make go nasm r nuitka pyinstaller python ruby perl lua doxygen && go install golang.org/x/tools/cmd/godoc@latest |
| 116 | + else |
| 117 | + echo "ERROR: You must have 'paru' or 'yay' installed so we can use the AUR." |
| 118 | + fi |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | + # UBUNTU INSTALLER (dependencies) |
| 124 | + ############################################################################# |
| 125 | + elif [ "$IS_UBUNTU" = "true" ]; then |
| 126 | + echo "Ubuntu detected." |
| 127 | + sudo apt update && sudo apt install yarn ranger fd-find && pip install pynvim pytest && yarn add global jest typedoc jdoc && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh && cargo install git-delta grcov && wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh && chmod +x ./dotnet-install.sh && ./dotnet-install.sh && rm -f ./dotnet-install.sh && sudo apt install mingw-w64 dotnet-sdk-7.0 mono-complete default-jdk nasm r-base rustc golang-go python ruby perl lua5.3 kotlin elixir make nodejs npm doxygen && sudo npm install -g typescript && pip install pyinstaller && pip install nuitka && go install golang.org/x/tools/cmd/godoc@latest && sudo snap install dart flutter --classic && wget https://swift.org/builds/swift-5.5-release/ubuntu2004/swift-5.5-RELEASE/swift-5.5-RELEASE-ubuntu20.04.tar.gz && tar -xzf swift-5.5-RELEASE-ubuntu20.04.tar.gz && sudo mv swift-5.5-RELEASE-ubuntu20.04 /opt/swift && export PATH=/opt/swift/usr/bin:"${PATH}" |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | + # MACOS INSTALLER (dependencies) |
| 133 | + ############################################################################# |
| 134 | + elif [ "$IS_MACOS" = "true" ]; then |
| 135 | + echo "MacOS detected." |
| 136 | + brew tap dart-lang/dart flutter/flutter homebrew/cask && brew install rustup-init yarn ranger pynvim pytest fd rip-delta && cargo install grcov && yarn add global jest typedoc jdoc && brew install --cask dotnet-sdk flutter && brew install mingw-w64 dotnet mono openjdk rust go nasm r pyinstaller python perl lua dart kotlin elixir node typescript swift make doxygen && pip install nuitka && go install golang.org/x/tools/cmd/godoc@latest |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + # IS_TERMUX (dependencies) |
| 142 | + ############################################################################# |
| 143 | + elif [ "$IS_TERMUX" = "true" ]; then |
| 144 | + echo "Termux detected." |
| 145 | + pkg install -y clang ranger binutils fd yarn rust swift && pip install pynvim pytest nuitka pyinstaller && yarn add global jest typedoc jdoc && pkg install -y dotnet-sdk mono openjdk-17 kotlin rust golang nasm python ruby perl lua53 dart nodejs elixir make doxygen && npm install -g typescript && go install golang.org/x/tools/cmd/godoc@latest && cargo install git-delta grcov |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + # ERROR: OS NOT DETECTED |
| 151 | + ############################################################################# |
| 152 | + else |
| 153 | + echo "ERROR: It seems your OS is not Arch Linux, Ubuntu, MacOS or Termux." |
| 154 | + echo "Your OS is not directly supported." |
| 155 | + echo "But you can still read the wiki and install the dependencies manually." |
| 156 | + fi |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +fi # End of install dependencies |
| 162 | + |
| 163 | + |
| 164 | +# SUCCESS MESSAGE |
| 165 | +############################################################################### |
| 166 | +echo |
| 167 | +echo |
| 168 | +echo |
| 169 | +echo |
| 170 | +echo "NormalNvim has been correctly installed" |
| 171 | +echo "========================================" |
| 172 | +echo "The first time you open NormalNvim, it will install the next things concurrently:" |
| 173 | +echo "" |
| 174 | +echo "* PLUGINS: → You can remove from your config the ones you don't want later." |
| 175 | +echo "* MASON: → Pre-configured LSP servers, linters, formatters and debuggers." |
| 176 | +echo "* TREESITTER: → For improved syntax highlighting." |
| 177 | +echo "" |
| 178 | +echo "========================================" |
| 179 | +echo "PRESS ENTER TO OPEN IT" |
| 180 | +nvim -c ':NvimUpdatePlugins' -c ':MasonInstall lua-language-server prettierd eslint-lsp typescript-language-server css-lsp asm-lsp netcoredbg json-lsp codelldb firefox-debug-adapter chrome-debug-adapter rust-analyzer clangd omnisharp bash-language-server shellcheck jedi-language-server pylama flake8 autopep8 autoflake debugpy ruby-lsp taplo ktlint yaml-language-server neocmakelsp angular-language-server ansible-language-server dockerfile-language-server docker-compose-language-service helm-ls fsautocomplete fantomas perlnavigator kotlin-language-server svelte-language-server phpactor stylua csharpier bash-debug-adapter asmfmt java-test google-java-format dart-debug-adapter gopls golangci-lint gofumpt golangci-lint-langserver kotlin-debug-adapter rubocop beautysh gersemi cmakelint eslint_d markuplint php-cs-fixer phpstan delve matlab-language-server zls elixir-ls php-debug-adapter' -c ':TSInstall all' 2>&1 |
0 commit comments