aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform/formatters/trim_whitespace.lua
blob: 4d6d6649c06fe88010291d96c6f9ba4b030e65e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---@type conform.FileLuaFormatterConfig
return {
  meta = {
    url = "https://github.com/stevearc/conform.nvim/blob/master/lua/conform/formatters/trim_whitespace.lua",
    description = "Trim trailing whitespace.",
  },
  format = function(self, ctx, lines, callback)
    local out_lines = {}
    for _, line in ipairs(lines) do
      local trimmed = line:gsub("%s+$", "")
      table.insert(out_lines, trimmed)
    end
    callback(nil, out_lines)
  end,
}