diff options
author | Wojciech Kulik <3128467+wojciech-kulik@users.noreply.github.com> | 2024-03-11 16:58:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-11 08:58:41 -0700 |
commit | db2c697fe8302f0328b50b480204be1b577a1e2f (patch) | |
tree | d76877ddb1c7dc621969289ea751c38ce01cf9dc | |
parent | bc937565f251866c0ff344fd13fe27f00a4c0d25 (diff) |
fix(swiftformat): range formatting support and add cwd (#326)
-rw-r--r-- | lua/conform/formatters/swiftformat.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lua/conform/formatters/swiftformat.lua b/lua/conform/formatters/swiftformat.lua index ed142ad..adde245 100644 --- a/lua/conform/formatters/swiftformat.lua +++ b/lua/conform/formatters/swiftformat.lua @@ -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" }), } |