1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 11:24:55 +02:00

nvim: conform: support range formatting

This commit is contained in:
Henrik Hautakoski 2024-11-03 13:41:53 +01:00
parent d82420ffeb
commit e9de80a97e
2 changed files with 14 additions and 4 deletions

View file

@ -10,13 +10,13 @@ if user.formatter == nil then
user.formatter = [[mfgggqG`f=zz]]
end
vim.api.nvim_create_user_command('Format', function()
vim.api.nvim_create_user_command('Format', function(args)
if type(user.formatter) == "string" then
local cmd = vim.api.nvim_replace_termcodes(user.formatter, true, false, true)
vim.api.nvim_feedkeys(cmd, 'n', false)
elseif type(user.formatter) == "function" then
user.formatter()
user.formatter(args)
else
vim.api.nvim_err_writeln("No formatter found")
end
end, {})
end, { range = true })