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})
|
||||
|
||||
-- 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
|
||||
|
|
|
@ -2,15 +2,16 @@ local install_path = vim.fn.stdpath("data") .. "/pack/packer/start/packer.nvim"
|
|||
|
||||
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
||||
vim.cmd("!git clone https://github.com/wbthomason/packer.nvim " ..
|
||||
install_path)
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue