[neovim] Add script to check updates for plugins pinned by commitid

This commit is contained in:
Daniel Carrillo 2022-10-01 17:20:10 +02:00
parent 5ba5be3325
commit 5aecb9f369
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Best effort script to check whenever a plugin pinned by commit has updates.
# plugins.lua must be formatted with stylua before running the script.
#
PLUGINS_DIR="$HOME/.local/share/nvim/site/pack/packer/start"
function check_update() {
local plugin=$1
local current_commit=$2
local last_commit
local remote_url
pushd "$PLUGINS_DIR/$plugin" > /dev/null || exit
last_commit=$(git log -n 1 --pretty=format:"%H" origin/HEAD)
remote_url=$(git config --get remote.origin.url)
if [[ "$current_commit" != "$last_commit" ]]; then
echo -e "Plugin $plugin has a new version $last_commit (the current version is $current_commit)\n\tURL: $remote_url"
fi
popd > /dev/null || exit
}
pushd "$HOME/.config/nvim/lua/user" > /dev/null || exit
grep -P "use.*commit" plugins.lua < plugins.lua | cut -f 2,4 -d "\"" | while IFS= read -r line; do
plugin=$(echo "$line" | cut -f1 -d "\"" | cut -f2 -d "/")
current_commit=$(echo "$line" | cut -f2 -d "\"")
check_update "$plugin" "$current_commit"
done
grep -P "^\t*commit" plugins.lua < plugins.lua | cut -f2 -d "\"" | while IFS= read -r current_commit; do
plugin=$(grep "$current_commit" -B1 plugins.lua | grep -v "$current_commit" | cut -f2 -d "\"" | cut -f2 -d "/")
check_update "$plugin" "$current_commit"
done
grep -P "^\t*requires.*commit" < plugins.lua | cut -f 2,4 -d "\"" | while IFS= read -r line; do
plugin=$(echo "$line" | cut -f1 -d "\"" | cut -f2 -d "/")
current_commit=$(echo "$line" | cut -f2 -d "\"")
check_update "$plugin" "$current_commit"
done
popd > /dev/null || exit

View File

@ -43,7 +43,7 @@ return packer.startup(function(use)
use({ "wbthomason/packer.nvim", commit = "6afb67460283f0e990d35d229fd38fdc04063e0a" })
use({ "nvim-lua/plenary.nvim", commit = "4b7e52044bbb84242158d977a50c4cbcd85070c7" })
use({ "windwp/nvim-autopairs", commit = "14cc2a4fc6243152ba085cc2059834113496c60a" })
use({ "numToStr/Comment.nvim", tag = "v0.6.1" })
use({ "numToStr/Comment.nvim", tag = "v0.*" })
use({ "JoosepAlviste/nvim-ts-context-commentstring", commit = "4d3a68c41a53add8804f471fcc49bb398fe8de08" })
use({ "kyazdani42/nvim-web-devicons", commit = "563f3635c2d8a7be7933b9e547f7c178ba0d4352" })
use({ "akinsho/bufferline.nvim", tag = "v2.*" })