refactor(nvim): use Lazy package manager instead of packer

This commit is contained in:
Price Hiller 2022-12-20 22:30:10 -06:00
parent e6d158f54e
commit 485c8024f6
5 changed files with 795 additions and 831 deletions

View File

@ -1,5 +1 @@
local loaded, impatient = pcall(require, 'impatient')
if loaded then
impatient.enable_profile()
end
require('main')

View File

@ -29,20 +29,18 @@ local header = {
}
-- Subheader, plugin count
local get_plugins = function()
local num_plugins_loaded = #vim.fn.globpath(vim.fn.stdpath('data') .. '/site/pack/packer/start', '*', 0, 1)
local num_plugins_total = #vim.tbl_keys(packer_plugins)
if num_plugins_total <= 1 then
return num_plugins_loaded .. ' / ' .. num_plugins_total .. ' plugin  loaded'
local get_plugin_info = function()
if require("lazy.status").has_updates() then
return "Plugin updates available, check :Lazy"
else
return num_plugins_loaded .. ' / ' .. num_plugins_total .. ' plugins  loaded'
return "All plugins up to date"
end
end
local plugin_count = {
local plugin_info = {
type = 'text',
val = {
get_plugins(),
get_plugin_info()
},
opts = {
hl = 'Comment',
@ -87,7 +85,7 @@ local buttons = {
button('f', ' Find File', ':Telescope find_files<CR>'),
button('r', ' Recent', ':Telescope oldfiles<CR>'),
button('s', ' Settings', ':e ~/.config/nvim/<CR>'),
button('u', ' Update Plugins', ':PackerSync<CR>'),
button('u', ' Update Plugins', ':Lazy sync<CR>'),
button('q', ' Quit', ':qa<CR>'),
},
opts = {
@ -113,7 +111,7 @@ local opts = {
padding(),
header,
padding(),
plugin_count,
plugin_info,
padding(),
buttons,
padding(),

View File

@ -130,7 +130,12 @@ lualine.setup({
},
-- Right
lualine_x = {},
lualine_x = {
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
},
},
lualine_y = {
{
"buffers",

View File

@ -183,34 +183,6 @@ vim.keymap.set(
{ silent = true, desc = "Gitsigns: Unstage Hunk" }
)
-- Packer Mappings
local packer = require("packer")
local packer_sync = function()
vim.notify("Syncing packer.", "info", {
title = "Packer",
})
local snap_shot_time = tostring(os.date("!%Y-%m-%dT%TZ"))
packer.snapshot(snap_shot_time)
packer.sync()
end
local packer_compile = function()
vim.notify("Compiling packer.", "info", {
title = "Packer",
})
packer.compile()
end
vim.keymap.set("n", "<leader>ps", packer_sync, {
silent = true,
desc = "Packer: Sync",
})
vim.keymap.set("n", "<leader>pc", packer_compile, {
silent = true,
desc = "Packer: Compile",
})
-- Hop Mappings
local hop = require("hop")

View File

@ -1,61 +1,49 @@
local fn = vim.fn
local utils = require("utils.funcs")
-- Packer strap, install packer automatically and configure plugins
-- See the end of this file for how the variable `packer_strap` gets used
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
PACKER_STRAP = fn.system({
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.notify("Installing Lazy plugin manager, please wait...")
vim.fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
-- Update the runtime so packer can be used
vim.o.runtimepath = vim.fn.stdpath("data") .. "/site/pack/*/start/*," .. vim.o.runtimepath
end
vim.opt.runtimepath:prepend(lazypath)
local packer = require("packer")
packer.init({
max_jobs = 20,
})
return packer.startup({
function(use)
-- Performance boost on startup
-- keep at top of plugins
use({ "lewis6991/impatient.nvim" })
local lazy = require("lazy")
lazy.setup({
-- Packer Itself
use({ "wbthomason/packer.nvim" })
{ "wbthomason/packer.nvim" },
-- Commonly used library
use({
{
"nvim-lua/plenary.nvim",
})
},
-- Much nicer ui, integrates cmdheight = 0 wella
use({
{
"folke/noice.nvim",
config = function()
-- NOTE: Might be redundant, to check later
require("plugins.configs.nvim-notify")
require("plugins.configs.noice")
end,
requires = {
dependencies = {
-- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
"hrsh7th/nvim-cmp",
},
})
},
-- Color schemes
use({ "folke/tokyonight.nvim" })
use({
{ "folke/tokyonight.nvim" },
{
"EdenEast/nightfox.nvim",
config = function()
require("nightfox").setup({
@ -65,42 +53,42 @@ return packer.startup({
},
})
end,
})
use({
},
{
"rebelot/kanagawa.nvim",
config = function()
require("plugins.configs.kanagawa")
end,
})
},
-- Icons for folders, files, etc.
use({
{
"kyazdani42/nvim-web-devicons",
event = "BufEnter",
})
},
-- Statusline.
use({
{
"nvim-lualine/lualine.nvim",
config = function()
require("plugins.configs.statusline")
end,
})
},
-- Indentation Guides
use({
{
"lukas-reineke/indent-blankline.nvim",
event = "BufEnter",
config = function()
require("plugins.configs.indent-blankline")
end,
})
},
-- Treesitter
use({
{
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
requires = {
build = ":TSUpdate",
dependencies = {
"p00f/nvim-ts-rainbow",
"nvim-treesitter/nvim-treesitter-context",
},
@ -108,9 +96,9 @@ return packer.startup({
require("plugins.configs.treesitter")
end,
before = "folke/noice.nvim",
})
},
use({
{
"nvim-treesitter/nvim-treesitter-textobjects",
after = { "nvim-treesitter" },
config = function()
@ -167,10 +155,10 @@ return packer.startup({
},
})
end,
})
},
-- Highlight given color codes
use({
{
"brenoprata10/nvim-highlight-colors",
event = "BufEnter",
config = function()
@ -179,43 +167,43 @@ return packer.startup({
render = "background",
})
end,
})
},
-- Dashboard when no file is given to nvim
use({
{
"goolord/alpha-nvim",
requires = { "kyazdani42/nvim-web-devicons" },
dependencies = { "kyazdani42/nvim-web-devicons" },
config = function()
require("plugins.configs.alpha")
end,
})
},
-- Telescope
use({
{
"nvim-telescope/telescope.nvim",
requires = {
dependencies = {
"nvim-telescope/telescope-media-files.nvim",
"nvim-telescope/telescope-file-browser.nvim",
"artart222/telescope_find_directories",
"nvim-telescope/telescope-ui-select.nvim",
{ "nvim-telescope/telescope-smart-history.nvim", requires = "tami5/sqlite.lua" },
{ "nvim-telescope/telescope-fzf-native.nvim", run = "make" },
{ "nvim-telescope/telescope-smart-history.nvim", dependencies = "tami5/sqlite.lua" },
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
},
config = function()
require("plugins.configs.telescope-nvim")
end,
})
},
use({
{
"stevearc/dressing.nvim",
})
},
-- File Tree
use({
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v2.x",
requires = {
dependencies = {
"kyazdani42/nvim-web-devicons",
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
@ -224,12 +212,12 @@ return packer.startup({
require("plugins.configs.neotree")
end,
cmd = "Neotree",
})
},
-- Lspconfig
use({
{
"neovim/nvim-lspconfig",
requires = {
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"folke/neodev.nvim",
"Decodetalkers/csharpls-extended-lsp.nvim",
@ -241,62 +229,63 @@ return packer.startup({
"b0o/schemastore.nvim",
},
after = "noice.nvim",
event = "BufEnter",
config = function()
require("mason").setup({})
require("plugins.configs.lsp")
end,
})
},
-- Incremental rename, easier to view renames
use({
"https://github.com/smjonas/inc-rename.nvim.git",
{
"smjonas/inc-rename.nvim",
config = function()
require("inc_rename").setup({})
end,
})
},
-- Better LSP Virtual Text Lines
use({
"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
{
url = "https://git.sr.ht/~whynothugo/lsp_lines.nvim",
config = function()
require("lsp_lines").setup()
end,
})
},
-- Lsp From Null LS
use({
{
"jose-elias-alvarez/null-ls.nvim",
config = function()
require("plugins.configs.null_ls")
end,
})
},
-- Autopairs
use({
{
"windwp/nvim-autopairs",
config = function()
require("nvim-autopairs").setup()
end,
})
},
-- Snippets
use({
{
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
requires = {
dependencies = {
"L3MON4D3/LuaSnip",
"https://github.com/saadparwaiz1/cmp_luasnip",
"saadparwaiz1/cmp_luasnip",
},
after = "LuaSnip",
event = "BufEnter",
})
},
-- Code completion
use({
{
"hrsh7th/nvim-cmp",
requires = {
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
@ -314,80 +303,80 @@ return packer.startup({
config = function()
require("plugins.configs._cmp")
end,
})
},
use({
{
"tzachar/cmp-fuzzy-buffer",
requires = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" },
})
use({ "tzachar/cmp-fuzzy-path", requires = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" } })
use({
dependencies = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" },
},
{ "tzachar/cmp-fuzzy-path", dependencies = { "hrsh7th/nvim-cmp", "tzachar/fuzzy.nvim" } },
{
"saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
requires = { { "nvim-lua/plenary.nvim" } },
dependencies = { { "nvim-lua/plenary.nvim" } },
config = function()
require("crates").setup()
end,
})
},
-- DAP, debugger
use({
{
"mfussenegger/nvim-dap",
config = function()
require("dap.ext.vscode").load_launchjs()
require("plugins.configs._dap")
end,
after = "nvim-notify",
})
},
-- Python debugger, dapinstall does not play nice with debugpy
use({
{
"mfussenegger/nvim-dap-python",
after = "nvim-dap",
config = function()
require("plugins.configs.python-dap")
end,
})
},
-- Virtual Text for DAP
use({
{
"theHamsta/nvim-dap-virtual-text",
after = "nvim-dap",
config = function()
require("nvim-dap-virtual-text").setup({})
end,
})
},
-- Fancy ui for dap
use({
{
"rcarriga/nvim-dap-ui",
after = "nvim-dap",
config = function()
require("plugins.configs.dap-ui")
end,
})
},
-- Code formatting
use({
{
"sbdchd/neoformat",
cmd = "Neoformat",
config = function()
require("plugins.configs.neoformat")
end,
})
},
use({
{
"anuvyklack/pretty-fold.nvim",
requires = "anuvyklack/nvim-keymap-amend",
dependencies = "anuvyklack/nvim-keymap-amend",
config = function()
require("pretty-fold").setup({
fill_char = " ",
})
end,
})
},
-- Git signs
use({
{
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup({
@ -397,52 +386,51 @@ return packer.startup({
},
})
end,
})
},
-- Highlight certain comments, TODO, BUG, etc.
use({
{
"folke/todo-comments.nvim",
event = "BufEnter",
config = function()
require("todo-comments").setup({})
end,
})
},
-- Show possible key bindings during typing
use({
{
"folke/which-key.nvim",
config = function()
require("which-key").setup({})
end,
})
},
-- Create full path if not existing on write
use({
{
"jghauser/mkdir.nvim",
cmd = "new",
config = function()
require("mkdir")
end,
})
},
-- Text commenting
use({
{
"terrortylor/nvim-comment",
cmd = "CommentToggle",
config = function()
require("nvim_comment").setup()
end,
})
},
-- Move selections with alt+movement key
use({
{
"matze/vim-move",
})
},
-- Register support in telescope with persistent save
use({
{
"AckslD/nvim-neoclip.lua",
requires = {
dependencies = {
{ "tami5/sqlite.lua", module = "sqlite" },
{ "nvim-telescope/telescope.nvim" },
},
@ -451,21 +439,21 @@ return packer.startup({
enable_persistent_history = true,
})
end,
})
},
-- Markdown Previewer
use({
{
"iamcco/markdown-preview.nvim",
run = "cd app && npm install",
setup = function()
build = "cd app && npm install",
init = function()
vim.g.mkdp_filetypes = { "markdown" }
vim.g.mkdp_browser = "firefox-developer-edition"
end,
ft = { "markdown" },
})
},
-- Better Git integration
use({
{
"TimUntersberger/neogit",
config = function()
require("neogit").setup({
@ -476,68 +464,68 @@ return packer.startup({
})
end,
event = "BufWinEnter",
requires = {
dependencies = {
"sindrets/diffview.nvim",
},
})
},
-- Ansible Syntax Highlighting
use({
{
"pearofducks/ansible-vim",
})
},
-- Better search display
use({
{
"kevinhwang91/nvim-hlslens",
module = "hlslens",
keys = "/",
config = function()
require("hlslens").setup()
end,
})
},
-- Note Taking
use({
{
"nvim-neorg/neorg",
config = function()
require("plugins.configs._neorg")
end,
requires = {
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-neorg/neorg-telescope",
},
after = "nvim-treesitter",
ft = "norg",
})
},
-- Log Syntax Highlighting
use({
{
"MTDL9/vim-log-highlighting",
})
},
-- Lots of small modules pulled into
-- one git repository
use({
{
"echasnovski/mini.nvim",
config = function()
require("mini.cursorword").setup({})
end,
})
},
-- Smoother Scrolling
use({
{
"karb94/neoscroll.nvim",
config = function()
require("neoscroll").setup({
easing_function = "circular",
})
end,
})
},
-- Generate function/class/etc annotations
use({
{
"danymat/neogen",
requires = "nvim-treesitter/nvim-treesitter",
dependencies = "nvim-treesitter/nvim-treesitter",
config = function()
require("neogen").setup({
snippet_engine = "luasnip",
@ -550,20 +538,20 @@ return packer.startup({
},
})
end,
})
},
-- Multiple cursor/multiple visual selection support
use({
{
"mg979/vim-visual-multi",
})
},
-- Editorconfig support
use({
{
"gpanders/editorconfig.nvim",
})
},
-- Maintain last cursor position in files
use({
{
"ethanholz/nvim-lastplace",
config = function()
require("nvim-lastplace").setup({
@ -572,25 +560,25 @@ return packer.startup({
lastplace_open_folds = true,
})
end,
})
},
-- Diagnose startup time
use({ "dstein64/vim-startuptime" })
{ "dstein64/vim-startuptime" },
-- More codeactions
use({
{
"ThePrimeagen/refactoring.nvim",
requires = {
dependencies = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-treesitter/nvim-treesitter" },
},
})
},
-- Http Request Support
use({
{
"NTBBloodbath/rest.nvim",
requires = {
"https://github.com/nvim-lua/plenary.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
local rest_nvim = require("rest-nvim")
@ -599,12 +587,12 @@ return packer.startup({
skip_ssl_verification = true,
})
end,
})
},
-- Allows repeating actions and more
use({
{
"anuvyklack/hydra.nvim",
requires = {
dependencies = {
"anuvyklack/keymap-layer.nvim",
"lewis6991/gitsigns.nvim",
"jbyuki/venn.nvim",
@ -613,27 +601,27 @@ return packer.startup({
config = function()
require("plugins.configs.hydra")
end,
})
},
-- Faster motions
use({
{
"phaazon/hop.nvim",
config = function()
-- you can configure Hop the way you like here; see :h hop-config
require("hop").setup({ keys = "etovxqpdygfblzhckisuran" })
end,
})
},
-- Surround actions
use({
{
"kylechui/nvim-surround",
config = function()
require("nvim-surround").setup({})
end,
})
},
-- Better list continuation
use({
{
"gaoDean/autolist.nvim",
ft = {
"markdown",
@ -644,10 +632,10 @@ return packer.startup({
config = function()
require("autolist").setup({})
end,
})
},
-- Tint inactive windows
use({
{
"levouh/tint.nvim",
config = function()
require("tint").setup({
@ -656,28 +644,28 @@ return packer.startup({
saturation = 0.8,
})
end,
})
},
-- Highlight argument definitions and usages
use({
{
"m-demare/hlargs.nvim",
requires = { "nvim-treesitter/nvim-treesitter" },
dependencies = { "nvim-treesitter/nvim-treesitter" },
config = function()
require("hlargs").setup({})
end,
})
},
-- Vim Latex Support
use({
{
"lervag/vimtex",
ft = "tex",
config = function()
vim.g.vimtext_view_method = "zathura"
vim.g.vimtex_view_general_viewer = "zathura"
end,
})
},
use({
{
"akinsho/toggleterm.nvim",
config = function()
require("toggleterm").setup({
@ -700,19 +688,19 @@ return packer.startup({
"ToggleTermSendVisualLines",
"ToggleTermSendVisualSelection",
},
})
},
-- Take a screenshot of code selected
use({
{
"NarutoXY/silicon.lua",
requires = { "nvim-lua/plenary.nvim" },
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("silicon").setup({})
end,
})
},
-- Nice sidebar cursor goodies
use({
{
"gen740/SmoothCursor.nvim",
after = "kanagawa.nvim",
config = function()
@ -733,10 +721,10 @@ return packer.startup({
disabled_filetypes = { "NeogitNotification" },
})
end,
})
},
-- Color Picker
use({
{
"uga-rosa/ccc.nvim",
config = function()
require("plugins.configs.ccc")
@ -748,52 +736,57 @@ return packer.startup({
"CccHighlighterToggle",
"CccHighlighterDisable",
},
})
},
-- Task runner & job management
use({
{
"stevearc/overseer.nvim",
config = function()
require("overseer").setup()
end,
})
},
-- Better buffer deletion
use({
{
"famiu/bufdelete.nvim",
})
},
-- Leave at end!!!
-- Install and deploy packer plugins
-- automatically
if PACKER_STRAP then
vim.notify("Syncing packer from bootstrap")
function _G.NotifyRestartNeeded()
local notify_available, _ = require("notify")
local message = "Neovim Restart Required to Finish Installation!"
if notify_available then
vim.notify(message, vim.lsp.log_levels.WARN, {
title = "Packer Strap",
keep = function()
return true
end,
})
else
vim.notify(message)
end
end
vim.api.nvim_exec(
[[
autocmd User PackerCompileDone lua NotifyRestartNeeded()
]],
false
)
require("packer").sync()
end
end,
config = {
compile_path = vim.fn.stdpath("config") .. "/lua/packer_compiled.lua",
},
-- if PACKER_STRAP then
-- vim.notify("Syncing packer from bootstrap")
--
-- function _G.NotifyRestartNeeded()
-- local notify_available, _ = require("notify")
-- local message = "Neovim Restart Required to Finish Installation!"
-- if notify_available then
-- vim.notify(message, vim.lsp.log_levels.WARN, {
-- title = "Packer Strap",
-- keep = function()
-- return true
-- end,
-- },
-- else
-- vim.notify(message)
-- end
-- end
--
-- vim.api.nvim_exec(
-- [[
-- autocmd User PackerCompileDone lua NotifyRestartNeeded()
-- ]],
-- false
-- )
-- require("packer").sync()
-- end
-- end,
-- config = {
-- compile_path = vim.fn.stdpath("config") .. "/lua/packer_compiled.lua",
-- },
}, {
checker = {
enabled = true,
concurrency = 20
}
})