I have auto-format on save enabled for some languages, for example go:
vim.api.nvim_create_autocmd('BufWritePost', {
group = 'Format',
pattern = '*.go',
callback = function()
vim.lsp.buf.format()
end
})
For everything else, we can use the = nvim motion for indenting a file!
Sources:
- [1] https://youtu.be/mEqqkHLhlGY?si=OFFVjkx5RM4TVN2B&t=31
- [2] `:h =`