[question] update formaters_by_ft at "runtime"?
Hi,
I'm working on a project that uses a different tooling stack than I do (prettier instead of biome etc etc..)
And I'm relying on exrc (.nvim.lua) for project specific settings but I can't find how to configure conform from there, the following doesn't properly update:
./.nvim.lua
local conform = require("conform")
-- NOTE: I INITIALLY TRIED THAT TOO:
-- conform.setup({
-- formatters_by_ft = {
-- javascript = { "prettier" },
-- typescript = { "prettier" },
-- json = { "prettier" },
-- jsonc = { "prettier" },
-- jsx = { "prettier" },
-- tsx = { "prettier" },
-- css = { "prettier" },
-- markdown = { "prettier" },
-- },
-- })
conform.formatters_by_ft.tsx = { "prettier" }
conform.formatters_by_ft.typescript = { "prettier" }
conform.formatters_by_ft.javascript = { "prettier" }
conform.formatters_by_ft.json = { "prettier" }
I'm sure it's obvious and have been talked about before but I couldn't find it, hopefully I used keywords that will help others in my situation
That should definitely work. When you get to the situation where you're in a project and it's using the wrong formatters, can you do :=require("conform").formatters_by_ft and confirm that the value of that table has actually been updated?
My bad I was on other projects, I'm back on the culprit project so I'll provide a proper log / debug / reproduction tonight
@melMass I use .lazy.lua and also encountered the same problem. Finally I found the following way works:
-- /path/to/your/project/.lazy.lua
return {
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
go = { "goimports" },
},
},
}