[neovim] Add auto-replace to check_plugin_updates.sh

This commit is contained in:
Daniel Carrillo 2022-10-07 19:31:01 +02:00
parent 1ebdd0846c
commit 893b6e0b7b
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
2 changed files with 20 additions and 11 deletions

View File

@ -4,12 +4,16 @@
# Best effort script to check whenever a plugin pinned by commit has updates.
# plugins.lua must be formatted with stylua before running the script.
#
# Add flag --update to replace the commit id by the latest one
#
#
PLUGINS_DIR="$HOME/.local/share/nvim/site/pack/packer/start"
function check_update() {
local plugin=$1
local current_commit=$2
local update=${3:-"false"}
local last_commit
local remote_url
@ -18,6 +22,10 @@ function check_update() {
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"
if [[ $update == "--update" ]]; then
sed -i "s/$current_commit/$last_commit/" "$HOME/.config/nvim/lua/user/plugins.lua"
fi
else
echo "Plugin $plugin is up to date."
fi
@ -25,23 +33,24 @@ function check_update() {
popd > /dev/null || exit
}
update=${1:-"false"}
pushd "$HOME/.config/nvim/lua/user" > /dev/null || exit
grep -P "use.*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"
check_update "$plugin" "$current_commit" "$update"
done
grep -P "^\t*commit" 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"
check_update "$plugin" "$current_commit" "$update"
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"
check_update "$plugin" "$current_commit" "$update"
done
popd > /dev/null || exit

View File

@ -48,7 +48,7 @@ return packer.startup(function(use)
use({ "kyazdani42/nvim-web-devicons", commit = "a8cf88cbdb5c58e2b658e179c4b2aa997479b3da" })
use({ "akinsho/bufferline.nvim", tag = "v2.*" })
use({ "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" })
use({ "nvim-lualine/lualine.nvim", commit = "f564015a23b7874ee83ae1b1c9ace723d915e16d" })
use({ "nvim-lualine/lualine.nvim", commit = "edca2b03c724f22bdc310eee1587b1523f31ec7c" })
use({ "lewis6991/impatient.nvim", commit = "b842e16ecc1a700f62adb9802f8355b99b52a5a6" })
use({ "lukas-reineke/indent-blankline.nvim", tag = "v2.*" })
use({ "Pocco81/auto-save.nvim", commit = "2c7a2943340ee2a36c6a61db812418fca1f57866" })
@ -56,7 +56,7 @@ return packer.startup(function(use)
use({ "romgrk/fzy-lua-native", commit = "085c7d262aa35cc55a8523e8c1618d398bf717a7", run = "make" })
use({ "mg979/vim-visual-multi", tag = "v0.*" })
use({ "Shatur/neovim-session-manager", commit = "4005dac93f5cd1257792259ef4df6af0e3afc213" })
use({ "nvim-treesitter/nvim-treesitter", commit = "a1bf2c75c01d612c4c3128aad6e291fe41eb03a9" })
use({ "nvim-treesitter/nvim-treesitter", commit = "5d11dfc27849e3d7435c32dbd8ea9be35bcd990b" })
use({
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
@ -64,11 +64,11 @@ return packer.startup(function(use)
})
-- Colorschemes
use({ "folke/tokyonight.nvim", commit = "d6a0adfe3f914efa06ca6e662f0b1398f3522783" })
use({ "folke/tokyonight.nvim", commit = "fd9105c9487996aa2269992b72a6fea7504688e4" })
use({ "EdenEast/nightfox.nvim", commit = "59c3dbcec362eff7794f1cb576d56fd8a3f2c8bb" })
-- cmp plugins
use({ "hrsh7th/nvim-cmp", commit = "b0dff0ec4f2748626aae13f011d1a47071fe9abc" })
use({ "hrsh7th/nvim-cmp", commit = "0e436ee23abc6c3fe5f3600145d2a413703e7272" })
use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" })
use({ "hrsh7th/cmp-path", commit = "91ff86cd9c29299a64f968ebb45846c485725f23" })
use({ "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36" })
@ -77,12 +77,12 @@ return packer.startup(function(use)
-- snippets
use({ "L3MON4D3/LuaSnip", tag = "v1.*" })
use({ "rafamadriz/friendly-snippets", commit = "9f4ffd17ade26815cad52ba90f478a4e6e2d80df" })
use({ "rafamadriz/friendly-snippets", commit = "6cd7469403fd06a3840a1065728d1affe1c23ec8" })
-- LSP
use({ "neovim/nvim-lspconfig", commit = "fc2f44dc6024bddb75b82e471c642ad1f4483094" })
use({ "neovim/nvim-lspconfig", commit = "9d4b8d393aad0e6e9227e2d67629aa99e56b994a" })
use({ "williamboman/nvim-lsp-installer", commit = "23820a878a5c2415bfd3b971d1fe3c79e4dd6763" })
use({ "jose-elias-alvarez/null-ls.nvim", commit = "4e1118c3f19885623d060aa9b10e41544232f183" })
use({ "jose-elias-alvarez/null-ls.nvim", commit = "6a98411e70fad6928f7311eeade4b1753cb83524" })
use({ "RRethy/vim-illuminate", commit = "0603e75fc4ecde1ee5a1b2fc8106ed6704f34d14" })
use({ "folke/trouble.nvim", commit = "929315ea5f146f1ce0e784c76c943ece6f36d786" })
@ -110,7 +110,7 @@ return packer.startup(function(use)
use({ "ray-x/go.nvim", commit = "1aef2d60bd220a8d58a0b5fed6af696b6244ce1d" })
use({
"ray-x/guihua.lua",
commit = "5d7f45500ece68832b2d2f0b9592a00b7cacd0b6",
commit = "2fce8a8b462cf6599d9422efb157773126e1c7ce",
run = "cd lua/fzy && make",
config = function()