init.lua 368 B

123456789101112131415161718
  1. -- autoformat
  2. if O.format_on_save then
  3. require("lv-utils").define_augroups({
  4. autoformat = {
  5. {
  6. "BufWritePre",
  7. "*",
  8. [[try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry]],
  9. },
  10. },
  11. })
  12. end
  13. if not O.format_on_save then
  14. vim.cmd([[if exists('#autoformat#BufWritePre')
  15. :autocmd! autoformat
  16. endif]])
  17. end