nvim: Change remaining augroups to lua autocmds

Changed formatting and plugin self-compilation to make use of the new
neovim 0.7 autcmd api function.
This commit is contained in:
Marty Oehme 2022-06-13 19:30:43 +02:00
parent 6c20ac04b1
commit c0443dad35
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 16 additions and 12 deletions

View file

@ -54,9 +54,12 @@ local formatters = {
require('formatter').setup({logging = false, filetype = formatters})
-- Format on save:
-- gather filetypes to autocorrect for each activated formatter above
local filetype = ""
for k, _ in pairs(formatters) do filetype = filetype .. "," .. k end
augroup({
{'FileType', filetype, 'autocmd', 'BufWritePost', '<buffer>', 'FormatWrite'}
}, 'formatonsave')
for k, _ in pairs(formatters) do
vim.api.nvim_create_autocmd({"Filetype " .. k}, {
command = "autocmd BufWritePost <buffer> FormatWrite",
desc = "Automatically format on write",
group = vim.api.nvim_create_augroup('formatonsave', {clear = true})
})
end

View file

@ -5,12 +5,13 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
install_path)
end
vim.api.nvim_exec([[
augroup Packer
autocmd!
autocmd BufWritePost plugins.lua PackerCompile
augroup END
]], false)
-- Compile on plugin edits
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
pattern = "plugins.lua",
command = "PackerCompile",
desc = "Compile plugins after editing plugin list",
group = vim.api.nvim_create_augroup('compilepackages', { clear = true })
})
local use = require("packer").use
require("packer").startup(function()