aboutsummaryrefslogtreecommitdiffstats
path: root/lua/conform
diff options
context:
space:
mode:
authorWojciech Kulik <3128467+wojciech-kulik@users.noreply.github.com>2024-03-11 16:58:41 +0100
committerGitHub <noreply@github.com>2024-03-11 08:58:41 -0700
commitdb2c697fe8302f0328b50b480204be1b577a1e2f (patch)
treed76877ddb1c7dc621969289ea751c38ce01cf9dc /lua/conform
parentbc937565f251866c0ff344fd13fe27f00a4c0d25 (diff)
fix(swiftformat): range formatting support and add cwd (#326)
Diffstat (limited to 'lua/conform')
-rw-r--r--lua/conform/formatters/swiftformat.lua11
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" }),
}