-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conform import not working so I used the lazyvim recipe
- Loading branch information
1 parent
59edd8f
commit 18e7d8f
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
} |