You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
Lua
45 lines
1.2 KiB
Lua
return { -- Autoformat
|
|
'stevearc/conform.nvim',
|
|
event = { 'BufWritePre', 'BufReadPre', 'BufNewFile' },
|
|
cmd = { 'ConformInfo' },
|
|
keys = {
|
|
{
|
|
'<leader>f',
|
|
function()
|
|
require('conform').format({ async = true, lsp_format = 'fallback' })
|
|
end,
|
|
mode = '',
|
|
desc = '[F]ormat buffer',
|
|
},
|
|
},
|
|
opts = {
|
|
notify_on_error = false,
|
|
format_on_save = {
|
|
lsp_fallback = true,
|
|
async = false,
|
|
timeout_ms = 500,
|
|
},
|
|
formatters_by_ft = {
|
|
lua = { 'stylua' },
|
|
javascript = { 'prettier' },
|
|
typescript = { 'prettier' },
|
|
javascriptreact = { 'prettier' },
|
|
typescriptreact = { 'prettier' },
|
|
svelte = { 'prettier' },
|
|
css = { 'prettier' },
|
|
html = { 'prettier' },
|
|
json = { 'prettier' },
|
|
yaml = { 'prettier' },
|
|
markdown = { 'prettier' },
|
|
graphql = { 'prettier' },
|
|
liquid = { 'prettier' },
|
|
python = { 'isort', 'black' },
|
|
-- Conform can also run multiple formatters sequentially
|
|
-- python = { "isort", "black" },
|
|
--
|
|
-- You can use 'stop_after_first' to run the first available formatter from the list
|
|
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
|
},
|
|
},
|
|
}
|