[neovim] Migrate from packer to lazy

This commit is contained in:
Daniel Carrillo 2023-01-20 18:57:58 +01:00
parent 06032b6fd0
commit cdcd1cbf9f
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
8 changed files with 147 additions and 211 deletions

View File

@ -1,64 +0,0 @@
#!/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.
#
# Add flag --update to replace the commit id by the latest one
#
#
PLUGINS_DIR="$HOME/.local/share/nvim/site/pack/packer/start"
CONF_DIR="$HOME/.config/nvim/lua/core/"
has_updates=false
function check_update() {
local plugin=$1
local current_commit=$2
local update=${3:-"false"}
local last_commit
local remote_url
pushd "$PLUGINS_DIR/$plugin" > /dev/null || exit
git fetch origin +"$(git rev-parse --abbrev-ref HEAD)": 2> /dev/null
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"
git log "${current_commit}"..origin/HEAD --pretty='format:%x09%h - %s (%cr) <%an>' --no-merges
if [[ $update == "--update" ]]; then
sed -i "s/$current_commit/$last_commit/" "$CONF_DIR/plugins.lua"
fi
has_updates=true
fi
popd > /dev/null || exit
}
update=${1:-"false"}
pushd "$CONF_DIR" > /dev/null || exit
grep -P "^\t*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" "$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" "$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" "$update"
done
if [ "$has_updates" == "false" ]; then
echo "Everything is up to date"
fi
popd > /dev/null || exit

View File

@ -0,0 +1,53 @@
{
"Comment.nvim": { "branch": "master", "commit": "d9cfae1059b62f7eacc09dba181efe4894e3b086" },
"DAPInstall.nvim": { "branch": "main", "commit": "8798b4c36d33723e7bba6ed6e2c202f84bb300de" },
"LuaSnip": { "branch": "master", "commit": "563827f00bb4fe43269e3be653deabc0005f1302" },
"auto-save.nvim": { "branch": "main", "commit": "4b59610e1318f8a89501cee9d47a0e8650f0a4d5" },
"b64.nvim": { "branch": "main", "commit": "12dde6ebc3035f010833f513cfbd9abad92b28b3" },
"bufferline.nvim": { "branch": "main", "commit": "028a87933d99f8bb88f2f70a4def3ff9574f3594" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
"diffview.nvim": { "branch": "main", "commit": "5bbcf162d03287296fe393f88da6065db3cf9fd0" },
"friendly-snippets": { "branch": "main", "commit": "046e4d3491baf664e0eef5231d28beb49333578b" },
"fzy-lua-native": { "branch": "master", "commit": "085c7d262aa35cc55a8523e8c1618d398bf717a7" },
"git-blame.nvim": { "branch": "master", "commit": "5ddf157139ecfc0d2161f00c2cce4874578dc355" },
"gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
"go.nvim": { "branch": "master", "commit": "13f5e15fd752af2924f87a1a37b7a264aa8d748c" },
"guihua.lua": { "branch": "master", "commit": "fbce2f18b36ac809edbda0a60cb872209632e5d2" },
"impatient.nvim": { "branch": "main", "commit": "c90e273f7b8c50a02f956c24ce4804a47f18162e" },
"indent-blankline.nvim": { "branch": "master", "commit": "db7cbcb40cc00fc5d6074d7569fb37197705e7f6" },
"lazy.nvim": { "branch": "main", "commit": "75dcd5741d76e09b1a41c771fbc8b010a109b5cb" },
"lspsaga.nvim": { "branch": "main", "commit": "19744ee0b3c84832d8848754c444b9069c953316" },
"lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" },
"lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" },
"markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "5b388c0de30f1605671ebfb9a20a620cda50ffce" },
"mason.nvim": { "branch": "main", "commit": "41d6a88c9d08380f7e1e33d8471ffe36c0900347" },
"neo-tree.nvim": { "branch": "v2.x", "commit": "8238865e1d9c61f1a260c290653f2c419503e0a9" },
"nui.nvim": { "branch": "main", "commit": "b99e6cb13dc51768abc1c4c8585045a0c0459ef1" },
"null-ls.nvim": { "branch": "main", "commit": "33cfeb7a761f08e8535dca722d4b237cabadd371" },
"nvim-autopairs": { "branch": "master", "commit": "f00eb3b766c370cb34fdabc29c760338ba9e4c6c" },
"nvim-cmp": { "branch": "main", "commit": "11a95792a5be0f5a40bab5fc5b670e5b1399a939" },
"nvim-dap": { "branch": "master", "commit": "700a3c7d6fbe5b07bee74e9952b456120d355c47" },
"nvim-dap-ui": { "branch": "master", "commit": "1e21b3b50e67700e32285b5a74e645311fd8bbea" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "191345947a92a5188d791e9786a5b4f205dcaca3" },
"nvim-lspconfig": { "branch": "master", "commit": "d228bcf7cd94611929482a09e114a42c41fe81a8" },
"nvim-treesitter": { "branch": "master", "commit": "c9615952e71397cec4cf89a9a0db0fb9c491a5e1" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "a0f89563ba36b3bacd62cf967b46beb4c2c29e52" },
"nvim-web-devicons": { "branch": "master", "commit": "6c38926351372ea87034dec26182b62c835ff3bc" },
"plenary.nvim": { "branch": "master", "commit": "1c7e3e6b0f4dd5a174fcea9fda8a4d7de593b826" },
"projections.nvim": { "branch": "main", "commit": "6820ad90343b5ec78f236bbe0e13d9c8078a0c48" },
"sad.nvim": { "branch": "master", "commit": "e8ab74c7a506f96a823527bfa78a66681483120b" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "fab3e2212e206f4f8b3bbaa656e129443c9b802e" },
"telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" },
"telescope.nvim": { "branch": "master", "commit": "2f32775405f6706348b71d0bb8a15a22852a61e4" },
"tokyonight.nvim": { "branch": "main", "commit": "4071f7fa984859c5de7a1fd27069b99c3a0d802a" },
"trouble.nvim": { "branch": "main", "commit": "b2a0afac2c319a481f0f0318963a74d672ba5766" },
"vim-bbye": { "branch": "master", "commit": "25ef93ac5a87526111f43e5110675032dbcacf56" },
"vim-illuminate": { "branch": "master", "commit": "da80f3877896adcf77f59fb0bf74e9601615d372" },
"vim-markdown-toc": { "branch": "master", "commit": "7ec05df27b4922830ace2246de36ac7e53bea1db" },
"vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" },
"wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }
}

View File

@ -3,7 +3,7 @@ vim.cmd("autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTre
-- Highlight Yanked Text
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
callback = function()
vim.highlight.on_yank({ higroup = "Visual", timeout = 200 })
vim.highlight.on_yank({ higroup = "Visual", timeout = 250 })
end,
})
@ -36,29 +36,3 @@ vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
end,
})
-- Autostore session on VimExit
local session = require("projections.session")
vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
callback = function()
session.store(vim.loop.cwd())
end,
})
-- If vim was started with arguments, do nothing
-- If in some project's root, attempt to restore that project's session
-- If not, restore last session
-- If no sessions, do nothing
vim.api.nvim_create_autocmd({ "VimEnter" }, {
callback = function()
if vim.fn.argc() ~= 0 then
return
end
local session_info = session.info(vim.loop.cwd())
if session_info == nil then
session.restore_latest()
else
session.restore(vim.loop.cwd())
end
end,
desc = "Restore last session automatically",
})

View File

@ -1,14 +0,0 @@
local colorscheme = "tokyonight"
require("tokyonight").setup({
style = "moon",
styles = {
sidebars = "normal",
floats = "normal",
},
})
local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
if not status_ok then
return
end

View File

@ -1,9 +1,6 @@
require("core.plugins")
require("core.options")
require("core.colorscheme")
vim.defer_fn(function()
require("core.keymaps")
require("core.plugins")
require("core.autocommands")
require("core.commands")
end, 0)
require("core.keymaps")
require("core.plugins")
require("core.autocommands")
require("core.commands")

View File

@ -83,7 +83,7 @@ keymap("n", "<leader>fc", ":Telescope commands<CR>", opts)
-- Comment
keymap("n", "<leader>/", "<cmd>lua require'Comment.api'.toggle.linewise.current()<CR>", opts)
keymap("x", "<leader>/", "<ESC><CMD>lua require'Comment.api'.toggle.linewise(vim.fn.visualmode())<CR>")
keymap("x", "<leader>/", "<esc><cmd>lua require'Comment.api'.toggle.linewise(vim.fn.visualmode())<CR>", opts)
-- DAP
keymap("n", "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<cr>", opts)

View File

@ -1,139 +1,128 @@
local fn = vim.fn
-- Automatically install packer
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
PACKER_BOOTSTRAP = fn.system({
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
print("Installing packer close and reopen Neovim...")
vim.cmd([[packadd packer.nvim]])
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Autocommand that reloads neovim whenever you save the plugins.lua file
-- vim.cmd([[
-- augroup packer_user_config
-- autocmd!
-- autocmd BufWritePost plugins.lua source <afile> | PackerSync
-- augroup end
-- ]])
local status_ok, packer = pcall(require, "packer")
local status_ok, lazy = pcall(require, "lazy")
if not status_ok then
return
end
packer.init({
display = {
open_fn = function()
return require("packer.util").float({ border = "rounded" })
lazy.setup({
-- Colorschemes
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
config = function()
require("tokyonight").setup({
style = "moon",
styles = {
sidebars = "normal",
floats = "normal",
},
})
vim.cmd([[colorscheme tokyonight]])
end,
},
})
return packer.startup(function(use)
-- Plugins
use({ "wbthomason/packer.nvim", commit = "1d0cf98a561f7fd654c970c49f917d74fafe1530" })
use({ "nvim-lua/plenary.nvim", commit = "1c7e3e6b0f4dd5a174fcea9fda8a4d7de593b826" })
use({ "windwp/nvim-autopairs", commit = "f00eb3b766c370cb34fdabc29c760338ba9e4c6c" })
use({ "numToStr/Comment.nvim", tag = "v0.*" })
use({ "JoosepAlviste/nvim-ts-context-commentstring", commit = "a0f89563ba36b3bacd62cf967b46beb4c2c29e52" })
use({ "kyazdani42/nvim-web-devicons", commit = "6c38926351372ea87034dec26182b62c835ff3bc" })
use({ "akinsho/bufferline.nvim", tag = "v3.*" })
use({ "moll/vim-bbye", commit = "25ef93ac5a87526111f43e5110675032dbcacf56" })
use({ "nvim-lualine/lualine.nvim", commit = "0050b308552e45f7128f399886c86afefc3eb988" })
use({ "lewis6991/impatient.nvim", commit = "c90e273f7b8c50a02f956c24ce4804a47f18162e" })
use({ "lukas-reineke/indent-blankline.nvim", tag = "v2.*" })
use({ "nvim-zh/auto-save.nvim", commit = "4b59610e1318f8a89501cee9d47a0e8650f0a4d5" })
use({ "gelguy/wilder.nvim", commit = "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" })
use({ "romgrk/fzy-lua-native", commit = "085c7d262aa35cc55a8523e8c1618d398bf717a7", run = "make" })
use({ "mg979/vim-visual-multi", tag = "v0.*" })
use({ "gnikdroy/projections.nvim", commit = "6820ad90343b5ec78f236bbe0e13d9c8078a0c48" })
use({ "nvim-treesitter/nvim-treesitter", commit = "622baacdc1b22cdfd73bc98c07bb5654a090bcac" })
use({ "ray-x/sad.nvim", commit = "e8ab74c7a506f96a823527bfa78a66681483120b" })
use({
{ "nvim-lua/plenary.nvim" },
{ "windwp/nvim-autopairs" },
{ "numToStr/Comment.nvim", version = "v0.*" },
{ "JoosepAlviste/nvim-ts-context-commentstring" },
{ "kyazdani42/nvim-web-devicons" },
{ "akinsho/bufferline.nvim", version = "v3.*" },
{ "moll/vim-bbye" },
{ "nvim-lualine/lualine.nvim" },
{ "lewis6991/impatient.nvim" },
{ "lukas-reineke/indent-blankline.nvim", version = "v2.*" },
{ "nvim-zh/auto-save.nvim" },
{ "gelguy/wilder.nvim" },
{ "romgrk/fzy-lua-native" },
{ "mg979/vim-visual-multi", version = "v0.*" },
{ "gnikdroy/projections.nvim" },
{ "nvim-treesitter/nvim-treesitter" },
{ "ray-x/sad.nvim" },
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
requires = { "MunifTanjim/nui.nvim", commit = "b99e6cb13dc51768abc1c4c8585045a0c0459ef1" },
})
use({ "taybart/b64.nvim", commit = "12dde6ebc3035f010833f513cfbd9abad92b28b3" })
-- Colorschemes
use({ "folke/tokyonight.nvim", commit = "4071f7fa984859c5de7a1fd27069b99c3a0d802a" })
dependencies = { "MunifTanjim/nui.nvim" },
},
{ "taybart/b64.nvim" },
-- cmp plugins
use({ "hrsh7th/nvim-cmp", commit = "11a95792a5be0f5a40bab5fc5b670e5b1399a939" })
use({ "hrsh7th/cmp-buffer", commit = "3022dbc9166796b644a841a02de8dd1cc1d311fa" })
use({ "hrsh7th/cmp-path", commit = "91ff86cd9c29299a64f968ebb45846c485725f23" })
use({ "saadparwaiz1/cmp_luasnip", commit = "18095520391186d634a0045dacaa346291096566" })
use({ "hrsh7th/cmp-nvim-lsp", commit = "59224771f91b86d1de12570b4070fe4ad7cd1eeb" })
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
-- Snippets
use({ "L3MON4D3/LuaSnip", tag = "v1.*" })
use({ "rafamadriz/friendly-snippets", commit = "320865dfe76c03a5c60513d4f34ca22effae56f2" })
{ "L3MON4D3/LuaSnip", version = "v1.*" },
{ "rafamadriz/friendly-snippets" },
-- LSP
use({ "neovim/nvim-lspconfig", commit = "a59ba78f164f586d47a2f315dc3d021a630768d0" })
use({ "williamboman/mason.nvim", commit = "d825d3d1612c31caaff60901e0a6600cab8624d3" })
use({ "williamboman/mason-lspconfig.nvim", commit = "610f5919fe633ac872239a0ab786572059f0d91d" })
use({ "jose-elias-alvarez/null-ls.nvim", commit = "7bd74a821d991057ca1c0ca569d8252c4f89f860" })
use({ "RRethy/vim-illuminate", commit = "da80f3877896adcf77f59fb0bf74e9601615d372" })
use({ "folke/trouble.nvim", commit = "83ec606e7065adf134d17f4af6bae510e3c491c1" })
use({ "glepnir/lspsaga.nvim", commit = "f4d12606719b1256445922b864fe09974e2f8cee" })
use({ "arkav/lualine-lsp-progress", commit = "56842d097245a08d77912edf5f2a69ba29f275d7" })
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" },
{ "jose-elias-alvarez/null-ls.nvim" },
{ "RRethy/vim-illuminate" },
{ "folke/trouble.nvim" },
{ "glepnir/lspsaga.nvim" },
{ "arkav/lualine-lsp-progress" },
-- Telescope
use({ "nvim-telescope/telescope.nvim", commit = "2f32775405f6706348b71d0bb8a15a22852a61e4" })
use({ "nvim-telescope/telescope-ui-select.nvim", commit = "62ea5e58c7bbe191297b983a9e7e89420f581369" })
use({
{ "nvim-telescope/telescope.nvim" },
{ "nvim-telescope/telescope-ui-select.nvim" },
{
"nvim-telescope/telescope-fzf-native.nvim",
commit = "fab3e2212e206f4f8b3bbaa656e129443c9b802e",
run = "make",
})
build = "make",
},
-- Git
use({ "lewis6991/gitsigns.nvim", tag = "v0.*" })
use({ "sindrets/diffview.nvim", commit = "5bbcf162d03287296fe393f88da6065db3cf9fd0" })
use({ "f-person/git-blame.nvim", commit = "5ddf157139ecfc0d2161f00c2cce4874578dc355" })
{ "lewis6991/gitsigns.nvim", version = "v0.*" },
{ "sindrets/diffview.nvim" },
{ "f-person/git-blame.nvim" },
-- DAP
use({ "mfussenegger/nvim-dap", tag = "0.*" })
use({ "rcarriga/nvim-dap-ui", tag = "v2.*" })
use({ "ravenxrz/DAPInstall.nvim", commit = "8798b4c36d33723e7bba6ed6e2c202f84bb300de" })
use({ "theHamsta/nvim-dap-virtual-text", commit = "191345947a92a5188d791e9786a5b4f205dcaca3" })
{ "mfussenegger/nvim-dap", version = "0.*" },
{ "rcarriga/nvim-dap-ui", version = "v2.*" },
{ "ravenxrz/DAPInstall.nvim" },
{ "theHamsta/nvim-dap-virtual-text" },
-- Go
use({ "ray-x/go.nvim", commit = "4030487864e90255bfbab12fa2f9b5ca13b5bef4" })
use({
{ "ray-x/go.nvim" },
{
"ray-x/guihua.lua",
commit = "a55e30a8d5a44683eaeffbf3d06c39699a173954",
run = "cd lua/fzy && make",
build = "cd lua/fzy && make",
config = function()
require("guihua.maps").setup({
maps = { close_view = "<C-x>" },
})
end,
})
},
-- Markdown
use({ "mzlogin/vim-markdown-toc", commit = "7ec05df27b4922830ace2246de36ac7e53bea1db" })
use({
{ "mzlogin/vim-markdown-toc" },
{
"iamcco/markdown-preview.nvim",
run = "cd app && npm install",
setup = function()
build = "cd app && npm install",
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
})
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)
},
})

View File

@ -12,7 +12,8 @@ indent_blankline.setup({
buftype_exclude = { "terminal", "nofile" },
filetype_exclude = {
"help",
"packer",
"lazy",
"mason",
"neo-tree",
},
})