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

48 lines
1.5 KiB
Lua
Raw Normal View History

2022-08-08 01:41:01 +02:00
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
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
if (not vim.api.nvim_buf_get_name(0):match('plugins.lua$')) then
2022-08-10 17:52:25 +02:00
vim.cmd([[
2022-08-12 00:06:42 +02:00
echom 'reloading config file and installing new plugins…'
2022-08-10 17:52:25 +02:00
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 = [[echom 'compiling plugins…' | PackerCompile]]
}
)
vim.api.nvim_create_autocmd(
{ 'User' },
{
group = 'packer_user_config',
pattern = 'PackerCompileDone',
command = [[echom 'plugins compiled.']]
}
)