Files
dotfiles/common/.config/nvim/lua/plugins/code-formatting.lua
Pratik Tripathy 12178dd96c NVIM
- VIM options updated for: autowrite, formatoptions, conceallevel,
  sidescrolloff, updatetime, wildmode
- LSP_config: options to display diagnostic icons, inlay hints
- Lint: codespell on "*" removed it wasn't working
- Formatting: ignore errors
- LuaSnip: Tab fix reversed, interfered with regular operations
- NVIM: Options for splitkeep & markdown_recommended_style
2024-03-11 17:29:52 +05:30

53 lines
2.0 KiB
Lua

return {
{
"stevearc/conform.nvim",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { { "prettierd", "prettier" } },
typescript = { { "prettierd", "prettier" } },
javascriptreact = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
svelte = { { "prettierd", "prettier" } },
css = { { "prettierd", "prettier" } },
html = { { "prettierd", "prettier" } },
json = { { "prettierd", "prettier" } },
yaml = { { "prettierd", "prettier" } },
markdown = { { "prettierd", "prettier" } },
graphql = { { "prettierd", "prettier" } },
lua = { "stylua" },
python = { "black" },
sh = { { "shfmt", "shellharden" } },
bash = { { "shfmt", "shellharden" } },
zsh = { { "shfmt", "shellharden" } },
["_"] = { "trim_whitespace" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 3000,
quiet = false,
},
formatters = {
injected = { options = { ignore_errors = true } },
shfmt = {
prepend_args = { "-i", "4" },
},
},
})
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 1000,
})
end, { desc = "Code Format (visual selection)" })
end,
},
}