add: formatting
This commit is contained in:
parent
dd24f4f55b
commit
fdb4ff4f5c
1 changed files with 43 additions and 0 deletions
43
lua/plugins/formatting.lua
Normal file
43
lua/plugins/formatting.lua
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
return {
|
||||||
|
"stevearc/conform.nvim",
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
config = function()
|
||||||
|
local conform = require("conform")
|
||||||
|
|
||||||
|
conform.setup({
|
||||||
|
formatters_by_ft = {
|
||||||
|
javascript = { "prettier" },
|
||||||
|
typescript = { "prettier" },
|
||||||
|
javascriptreact = { "prettier" },
|
||||||
|
typescriptreact = { "prettier" },
|
||||||
|
svelte = { "prettier" },
|
||||||
|
css = { "prettier" },
|
||||||
|
-- html = { 'prettier' },
|
||||||
|
fish = { "fish_indent" },
|
||||||
|
php = { "pretty-php" },
|
||||||
|
json = { "yq" },
|
||||||
|
yaml = { "yq" },
|
||||||
|
markdown = { "prettier" },
|
||||||
|
graphql = { "prettier" },
|
||||||
|
liquid = { "prettier" },
|
||||||
|
sh = { "shfmt" },
|
||||||
|
zsh = { "shfmt" },
|
||||||
|
batch = { "shfmt", "prettier" },
|
||||||
|
lua = { "stylua" },
|
||||||
|
},
|
||||||
|
format_on_save = {
|
||||||
|
lsp_fallback = false,
|
||||||
|
async = false,
|
||||||
|
timeout_ms = 1000,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
|
||||||
|
conform.format({
|
||||||
|
lsp_fallback = true,
|
||||||
|
async = false,
|
||||||
|
timeout_ms = 1000,
|
||||||
|
})
|
||||||
|
end, { desc = "Format file or range (in visual mode)" })
|
||||||
|
end,
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue