using BufWritePost for formatters
My latest config written in lua
.
local settings = require'waylonwalker.settings'
M.waylonwalker_augroup = augroup('waylonwalker', { clear = true })
M.format_python = function()
if settings.auto_format.python then
vim.cmd('silent execute "%!tidy-imports --black --quiet --replace-star-imports --replace --add-missing --remove-unused " . bufname("%")')
vim.cmd('silent execute "%!isort " . bufname("%")')
vim.cmd('silent execute "%!black " . bufname("%")')
end
end
autocmd({ "BufWritePost" }, {
group=M.waylonwalker_augroup,
pattern = { "*.py" },
callback = M.format_python,
})