dotfiles/.config/nvim/lua/my/plugins.lua
2022-08-12 14:14:12 +02:00

52 lines
1.4 KiB
Lua

local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
packer_bootstrap = vim.fn.system({
'git',
'clone',
'--depth',
'1',
'https://github.com/wbthomason/packer.nvim',
install_path})
vim.cmd [[packadd packer.nvim]]
end
packer = require('packer')
packer.init()
packer.use 'https://github.com/wbthomason/packer.nvim'
-- source file, install and compile plugins when config file is written
vim.api.nvim_create_augroup('packer_user_config', { clear = true })
vim.api.nvim_create_autocmd(
{ 'BufWritePost' },
{
group = 'packer_user_config',
pattern = { '*/nvim/lua/*.lua', '*/nvim/init.lua' },
callback = function()
-- exclude plugins.lua, because that would re-init packer
if not vim.api.nvim_buf_get_name(0):match('plugins.lua$') then
vim.cmd([[
source <afile>
PackerInstall
]])
end
end
}
)
vim.api.nvim_create_autocmd(
{ 'User' },
{
group = 'packer_user_config',
pattern = 'PackerComplete',
command = [[PackerCompile]]
}
)
vim.api.nvim_create_autocmd(
{ 'User' },
{
group = 'packer_user_config',
pattern = 'PackerCompileDone',
command = [[echo 'plugins compiled']]
}
)