summaryrefslogtreecommitdiffstats
path: root/lua/conform/formatters/swiftformat.lua
blob: adde245ef6c6c7f97676794bbdc0eb633849232a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---@type conform.FileFormatterConfig
return {
  meta = {
    url = "https://github.com/nicklockwood/SwiftFormat",
    description = "SwiftFormat is a code library and command-line tool for reformatting `swift` code on macOS or Linux.",
  },
  command = "swiftformat",
  stdin = true,
  args = { "--stdinpath", "$FILENAME" },
  range_args = function(self, ctx)
    local startOffset = tonumber(ctx.range.start[1]) - 1
    local endOffset = tonumber(ctx.range["end"][1]) - 1

    return {
      "--linerange",
      startOffset .. "," .. endOffset,
    }
  end,
  cwd = require("conform.util").root_file({ ".swiftformat", "Package.swift", "buildServer.json" }),
}