Initial commit
This commit is contained in:
54
dot_config/nvim/lua/plugins/conform.lua
Normal file
54
dot_config/nvim/lua/plugins/conform.lua
Normal file
@ -0,0 +1,54 @@
|
||||
return {
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre" },
|
||||
cmd = { "ConformInfo" },
|
||||
keys = {
|
||||
{
|
||||
-- Customize or remove this keymap to your liking
|
||||
"<leader>F",
|
||||
function()
|
||||
require("conform").format({ async = true, lsp_fallback = true })
|
||||
end,
|
||||
mode = "",
|
||||
desc = "Format buffer",
|
||||
},
|
||||
},
|
||||
-- Everything in opts will be passed to setup()
|
||||
opts = {
|
||||
-- Define your formatters
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
python = { "ruff_organize_imports_only" },
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
sh = { "shfmt" },
|
||||
json = { "prettierd", "prettier", stop_after_first = true },
|
||||
jsonc = { "prettierd", "prettier", stop_after_first = true },
|
||||
css = { "prettierd", "prettier", stop_after_first = true },
|
||||
html = { "prettierd", "prettier", stop_after_first = true },
|
||||
-- go = { "goimports", "gofmt" },
|
||||
-- typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||
},
|
||||
-- Custom formatters
|
||||
formatters = {
|
||||
ruff_organize_imports_only = {
|
||||
command = "ruff",
|
||||
args = {
|
||||
"check",
|
||||
"--select",
|
||||
"I001",
|
||||
"--fix",
|
||||
"--stdin-filename",
|
||||
"$FILENAME",
|
||||
"-",
|
||||
},
|
||||
stdin = true,
|
||||
},
|
||||
},
|
||||
-- Set up format-on-save
|
||||
format_on_save = { timeout_ms = 500, lsp_fallback = true },
|
||||
},
|
||||
init = function()
|
||||
-- If you want the formatexpr, here is the place to set it
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
end,
|
||||
}
|
||||
Reference in New Issue
Block a user