Skip to content

Commit

Permalink
fix(swiftformat): range formatting support and add cwd (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciech-kulik authored Mar 11, 2024
1 parent bc93756 commit db2c697
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lua/conform/formatters/swiftformat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,16 @@ return {
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" }),
}

0 comments on commit db2c697

Please sign in to comment.