Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

conform.nvim: store formatters settings in a project config

I like the conform.nvim plugin - it helps me automatically format different file types. But I had two common cases where I wanted a bit more flexibility: Sometimes I need to use different formatters per project. Sometimes I want to pass…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

.conform.json

I like the conform.nvim plugin - it helps me automatically format different file types.



But I had two common cases where I wanted a bit more flexibility:




  • Sometimes I need to use different formatters per project.

  • Sometimes I want to pass extra arguments to a formatter, especially if the project doesn’t already include a formatter-specific config file.



At first, I hardcoded all of this directly in my conform.lua setup.

But then I thought - what if I could store the configuration inside each project repository?



This is where .conform.json comes in.





Example .conform.json file





{
"formatters_by_ft": {
"python": ["isort", "yapf"],
"json": ["prettier"],
"yaml": ["prettier"]
},
"args": {
"yapf": ["--style", "{based_on_style: pep8, indent_width: 4}"],
"isort": ["--profile", "open_stack", "--line-length", "79"]
}
}





If the project contains .conform.json, conform.nvim will read it and use whatever formatters and arguments you define there.

If not, it will just fall back to the defaults.





  • formatters_by_ft — which formatter(s) to use per filetype.


  • args — optional arguments to pass to each formatter.



Tip: If you don’t want to commit .conform.json to your repository, you can add it to your global gitignore file:




echo ".conform.json" >> ~/.gitignore_global









Plugin config



Here’s the conform.nvim configuration that automatically reads .conform.json from the git root if it exists:




return {
"stevearc/conform.nvim",
config = function()
local conform = require("conform")

-- Constant path to the config file (relative to git root)
local config_filename = ".conform.json"

-- Default formatters if no config file present
local defaults = {
formatters = {
lua = { "stylua" },
python = { "isort", "yapf" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
},
args = {},
}

--- Load configuration from `.conform.json` in the git repository root
--- Example `.conform.json`:
-- {
-- "formatters_by_ft": {
-- "python": ["isort", "yapf"],
-- "json": ["prettier"],
-- "yaml": ["prettier"]
-- },
-- "args": {
-- "yapf": ["--style", "{based_on_style: pep8, indent_width: 4}"],
-- "isort": ["--profile", "open_stack", "--line-length", "79"]
-- }
-- }

local load_config = function(bufnr)
local path = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(bufnr), ":h")
local git_root = vim.fn.systemlist(
"git -C " .. vim.fn.fnameescape(path) .. " rev-parse --show-toplevel"
)[1]

if vim.v.shell_error ~= 0 or not git_root then
vim.notify("No git root found, using defaults", vim.log.levels.DEBUG)
return nil
end

local cfg_path = git_root .. "/" .. config_filename
if vim.fn.filereadable(cfg_path) == 0 then
vim.notify("No " .. config_filename .. " found, using defaults", vim.log.levels.DEBUG)
return nil
end

local ok_read, content = pcall(vim.fn.readfile, cfg_path)
if not ok_read or not content then
vim.notify("Failed to read " .. cfg_path, vim.log.levels.ERROR)
return nil
end

local ok_parse, parsed = pcall(vim.fn.json_decode, table.concat(content, "\n"))
if not ok_parse then
vim.notify("Invalid JSON in " .. cfg_path, vim.log.levels.ERROR)
return nil
end

return {
formatters = parsed.formatters_by_ft or {},
args = parsed.args or {},
}
end

local orig_format = conform.format

conform.format = function(opts)
local bufnr = opts.buf or vim.api.nvim_get_current_buf()
local cfg = load_config(bufnr) or defaults
vim.notify("Using conform config: " .. vim.inspect(cfg), vim.log.levels.DEBUG)

conform.formatters_by_ft = cfg.formatters

for name, arg_list in pairs(cfg.args) do
conform.formatters[name] = conform.formatters[name] or {}
conform.formatters[name].prepend_args = function()
return arg_list
end
end

orig_format(opts)
end

vim.keymap.set({ "n", "v" }, "<leader>cf", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 5000,
})
end, { desc = "Format current file with conform" })
end,
}









Why this is useful



This small setup makes conform.nvim much more flexible: each project can define its own formatter set and options, without touching your main neovim config.






Link to my config



You can check out my dotfiles here: https://github.com/art-vasilyev/.dotfiles

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten conform.nvim: store formatters settings in a project config

Thematisch verwandte Begriffe: conformnvim, store, formatters, settings · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94097 | A vulnerability was determined in Netcore NBR200V2 1.3.241127.071246. Th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick