mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 19:30:01 +02:00
nvim: conform: support range formatting
This commit is contained in:
parent
d82420ffeb
commit
e9de80a97e
2 changed files with 14 additions and 4 deletions
|
|
@ -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" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue