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

45 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'
-- common dependencies which require setup
packer.use {
'https://github.com/nvim-treesitter/nvim-treesitter',
run = function()
require('nvim-treesitter.install').update({ with_sync = true })
end
}
-- 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([[source <afile> | PackerInstall]])
end
end
}
)