init.lua 556 B

1234567891011121314151617181920212223
  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. vim.g.neoformat_run_all_formatters = 0
  14. vim.g.neoformat_enabled_python = { "autopep8", "yapf", "docformatter" }
  15. vim.g.neoformat_enabled_javascript = { "prettier" }
  16. if not O.format_on_save then
  17. vim.cmd [[if exists('#autoformat#BufWritePre')
  18. :autocmd! autoformat
  19. endif]]
  20. end