From f66e77fbb36b66dc4c310c7910fe71b799edadc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Wed, 22 May 2024 00:16:18 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20add=20shfmt=20formatt?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lua/plugins/extras/formatting/shfmt.lua | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .config/nvim/lua/plugins/extras/formatting/shfmt.lua diff --git a/.config/nvim/lua/plugins/extras/formatting/shfmt.lua b/.config/nvim/lua/plugins/extras/formatting/shfmt.lua new file mode 100644 index 00000000..b1fb8d72 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/formatting/shfmt.lua @@ -0,0 +1,29 @@ +return { + { + "stevearc/conform.nvim", + opts = function(_, opts) + local function add_formatters(tbl) + for ft, formatters in pairs(tbl) do + if opts.formatters_by_ft[ft] == nil then + opts.formatters_by_ft[ft] = formatters + else + vim.list_extend(opts.formatters_by_ft[ft], formatters) + end + end + end + + add_formatters({ + ["sh"] = { "shfmt" }, + ["bash"] = { "shfmt" }, + ["zsh"] = { "shfmt" }, + }) + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "shfmt" }) + end, + }, +}