dotfiles/.config/nvim/lua/plugins.lua
2022-08-11 01:06:59 +02:00

42 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 new plugins and compile when config file is written
vim.api.nvim_create_augroup('packer_user_config', { clear = true })
-- vim.api.nvim_create_autocmd(
-- { 'User' },
-- {
-- group = 'packer_user_config',
-- pattern = 'PackerComplete',
-- command = [[PackerCompile']]
-- }
-- )
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([[
echo 'reloading config file…'
source <afile>
PackerCompile
redraw
]])
end
end
}
)