summaryrefslogtreecommitdiffstats
path: root/lua/conform/formatters/injected.lua
diff options
context:
space:
mode:
authorSteven Arcangeli <506791+stevearc@users.noreply.github.com>2023-10-15 16:18:08 -0700
committerGitHub <noreply@github.com>2023-10-15 16:18:08 -0700
commit7027ebbd772e2d3593f7dd566dea06d2d20622ee (patch)
treeb78bbe24dda9cd7e1272bce6c699b5e576d76a66 /lua/conform/formatters/injected.lua
parent9b5fbddfca5080c6961dabafb3f0a6ef7e2fc18a (diff)
feat!: merge configs in conform.formatters with defaults (#140)
This breaking change should make it significantly easier to modify formatters. While I expect 99% of configs to be backwards-compatible, this can still potentially cause problems. If you: * define a formatter in the `formatters` option * that has the same name as a built-in formatter * and omits a property from the original formatter (e.g. leaves out `range_args` or `cwd`) Then you may encounter breaking behavior from this commit, because now your config definition will be merged with the built-in definition, and so will inherit those omitted properties. This config merging behavior can be opted-out of by adding `inherit = false` to your formatter config.
Diffstat (limited to 'lua/conform/formatters/injected.lua')
-rw-r--r--lua/conform/formatters/injected.lua11
1 files changed, 4 insertions, 7 deletions
diff --git a/lua/conform/formatters/injected.lua b/lua/conform/formatters/injected.lua
index 71005bc..21a9830 100644
--- a/lua/conform/formatters/injected.lua
+++ b/lua/conform/formatters/injected.lua
@@ -60,15 +60,10 @@ local function apply_indent(lines, indentation)
end
end
----@class conform.InjectedFormatterConfig : conform.FileLuaFormatterConfig
----@field format fun(self: conform.InjectedFormatterConfig, ctx: conform.Context, lines: string[], callback: fun(err: nil|string, new_lines: nil|string[]))
----@field condition? fun(self: conform.InjectedFormatterConfig, ctx: conform.Context): boolean
----@field options conform.InjectedFormatterOptions
-
---@class (exact) conform.InjectedFormatterOptions
---@field ignore_errors boolean
----@type conform.InjectedFormatterConfig
+---@type conform.FileLuaFormatterConfig
return {
meta = {
url = "doc/advanced_topics.md#injected-language-formatting-code-blocks",
@@ -94,6 +89,8 @@ return {
callback("No treesitter parser for buffer")
return
end
+ ---@type conform.InjectedFormatterOptions
+ local options = self.options
--- Disable diagnostic to pass the typecheck github action
--- This is available on nightly, but not on stable
--- Stable doesn't have any parameters, so it's safe to always pass `true`
@@ -134,7 +131,7 @@ return {
i = i + 1
end
end
- if self.options.ignore_errors then
+ if options.ignore_errors then
format_error = nil
end
end