diff --git a/installs/neovim.sh b/installs/neovim.sh index 4662ea0..0dd3179 100755 --- a/installs/neovim.sh +++ b/installs/neovim.sh @@ -105,14 +105,15 @@ $_sudo apk add neovim } + echo_info "Fetching latest stable Neovim version..." + latest_version=$(curl -s https://api.github.com/repos/neovim/neovim/releases/latest | grep 'tag_name' | cut -d\" -f4) + inst_generic() { tempdir="$(mktemp -d)" if [ ! -d "$HOME/.bin" ]; then mkdir -p "$HOME/.bin" fi - echo_info "Fetching latest stable Neovim version..." - latest_version=$(curl -s https://api.github.com/repos/neovim/neovim/releases/latest | grep 'tag_name' | cut -d\" -f4) echo_info "Downloading Neovim version $latest_version..." # Download the tarball @@ -143,6 +144,10 @@ echo_info "Neovim $latest_version installed successfully" } + checkVersion() { + currentVersion="$(nvim --version | head -n1 | awk '{print $2}')" + } + # ─< Distribution detection and installation >──────────────────────────────────────── get_packager() { if [ -e /etc/os-release ]; then @@ -186,9 +191,12 @@ # ─< Main function >───────────────────────────────────────────────────────────────── main() { if command_exists nvim; then - echo_warning "Neovim is already installed in version: $(nvim --version)" - echo_error "Exiting now!" - exit 0 + checkVersion + if [ "$(printf '%s\n' "$latest_version" "$currentVersion" | sort -V | head -n1)" = "$latest_version" ]; then + echo_warning "Neovim is already installed in version: $currentVersion" + echo_error "Exiting now!" + exit 0 + fi fi echo_info "Starting Neovim installation script..."