dotfiles/.config/nvim/lua/my/plugins.lua

47 lines
1.3 KiB
Lua

local fn = vim.fn
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({'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']]
}
)