diff options
author | Steven Arcangeli <506791+stevearc@users.noreply.github.com> | 2023-12-06 22:20:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 22:20:29 -0800 |
commit | 659838ff4244ef6af095395ce68aaaf99fa8e696 (patch) | |
tree | b92754f2de1a225187769ed2c30e01a3ea703b3c /lua/conform/formatters | |
parent | 8d0421a11b2944c6c059e0936a95182972921c30 (diff) |
refactor!: formatter config functions take self as first argument (#233)
This is a breaking API change, but there is a shim in place that will keep existing functions working, just with a warning notification. Most people should not encounter this at all. For anyone overriding a formatter config value with a function that takes `(ctx)` as the parameter, it will need to be updated to take `(self, ctx)`.
Diffstat (limited to 'lua/conform/formatters')
-rw-r--r-- | lua/conform/formatters/autopep8.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/clang_format.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/darker.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/deno_fmt.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/markdown-toc.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/phpcbf.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/prettier.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/prettierd.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/stylua.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/uncrustify.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/yapf.lua | 2 | ||||
-rw-r--r-- | lua/conform/formatters/zprint.lua | 2 |
12 files changed, 12 insertions, 12 deletions
diff --git a/lua/conform/formatters/autopep8.lua b/lua/conform/formatters/autopep8.lua index 3945e47..3d5b015 100644 --- a/lua/conform/formatters/autopep8.lua +++ b/lua/conform/formatters/autopep8.lua @@ -6,7 +6,7 @@ return { }, command = "autopep8", args = { "-" }, - range_args = function(ctx) + range_args = function(self, ctx) return { "-", "--line-range", tostring(ctx.range.start[1]), tostring(ctx.range["end"][1]) } end, } diff --git a/lua/conform/formatters/clang_format.lua b/lua/conform/formatters/clang_format.lua index 44af877..2e68fc1 100644 --- a/lua/conform/formatters/clang_format.lua +++ b/lua/conform/formatters/clang_format.lua @@ -7,7 +7,7 @@ return { }, command = "clang-format", args = { "-assume-filename", "$FILENAME" }, - range_args = function(ctx) + range_args = function(self, ctx) local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range) local length = end_offset - start_offset return { diff --git a/lua/conform/formatters/darker.lua b/lua/conform/formatters/darker.lua index 5f47e6b..9fe9b20 100644 --- a/lua/conform/formatters/darker.lua +++ b/lua/conform/formatters/darker.lua @@ -6,7 +6,7 @@ return { description = "Run black only on changed lines.", }, command = "darker", - args = function(ctx) + args = function(self, ctx) -- make sure pre-save doesn't lose changes while post-save respects -- the revision setting potentially set in pyproject.toml if vim.bo[ctx.buf].modified then diff --git a/lua/conform/formatters/deno_fmt.lua b/lua/conform/formatters/deno_fmt.lua index 7b48320..5e7f452 100644 --- a/lua/conform/formatters/deno_fmt.lua +++ b/lua/conform/formatters/deno_fmt.lua @@ -14,7 +14,7 @@ return { description = "Use [Deno](https://deno.land/) to format TypeScript, JavaScript/JSON and markdown.", }, command = "deno", - args = function(ctx) + args = function(self, ctx) return { "fmt", "-", diff --git a/lua/conform/formatters/markdown-toc.lua b/lua/conform/formatters/markdown-toc.lua index 129d50e..a7a9694 100644 --- a/lua/conform/formatters/markdown-toc.lua +++ b/lua/conform/formatters/markdown-toc.lua @@ -6,7 +6,7 @@ return { }, command = "markdown-toc", stdin = false, - args = function(ctx) + args = function(self, ctx) -- use the indentation set in the current buffer, effectively allowing us to -- use values from .editorconfig local indent = vim.bo[ctx.buf].expandtab and (" "):rep(vim.bo[ctx.buf].tabstop) or "\t" diff --git a/lua/conform/formatters/phpcbf.lua b/lua/conform/formatters/phpcbf.lua index 38f3155..6c6027e 100644 --- a/lua/conform/formatters/phpcbf.lua +++ b/lua/conform/formatters/phpcbf.lua @@ -9,7 +9,7 @@ return { command = util.find_executable({ "vendor/bin/phpcbf", }, "phpcbf"), - args = function(ctx) + args = function(self, ctx) return { "-q", "--stdin-path=" .. ctx.filename, "-" } end, stdin = true, diff --git a/lua/conform/formatters/prettier.lua b/lua/conform/formatters/prettier.lua index ea45ffb..52dda86 100644 --- a/lua/conform/formatters/prettier.lua +++ b/lua/conform/formatters/prettier.lua @@ -7,7 +7,7 @@ return { }, command = util.from_node_modules("prettier"), args = { "--stdin-filepath", "$FILENAME" }, - range_args = function(ctx) + range_args = function(self, ctx) local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range) return { "$FILENAME", "--range-start=" .. start_offset, "--range-end=" .. end_offset } end, diff --git a/lua/conform/formatters/prettierd.lua b/lua/conform/formatters/prettierd.lua index 3cdc19e..386d441 100644 --- a/lua/conform/formatters/prettierd.lua +++ b/lua/conform/formatters/prettierd.lua @@ -7,7 +7,7 @@ return { }, command = util.from_node_modules("prettierd"), args = { "$FILENAME" }, - range_args = function(ctx) + range_args = function(self, ctx) local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range) return { "$FILENAME", "--range-start=" .. start_offset, "--range-end=" .. end_offset } end, diff --git a/lua/conform/formatters/stylua.lua b/lua/conform/formatters/stylua.lua index d971932..25012bf 100644 --- a/lua/conform/formatters/stylua.lua +++ b/lua/conform/formatters/stylua.lua @@ -7,7 +7,7 @@ return { }, command = "stylua", args = { "--search-parent-directories", "--stdin-filepath", "$FILENAME", "-" }, - range_args = function(ctx) + range_args = function(self, ctx) local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range) return { "--search-parent-directories", diff --git a/lua/conform/formatters/uncrustify.lua b/lua/conform/formatters/uncrustify.lua index 2782e96..aec93c2 100644 --- a/lua/conform/formatters/uncrustify.lua +++ b/lua/conform/formatters/uncrustify.lua @@ -5,7 +5,7 @@ return { description = "A source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and Vala.", }, command = "uncrustify", - args = function(ctx) + args = function(self, ctx) return { "-q", "-l", vim.bo[ctx.buf].filetype:upper() } end, } diff --git a/lua/conform/formatters/yapf.lua b/lua/conform/formatters/yapf.lua index fc3cfeb..63bff83 100644 --- a/lua/conform/formatters/yapf.lua +++ b/lua/conform/formatters/yapf.lua @@ -6,7 +6,7 @@ return { }, command = "yapf", args = { "--quiet" }, - range_args = function(ctx) + range_args = function(self, ctx) return { "--quiet", "--lines", string.format("%d-%d", ctx.range.start[1], ctx.range["end"][1]) } end, } diff --git a/lua/conform/formatters/zprint.lua b/lua/conform/formatters/zprint.lua index 935a485..240b7ed 100644 --- a/lua/conform/formatters/zprint.lua +++ b/lua/conform/formatters/zprint.lua @@ -5,7 +5,7 @@ return { description = "Formatter for Clojure and EDN.", }, command = "zprint", - range_args = function(ctx) + range_args = function(self, ctx) return { string.format( "{:input {:range {:start %d :end %d :use-previous-!zprint? true :continue-after-!zprint-error? true}}}", |