|
| 1 | +#!/usr/bin/env sh |
| 2 | +# |
| 3 | +# NormalNvim installer. |
| 4 | +# Supports: Arch, Ubuntu, MacOS, Termux, Fedora, WSL |
| 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 |
| 24 | +echo "Welcome to NormalNvim!" |
| 25 | +echo "==================================================================" |
| 26 | +echo "This installer will ask you for confirmation on every step before:" |
| 27 | +echo "==================================================================" |
| 28 | +echo "1) Cloning NormalNvim on '~/.config/nvim'." |
| 29 | +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." |
| 30 | +echo "3) (optional) Install system dependencies, to unlock all features." |
| 31 | +echo "==================================================================" |
| 32 | +echo |
| 33 | +echo |
| 34 | +echo |
| 35 | +echo |
| 36 | +echo "Step 1: Cloning NormalNvim on ~/.config/nvim" |
| 37 | +echo "------------------------------------------------------------------" |
| 38 | +if [ -d ~/.config/nvim ]; then |
| 39 | + echo "ERROR: The directory ~/.config/nvim already exist." |
| 40 | + echo " Please move it to a different location before installing." |
| 41 | + exit 1 |
| 42 | +fi |
| 43 | +echo "INFO: Installing NormalNvim in '~/.config/nvim'" |
| 44 | +git clone https://github.com/NormalNvim/NormalNvim.git ~/.config/nvim |
| 45 | +cd ~/.config/nvim || echo 2>&1 |
| 46 | +echo "------------------------------------------------------------------" |
| 47 | +echo "SUCCESS: NormalNvim installed correctly" |
| 48 | +echo "------------------------------------------------------------------" |
| 49 | +printf "PRESS ENTER TO CONTINUE" |
| 50 | +read -r |
| 51 | +echo |
| 52 | +echo |
| 53 | +echo |
| 54 | +echo |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +## DETECT REMOTE ORIGIN |
| 60 | +############################################################################### |
| 61 | +echo "Step 2: Change git remote origin (optional)" |
| 62 | +echo "------------------------------------------------------------------" |
| 63 | +echo "* We recommend forking NormalNvim." |
| 64 | +echo "* You can do it now." |
| 65 | +echo "* We are gonna ask your GitHub username to set your" |
| 66 | +echo " git remote URL to git://github.com/<your_username>/NormalNvim.git" |
| 67 | +echo "" |
| 68 | +printf "Please, enter your GitHub username [leave blank to skip]: " |
| 69 | +read -r github_username |
| 70 | + |
| 71 | +# Check if the username is not empty |
| 72 | +if [ -n "$github_username" ]; then |
| 73 | + # Change the remote URL |
| 74 | + git remote set-url origin "git://github.com/$github_username/NormalNvim.git" |
| 75 | + echo "------------------------------------------------------------------" |
| 76 | + echo "SUCCESS: GitHub username provided. You will get updates from:" |
| 77 | + echo " git://github.com/$github_username/NormalNvim.git" |
| 78 | + echo "------------------------------------------------------------------" |
| 79 | +else |
| 80 | + echo "------------------------------------------------------------------" |
| 81 | + echo "SKIPPED: No GitHub username provided. You will get updates from:" |
| 82 | + echo " git://github.com/NormalNvim/NormalNvim.git" |
| 83 | + echo "------------------------------------------------------------------" |
| 84 | +fi |
| 85 | +echo |
| 86 | +echo |
| 87 | +echo |
| 88 | +echo |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +## INSTALL DEPENDENCIES |
| 94 | +############################################################################### |
| 95 | +echo "Step 3: Install system dependencies (optional)" |
| 96 | +echo "------------------------------------------------------------------" |
| 97 | +printf "Do you want to install the dependencies? [Y/n]" |
| 98 | +read -r answer |
| 99 | +answer_lowercase=$(echo "$answer" | tr '[:upper:]' '[:lower:]') |
| 100 | +if [ -z "$answer_lowercase" ] || [ "$answer_lowercase" = "y" ] || [ "$answer_lowercase" = "yes" ]; then |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + ## ARCH INSTALLER (dependencies) |
| 106 | + ############################################################################# |
| 107 | + if [ "$IS_ARCH" = "true" ]; then |
| 108 | + echo "Arch Linux detected." |
| 109 | + |
| 110 | + # DETECT AUR CLIENT |
| 111 | + # ----------------- |
| 112 | + if command -v paru > /dev/null 2>&1; then AUR_CMD="paru -S --needed"; |
| 113 | + elif command -v yay > /dev/null 2>&1; then AUR_CMD="yay -S --needed"; fi |
| 114 | + |
| 115 | + # INSTALL DEPENDENCIES |
| 116 | + # -------------------- |
| 117 | + if [ -n "$AUR_CMD" ]; then |
| 118 | + "$AUR_CMD" "python" "python-pynvim" "fd" "git-delta" "grcov" "rustup" "yarn" "python-pytest" "mingw-w64-gcc" "dotnet-runtime" "dotnet-sdk" "aspnet-runtime" "mono" "jdk-openjdk" "dart" "kotlin" "elixir" "npm" "nodejs" "typescript" "make" "go" "nasm" "r" "nuitka" "python" "ruby" "perl" "lua" "pyinstaller" "swift-bin" "doxygen"; yarn global add "jest" "jsdoc" "typedoc"; cargo install "cargo-nextest"; go install "golang.org/x/tools/cmd/godoc@latest" |
| 119 | + else |
| 120 | + echo "ERROR: You must have 'paru' or 'yay' installed so we can use the AUR." |
| 121 | + fi |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | + # UBUNTU INSTALLER (dependencies) |
| 127 | + ############################################################################# |
| 128 | + elif [ "$IS_UBUNTU" = "true" ]; then |
| 129 | + echo "Ubuntu detected." |
| 130 | + sudo apt update; sudo apt install --install-if-missing "yarn" "ranger" "rust-fd-find" "python-pynvim" "python-pytest" "delta" "rust-grcov" "rustup" "mingw-w64" "dotnet8" "monodevelop" "java-common" "nasm" "r-base" "rustc" "golang" "python" "ruby" "perl" "lua5.3" "kotlin" "elixir" "make" "nodejs" "npm" "node-typescript" "nuitka"; pip install "pyinstaller"; yarn global add "jest" "jsdoc" "typedoc"; go install "golang.org/x/tools/cmd/godoc@latest"; sudo snap install --classic "flutter" |
| 131 | + |
| 132 | + |
| 133 | + |
| 134 | + |
| 135 | + # MACOS INSTALLER (dependencies) |
| 136 | + ############################################################################# |
| 137 | + elif [ "$IS_MACOS" = "true" ]; then |
| 138 | + echo "MacOS detected." |
| 139 | + sudo brew install "ranger" "fd" "git-delta" "rustup-init" "yarn" "mingw-w64" "dotnet" "mono" "openjdk" "dart-sdk" "kotlin" "elixir" "node" "typescript" "make" "rust" "go" "nasm" "r" "ruby" "perl" "lua" "swift" "pyinstaller" "doxygen"; sudo brew install --cask "dotnet-sdk" "flutter"; pip install "pynvim" "pytest" "Nuitka"; yarn add global "jest" "jsdoc" "typedoc"; cargo install "cargo-nextest" "grcov"; go install "golang.org/x/tools/cmd/godoc@latest" |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + # TERMUX INSTALLER (dependencies) |
| 145 | + ############################################################################# |
| 146 | + elif [ "$IS_TERMUX" = "true" ]; then |
| 147 | + echo "Termux detected." |
| 148 | + pkg update; pkg install "tur-repo"; pkg install "ranger" "python" "fd" "git-delta" "yarn" "mono" "openjdk-17" "dart" "kotlin" "elixir" "nodejs" "make" "rust" "golang" "nasm" "python" "ruby" "perl" "liblua52" "swift" "binutils-libs" "gcc-default" "doxygen"; pip install "pynvim" "pytest" "Nuitka" "pyinstaller"; yarn add global "jest" "typescript" "jsdoc" "typedoc"; cargo install "cargo-nextest" "git-delta" "grcov"; go install "golang.org/x/tools/cmd/godoc@latest" |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | + # FEDORA INSTALLER (dependencies) |
| 154 | + ############################################################################# |
| 155 | + elif [ "$IS_FEDORA" = "true" ]; then |
| 156 | + echo "Fedora detected." |
| 157 | + sudo dnf install "rust-fd-find" "rust-git-delta" "rustup" "python3-pytest" "mingw64-gcc" "binutils" "dotnet6.0" "dotnet-runtime-6.0" "dotnet-sdk-6.0" "aspnetcore-runtime-6.0" "mono-complete" "java-21-openjdk" "elixir" "nodejs" "npm" "typescript" "make" "golang" "nasm" "R-rlang" "ruby" "perl" "lua" "swift-lang"; pip install "pynvim" "pytest" "Nuitka" "pyinstaller"; npm install -g "yarn" "jest" "typescript" "jsdoc" "typedoc"; cargo install "cargo-nextest" "grcov"; go install "golang.org/x/tools/cmd/godoc@latest" |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + # ERROR: OS NOT DETECTED |
| 163 | + ############################################################################# |
| 164 | + else |
| 165 | + echo "ERROR: It seems your OS is not Arch Linux, Ubuntu, MacOS, Termux, or Fedora." |
| 166 | + echo "Your OS is not directly supported." |
| 167 | + echo "But you can still read the wiki and install the dependencies manually." |
| 168 | + fi |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | +fi # End of install dependencies |
| 174 | + |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | +# SUCCESS MESSAGE |
| 179 | +############################################################################### |
| 180 | +echo |
| 181 | +echo |
| 182 | +echo |
| 183 | +echo |
| 184 | +echo "NormalNvim has been correctly installed" |
| 185 | +echo "========================================" |
| 186 | +echo "The first time you open NormalNvim, it will install the next things concurrently:" |
| 187 | +echo "" |
| 188 | +echo "* PLUGINS: → You can remove from your config the ones you don't want later." |
| 189 | +echo "* MASON: → Pre-configured LSP servers, linters, formatters and debuggers." |
| 190 | +echo "* TREESITTER: → For improved syntax highlighting." |
| 191 | +echo "" |
| 192 | +echo "========================================" |
| 193 | +echo "PRESS ENTER TO OPEN IT" |
| 194 | +nvim -c ':NvimUpdatePlugins' -c ':MasonInstall lua-language-server prettierd 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 markuplint php-cs-fixer phpstan delve matlab-language-server zls elixir-ls php-debug-adapter' -c ':TSInstall all' 2>&1 |
0 commit comments