From 4ff36062dd33b852f9734d3731c55a5a8c50cf75 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 7 Nov 2024 07:11:36 -0800 Subject: [PATCH] fix(prettier): keep existing formatters_by_ft (#4719) ## Description This change makes it possible to configure other formatters for filetypes supported by the prettier extra, for instance ```js return { { "stevearc/conform.nvim", opts = { formatters_by_ft = { css = { "stylelint" }, }, }, }, } ``` Currently the prettier extra overwrites any existing `formatters_by_ft` for the filetypes it supports. I've changed it to use `table.insert` [like the sql extra does](https://github.com/LazyVim/LazyVim/blob/75750be1c0493659c9fbc60ff5e06dba053ef528/lua/lazyvim/plugins/extras/lang/sql.lua#L148-L149). ## Related Issue(s) None that I know of ## Screenshots N/A ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- lua/lazyvim/plugins/extras/formatting/prettier.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 13704ca9..855dc258 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -70,7 +70,8 @@ return { opts = function(_, opts) opts.formatters_by_ft = opts.formatters_by_ft or {} for _, ft in ipairs(supported) do - opts.formatters_by_ft[ft] = { "prettier" } + opts.formatters_by_ft[ft] = opts.formatters_by_ft[ft] or {} + table.insert(opts.formatters_by_ft[ft], "prettier") end opts.formatters = opts.formatters or {}