Skip to content

Commit

Permalink
conform import not working so I used the lazyvim recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredosdpiii committed Oct 1, 2023
1 parent 59edd8f commit 18e7d8f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lua/plugins/conform.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
return {
{
"stevearc/conform.nvim",
dependencies = { "mason.nvim" },
lazy = true,
cmd = "ConformInfo",
init = function()
-- Install the conform formatter on VeryLazy
require("lazyvim.util").on_very_lazy(function()
require("lazyvim.plugins.lsp.format").custom_format = function(buf)
return require("conform").format({ bufnr = buf })
end
end)
end,
opts = {
formatters_by_ft = {
lua = { "stylua" },
fish = { "fish_indent" },
sh = { "shfmt" },
js = { "eslint_d" },
ts = { "eslint_d" },
},
-- LazyVim will merge the options you set here with builtin formatters.
-- You can also define any custom formatters here.
---@type table<string,table>
formatters = {
-- -- 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,
-- },
},
},
config = function(_, opts)
opts.formatters = opts.formatters or {}
for f, o in pairs(opts.formatters) do
local ok, formatter = pcall(require, "conform.formatters." .. f)
opts.formatters[f] = vim.tbl_deep_extend("force", {}, ok and formatter or {}, o)
end
require("conform").setup(opts)
end,
},
}

0 comments on commit 18e7d8f

Please sign in to comment.