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:
parent
6c20ac04b1
commit
c0443dad35
2 changed files with 16 additions and 12 deletions
|
@ -54,9 +54,12 @@ local formatters = {
|
||||||
|
|
||||||
require('formatter').setup({logging = false, filetype = formatters})
|
require('formatter').setup({logging = false, filetype = formatters})
|
||||||
|
|
||||||
|
-- Format on save:
|
||||||
-- gather filetypes to autocorrect for each activated formatter above
|
-- gather filetypes to autocorrect for each activated formatter above
|
||||||
local filetype = ""
|
for k, _ in pairs(formatters) do
|
||||||
for k, _ in pairs(formatters) do filetype = filetype .. "," .. k end
|
vim.api.nvim_create_autocmd({"Filetype " .. k}, {
|
||||||
augroup({
|
command = "autocmd BufWritePost <buffer> FormatWrite",
|
||||||
{'FileType', filetype, 'autocmd', 'BufWritePost', '<buffer>', 'FormatWrite'}
|
desc = "Automatically format on write",
|
||||||
}, 'formatonsave')
|
group = vim.api.nvim_create_augroup('formatonsave', {clear = true})
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
@ -5,12 +5,13 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
||||||
install_path)
|
install_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_exec([[
|
-- Compile on plugin edits
|
||||||
augroup Packer
|
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
autocmd!
|
pattern = "plugins.lua",
|
||||||
autocmd BufWritePost plugins.lua PackerCompile
|
command = "PackerCompile",
|
||||||
augroup END
|
desc = "Compile plugins after editing plugin list",
|
||||||
]], false)
|
group = vim.api.nvim_create_augroup('compilepackages', { clear = true })
|
||||||
|
})
|
||||||
|
|
||||||
local use = require("packer").use
|
local use = require("packer").use
|
||||||
require("packer").startup(function()
|
require("packer").startup(function()
|
||||||
|
|
Loading…
Reference in a new issue