conform.lua 679 B

12345678910111213141516171819202122232425262728293031
  1. local status_ok, conform = pcall(require, "conform")
  2. if not status_ok then
  3. return
  4. end
  5. conform.setup({
  6. formatters_by_ft = {
  7. javascript = { "prettier" },
  8. javascriptreact = { "prettier" },
  9. json = { "prettier" },
  10. jsonc = { "prettier" },
  11. markdown = { "prettier" },
  12. scss = { "prettier" },
  13. css = { "prettier" },
  14. typescript = { "prettier" },
  15. typescriptreact = { "prettier" },
  16. yaml = { "prettier" },
  17. },
  18. formatters = {
  19. prettier = {
  20. command = "/Users/leon/node_modules/.bin/prettier",
  21. },
  22. },
  23. })
  24. vim.api.nvim_create_user_command("Format", function()
  25. conform.format({
  26. async = true,
  27. lsp_fallback = true,
  28. })
  29. end, {})