1 -- Lightweight yet powerful formatter plugin for Neovim
 
   2 -- https://github.com/stevearc/conform.nvim
 
   3 vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
 
   6         event = { "BufWritePre" },
 
   7         cmd = { "ConformInfo" },
 
   9                 require("conform").setup({
 
  10                         -- Map of filetype to formatters
 
  13                                 -- Conform will run multiple formatters sequentially
 
  14                                 go = { "goimports", "gofmt" },
 
  15                                 haskell = { "fourmolu" },
 
  17                                 -- You can also customize some of the format options for the filetype
 
  18                                 rust = { "rustfmt", lsp_format = "fallback" },
 
  19                                 -- You can use a function here to determine the formatters dynamically
 
  20                                 python = function(bufnr)
 
  21                                         if require("conform").get_formatter_info("ruff_format", bufnr).available then
 
  22                                                 return { "ruff_format" }
 
  24                                                 return { "isort", "black" }
 
  28                                 -- Use the "*" filetype to run formatters on all filetypes.
 
  29                                 ["*"] = { "codespell" },
 
  30                                 -- Use the "_" filetype to run formatters on filetypes that don't
 
  31                                 -- have other formatters configured.
 
  32                                 ["_"] = { "trim_whitespace" },
 
  34                         -- Set this to change the default values when calling conform.format()
 
  35                         -- This will also affect the default values for format_on_save/format_after_save
 
  36                         default_format_opts = {
 
  37                                 lsp_format = "fallback",
 
  39                         -- If this is set, Conform will run the formatter on save.
 
  40                         -- It will pass the table to conform.format().
 
  41                         -- This can also be a function that returns the table.
 
  42                         format_after_save = function()
 
  43                                 if not vim.g.formatsave or vim.b.disableFormatSave then
 
  46                                         return { lsp_format = "fallback" }
 
  49                         format_on_save = function()
 
  50                                 if not vim.g.formatsave or vim.b.disableFormatSave then
 
  53                                         return { lsp_format = "fallback", timeout_ms = 500 }
 
  56                         -- Set the log level. Use `:ConformInfo` to see the location of the log file.
 
  57                         log_level = vim.log.levels.ERROR,
 
  58                         -- Conform will notify you when a formatter errors
 
  59                         notify_on_error = true,
 
  60                         -- Conform will notify you when no formatters are available for the buffer
 
  61                         notify_no_formatters = true,
 
  62                         -- Custom formatters and overrides for built-in formatters