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

52 lines
1.4 KiB
Lua
Raw Normal View History

2022-08-12 14:09:45 +02:00
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})
2022-08-08 01:41:01 +02:00
vim.cmd [[packadd packer.nvim]]
end
2022-08-08 13:57:38 +02:00
packer = require('packer')
packer.init()
2022-08-08 01:41:01 +02:00
2022-08-08 20:27:58 +02:00
packer.use 'https://github.com/wbthomason/packer.nvim'
2022-08-08 13:57:38 +02:00
2022-08-12 00:06:42 +02:00
-- source file, install and compile plugins when config file is written
2022-08-10 17:34:00 +02:00
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
2022-08-12 14:05:53 +02:00
if not vim.api.nvim_buf_get_name(0):match('plugins.lua$') then
2022-08-10 17:52:25 +02:00
vim.cmd([[
source <afile>
2022-08-12 00:06:42 +02:00
PackerInstall
2022-08-10 17:52:25 +02:00
]])
2022-08-10 17:34:00 +02:00
end
end
}
)
2022-08-12 00:06:42 +02:00
vim.api.nvim_create_autocmd(
{ 'User' },
{
group = 'packer_user_config',
pattern = 'PackerComplete',
command = [[PackerCompile]]
2022-08-12 00:06:42 +02:00
}
)
vim.api.nvim_create_autocmd(
{ 'User' },
{
group = 'packer_user_config',
pattern = 'PackerCompileDone',
command = [[echo 'plugins compiled']]
2022-08-12 00:06:42 +02:00
}
)