This commit is contained in:
guru245 2025-05-13 18:52:50 +09:00 committed by GitHub
commit 70b66b585e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 10 deletions

View File

@ -740,16 +740,6 @@ require('lazy').setup({
'stevearc/conform.nvim',
event = { 'BufWritePre' },
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 = function(bufnr)
@ -774,6 +764,22 @@ 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 },
},
vim.api.nvim_create_user_command('Format', function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_gt_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
['end'] = { args.line2, end_line:len() },
}
end
require('conform').format {
async = true,
lsp_format = 'fallback',
range = range,
}
end, { range = true }),
vim.keymap.set({ 'n', 'v' }, '<leader>f', '<Cmd>Format<CR>'),
},
},