From 7e10d80511d128eca2c23b9b694ad39af4f0aac3 Mon Sep 17 00:00:00 2001 From: Nicolas Rannou Date: Sat, 15 Jun 2024 16:17:13 +0200 Subject: [PATCH] formatter --- lua/custom/plugins/format.lua | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/lua/custom/plugins/format.lua b/lua/custom/plugins/format.lua index 738be58f..79155899 100644 --- a/lua/custom/plugins/format.lua +++ b/lua/custom/plugins/format.lua @@ -25,12 +25,37 @@ return { -- Autoformat end, formatters_by_ft = { lua = { "stylua" }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- -- You can use a sub-list to tell conform to run *until* a formatter -- is found. - -- javascript = { { "prettierd", "prettier" } }, + typescript = { { "dprint", "prettier" } }, + html = { "prettier" }, + css = { "prettier" }, + scss = { "prettier" }, + php = { "php-cs-fixer" }, + -- Conform can also run multiple formatters sequentially + python = { "isort", "black" }, + }, + -- LazyVim will merge the options you set here with builtin formatters. + -- You can also define any custom formatters here. + ---@type table + formatters = { + injected = { options = { ignore_errors = true } }, + -- # Example of using dprint only when a dprint.json file is present + dprint = { + condition = function(ctx) + return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] + end, + }, + prettier = { + condition = function(ctx) + return vim.fs.find({ ".prettierrc" }, { path = ctx.filename, upward = true })[1] + end, + }, + -- + -- Example of using shfmt with extra args + shfmt = { + extra_args = { "-i", "2", "-ci" }, + }, }, }, }