mirror of
https://github.com/pratiktri/dotfiles.git
synced 2026-02-04 08:41:43 +05:30
NVIM
- Plugin file names changed - Plugins reorged into files more logically
This commit is contained in:
50
common/.config/nvim/lua/plugins/code-formatting.lua
Normal file
50
common/.config/nvim/lua/plugins/code-formatting.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
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 = 1000,
|
||||
},
|
||||
formatters = {
|
||||
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 = "[C]ode [F]ormat (visual selection)" })
|
||||
end,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user