This commit is contained in:
Your Name 2026-03-06 22:42:22 +08:00
parent 77c38f1eb1
commit d130d5241b
1 changed files with 27 additions and 3 deletions

View File

@ -773,7 +773,7 @@ require('lazy').setup({
cmd = { 'ConformInfo' },
keys = {
{
'<leader>f',
'<leader>ff',
function() require('conform').format { async = true, lsp_format = 'fallback' } end,
mode = '',
desc = '[F]ormat buffer',
@ -783,15 +783,16 @@ require('lazy').setup({
---@type conform.setupOpts
opts = {
notify_on_error = false,
format_on_save = function(bufnr)
format_after_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 }
local disable_filetypes = {}
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
return {
async = true,
timeout_ms = 500,
lsp_format = 'fallback',
}
@ -804,6 +805,29 @@ require('lazy').setup({
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
javascript = { 'prettierd' },
typescript = { 'prettierd' },
javascriptreact = { 'prettierd' },
typescriptreact = { 'prettierd' },
scss = { 'prettierd' },
pandoc = { 'prettierd' },
markdown = { 'prettierd' },
json = { 'prettierd' },
css = { 'prettierd' },
yml = { 'prettierd' },
html = { 'prettierd' },
php = { 'pretty-php' },
cpp = { 'clang_format' },
sh = { 'shfmt' },
go = { 'gofumpt' },
python = {
-- To fix auto-fixable lint errors
'ruff_fix',
-- To run the Ruff formatter
'ruff_format',
-- To organize the imports
'ruff_organize_imports',
},
},
},
},