1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-06-16 03:14: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

@ -105,7 +105,17 @@ return {
},
init = function()
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
user.formatter = ":lua require'conform'.format({ async = true })<CR>:<DEL>"
user.formatter = function (args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_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, range = range })
end
end
},
{ import = "user.plugins.editor.fuzzyfinder" },