-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin breaks with function in table #8
Comments
Thanks for the report 😄
I did not know that you could provide a function to conform in this manner.
Yea that is my take on this issue as well. Configuring a function like this with conform does not really make sense in the context of this plugin, at least not to me. I'd say this is very low on my priority list right now. |
I have stumbled upon this as well when selecting one of multiple formatters, followed by running more formatters. With the release of 7.0.0, conform.nvim switched to a new configuration format which deprecates the nested table configuration style for running one formatter out of a pool and subsequently another formatter: require("conform").setup({
formatters_by_ft = {
markdown = { { "prettier", "prettierd" }, "cbfmt" },
},
}) This produces a warning with the new version. ---@param bufnr integer
---@param ... string
---@return string
local function first(bufnr, ...)
local conform = require("conform")
for i = 1, select("#", ...) do
local formatter = select(i, ...)
if conform.get_formatter_info(formatter, bufnr).available then
return formatter
end
end
return select(1, ...)
end
require("conform").setup({
formatters_by_ft = {
markdown = function(bufnr)
return { first(bufnr, "prettierd", "prettier"), "cbfmt" }
end,
},
}) This seems to pose the same issue again. I agree that it's not a priority issue but with the documentation recommending this way of configuration I think more reports are going to appear which stumble upon the same error. |
Thanks for the heads up, we should definitely support this going forward then. |
One way to fix this is to make amends to both the plugins
|
@zapling, maybe we can allow passing functions in the |
The recipe from mason-conform to Run the first available formatter followed by more formatters posses a problem for this plugin. We need to get all possible formatters at run-time, in order for us to download them via mason. Adding a function to the return list (in this case We could support a function, but we probably do not have a Is that a solution that could work? |
Hey! I started using your plugin today and it works great, however I believe I've discovered a bug. I'm not sure if this is something you're actually able to fix on your side, but here's an example snipped from my configuration for conform which triggers the error:
It throws this error on startup:
If i replace the function in the table with just
{"prettier"}
the issue goes away. Also, if I call the function likeprettier()
instead of just putting the function object in the table, I believe the issue also goes away. Now that I'm using this plugin, I don't really need to worry about needing this specific function, but it may come up in the future for others so I figured I'd document it here at least. Thanks for your work, and let me know if you need any more infoThe text was updated successfully, but these errors were encountered: