Files
dotfiles/.config/nvim/lua/plugins/formatting.lua
Stefan Imhoff a41290c297 feat(nix): nix and back again
I tried Nix, but it had too many downsides so I removed it.

1. Didn't like that all files are immutable and simple config changes
need a complete rebuild.
2. Setting up a new Mac didn't work as smoothly as promised. Not worth
the effort.
3. It sucked a lot to always have to type in the password twice on each
darwin-rebuild
4. It solves problems I never had.
2024-08-07 17:49:02 +02:00

57 lines
1.7 KiB
Lua

-- Lightweight yet powerful formatter plugin for Neovim
-- https://github.com/stevearc/conform.nvim
return {
"stevearc/conform.nvim",
event = { "BufWritePre", "BufNewFile" },
keys = {
{
"<leader>mp",
mode = { "n", "v" },
function()
require("conform").format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
end,
desc = "Format file or range (in visual mode)",
},
},
opts = {
formatters = {
eslint_d = {
command = "eslint_d",
args = { "--fix-to-stdout", "--stdin", "--stdin-filename", "$FILENAME" },
stdin = true,
},
nixpkgs_fmt = {
command = "nixpkgs-fmt",
},
},
formatters_by_ft = {
-- ["*"] = { "codespell" },
["_"] = { "trim_whitespace" },
astro = { { "prettierd", "prettier" } },
css = { { "prettierd", "prettier" }, "stylelint" },
fish = { "fish_indent" },
go = { "goimports", "gofumpt" },
graphql = { { "prettierd", "prettier" } },
html = { { "prettierd", "prettier" } },
javascript = { { "prettierd", "prettier" }, "eslint_d" },
javascriptreact = { { "prettierd", "prettier" }, "eslint_d" },
json = { { "prettierd", "prettier" } },
lua = { "stylua" },
markdown = { { "prettierd", "prettier" } },
mdx = { { "prettierd", "prettier" } },
nix = { "nixpkgs_fmt" },
python = { "isort", "black" },
ruby = { "rubyfmt", "rubocop" },
eruby = { "htmlbeautifier" },
svelte = { { "prettierd", "prettier" } },
typescript = { { "prettierd", "prettier" }, "eslint_d" },
typescriptreact = { { "prettierd", "prettier" }, "eslint_d" },
yaml = { { "prettierd", "prettier" } },
},
},
}