52 lines
1.7 KiB
Lua
52 lines
1.7 KiB
Lua
return {
|
|
'stevearc/conform.nvim',
|
|
event = { 'BufReadPre', 'BufNewFile' },
|
|
cmd = { 'ConformInfo' },
|
|
keys = {
|
|
{
|
|
'<leader>cf',
|
|
function()
|
|
require('conform').format { async = true, lsp_format = 'fallback' }
|
|
end,
|
|
mode = '',
|
|
desc = '[C]ode [F]ormat',
|
|
},
|
|
},
|
|
config = function()
|
|
local conform = require 'conform'
|
|
|
|
conform.setup {
|
|
formatters_by_ft = {
|
|
javascript = { 'prettierd', 'prettier', stop_after_first = true },
|
|
typescript = { 'prettierd', 'prettier', stop_after_first = true },
|
|
css = { 'prettierd', 'prettier', stop_after_first = true },
|
|
scss = { 'prettierd', 'prettier', stop_after_first = true },
|
|
json = { 'prettierd', 'prettier', stop_after_first = true },
|
|
yaml = { 'yamlfmt', 'prettierd', 'prettier', stop_after_first = true },
|
|
markdown = { 'cbfmt', 'prettierd', 'prettier', stop_after_first = true },
|
|
graphql = { 'prettierd', 'prettier', stop_after_first = true },
|
|
html = { 'prettierd', 'prettier', stop_after_first = true },
|
|
htmlangular = { 'prettierd', 'prettier', stop_after_first = true },
|
|
lua = { 'stylua' },
|
|
rust = { 'rustfmt', lsp_format = 'fallback' },
|
|
python = { 'ruff_format' },
|
|
},
|
|
format_on_save = {
|
|
lsp_format = 'fallback',
|
|
async = false,
|
|
timeout_ms = 1000,
|
|
},
|
|
default_format_opts = {
|
|
lsp_format = 'fallback',
|
|
},
|
|
}
|
|
|
|
vim.keymap.set({ 'n', 'v' }, '<leader>mp', function()
|
|
conform.format {
|
|
lsp_format = 'fallback',
|
|
async = false,
|
|
timeout_ms = 1000,
|
|
}
|
|
end, { desc = '[M]ake [P]retty' })
|
|
end,
|
|
}
|