vim.api.nvim_create_autocmd(
“BufWritePost”,
{
pattern = “*.py”,
group = “AutoFormat”,
callback = function()
vim.cmd(“silent !black –quiet %”)
vim.cmd(“edit”)
end,
}
)
This is the autocmd to format on save for python files but i am not able to get it working for .js, .ts, .jsx, .tsx
vim.api.nvim_create_autocmd(
“BufWritePost”,
{
pattern = “*.js”,
group = ‘AutoFormat’,
callback = function()
vim.lsp.buf.format({ async = false })
end
}
)
i have tried this and i dont know how to add prettier so i have just used the vim autocmd
Sai Nikhil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.