2024-07-21 23:30:17 +02:00
|
|
|
return { -- Autoformat
|
|
|
|
'stevearc/conform.nvim',
|
|
|
|
lazy = false,
|
|
|
|
keys = {
|
|
|
|
{
|
|
|
|
'<leader>f',
|
|
|
|
function()
|
|
|
|
require('conform').format { async = true, lsp_fallback = true }
|
|
|
|
end,
|
|
|
|
mode = '',
|
|
|
|
desc = '[F]ormat buffer',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
opts = {
|
|
|
|
notify_on_error = false,
|
2024-08-21 21:20:21 +02:00
|
|
|
format_on_save = false,
|
|
|
|
-- format_on_save = function(bufnr)
|
|
|
|
-- -- Disable "format_on_save lsp_fallback" for languages that don't
|
|
|
|
-- -- have a well standardized coding style. You can add additional
|
|
|
|
-- -- languages here or re-enable it for the disabled ones.
|
|
|
|
-- local disable_filetypes = { c = true, cpp = true }
|
|
|
|
-- return {
|
|
|
|
-- timeout_ms = 500,
|
|
|
|
-- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
|
|
|
|
-- }
|
|
|
|
-- end,
|
2024-07-21 23:30:17 +02:00
|
|
|
formatters_by_ft = {
|
|
|
|
lua = { 'stylua' },
|
|
|
|
-- Conform can also run multiple formatters sequentially
|
2024-08-21 21:20:41 +02:00
|
|
|
python = { 'isort', 'black' },
|
2024-07-21 23:30:17 +02:00
|
|
|
--
|
|
|
|
-- You can use a sub-list to tell conform to run *until* a formatter
|
|
|
|
-- is found.
|
2024-08-21 21:20:41 +02:00
|
|
|
javascript = { { 'prettierd', 'prettier' } },
|
|
|
|
java = { 'clang-format' },
|
2024-07-21 23:30:17 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|