perf: replace Packer.nvim with Lazy.nvim

This commit is contained in:
zirbest 2023-01-02 16:38:05 +01:00
parent 4916072854
commit 25e6536c33
1 changed files with 44 additions and 76 deletions

116
init.lua
View File

@ -1,95 +1,69 @@
-- Install packer -- Set <space> as the leader key
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim' -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
local is_bootstrap = false vim.g.mapleader = ' '
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then vim.g.maplocalleader = ' '
is_bootstrap = true
vim.fn.system { 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path } -- Install Lazy.nvim
vim.cmd [[packadd packer.nvim]] local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git', 'clone',
'--filter=blob:none', '--single-branch',
'https://github.com/folke/lazy.nvim.git',
lazypath,
})
end end
vim.opt.runtimepath:prepend(lazypath)
require('packer').startup(function(use) require('lazy').setup({
-- Package manager { -- LSP Configuration & Plugins
use 'wbthomason/packer.nvim'
use { -- LSP Configuration & Plugins
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
requires = { event = "BufReadPre",
dependencies = {
-- Automatically install LSPs to stdpath for neovim -- Automatically install LSPs to stdpath for neovim
'williamboman/mason.nvim', { 'williamboman/mason.nvim', config = true },
'williamboman/mason-lspconfig.nvim', 'williamboman/mason-lspconfig.nvim',
-- Useful status updates for LSP -- Useful status updates for LSP
'j-hui/fidget.nvim', { 'j-hui/fidget.nvim', config = true },
-- Additional lua configuration, makes nvim stuff amazing -- Additional lua configuration, makes nvim stuff amazing
'folke/neodev.nvim', { 'folke/neodev.nvim', config = true }
},
}, },
}
use { -- Autocompletion { -- Autocompletion
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
requires = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' }, event = 'InsertEnter',
} dependencies = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' },
},
use { -- Highlight, edit, and navigate code { -- Highlight, edit, and navigate code
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
run = function() config = function()
pcall(require('nvim-treesitter.install').update { with_sync = true }) pcall(require('nvim-treesitter.install').update { with_sync = true })
end, end,
} },
use { -- Additional text objects via treesitter -- Additional text objects via treesitter
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter',
}
-- Git related plugins -- Git related plugins
use 'tpope/vim-fugitive' { 'tpope/vim-fugitive', cmd = { "G", "Git" } },
use 'tpope/vim-rhubarb' 'tpope/vim-rhubarb',
use 'lewis6991/gitsigns.nvim' { 'lewis6991/gitsigns.nvim', event = "BufReadPre" } ,
use 'navarasu/onedark.nvim' -- Theme inspired by Atom 'navarasu/onedark.nvim', -- Theme inspired by Atom
use 'nvim-lualine/lualine.nvim' -- Fancier statusline { 'nvim-lualine/lualine.nvim', event = "VeryLazy" }, -- Fancier statusline
use 'lukas-reineke/indent-blankline.nvim' -- Add indentation guides even on blank lines 'lukas-reineke/indent-blankline.nvim', -- Add indentation guides even on blank lines
use 'numToStr/Comment.nvim' -- "gc" to comment visual regions/lines { 'numToStr/Comment.nvim', config = true },
use 'tpope/vim-sleuth' -- Detect tabstop and shiftwidth automatically 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
-- Fuzzy Finder (files, lsp, etc) -- Fuzzy Finder (files, lsp, etc)
use { 'nvim-telescope/telescope.nvim', branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } } { 'nvim-telescope/telescope.nvim', branch = '0.1.x', cmd = "Telescope",
dependencies = { 'nvim-lua/plenary.nvim',
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available -- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available
use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make', cond = vim.fn.executable 'make' == 1 } { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', cond = vim.fn.executable 'make' == 1 } } },
-- Add custom plugins to packer from ~/.config/nvim/lua/custom/plugins.lua
local has_plugins, plugins = pcall(require, 'custom.plugins')
if has_plugins then
plugins(use)
end
if is_bootstrap then
require('packer').sync()
end
end)
-- When we are bootstrapping a configuration, it doesn't
-- make sense to execute the rest of the init.lua.
--
-- You'll need to restart nvim, and then it will work.
if is_bootstrap then
print '=================================='
print ' Plugins are being installed'
print ' Wait until Packer completes,'
print ' then restart nvim'
print '=================================='
return
end
-- Automatically source and re-compile packer whenever you save this init.lua
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
vim.api.nvim_create_autocmd('BufWritePost', {
command = 'source <afile> | silent! LspStop | silent! LspStart | PackerCompile',
group = packer_group,
pattern = vim.fn.expand '$MYVIMRC',
}) })
-- [[ Setting options ]] -- [[ Setting options ]]
@ -126,12 +100,6 @@ vim.cmd [[colorscheme onedark]]
vim.o.completeopt = 'menuone,noselect' vim.o.completeopt = 'menuone,noselect'
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Keymaps for better default experience -- Keymaps for better default experience
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })