Skip to content

Commit

Permalink
support range
Browse files Browse the repository at this point in the history
  • Loading branch information
heygarrett committed Dec 11, 2024
1 parent 15ca129 commit 51ba214
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/conform/formatters/equalprg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ return {
},
format = function(self, ctx, lines, callback)
local cursor_position = vim.api.nvim_win_get_cursor(0)
vim.cmd.normal("gg")
vim.cmd.normal("=G")
if ctx.range then
vim.cmd.normal(ctx.range["start"][1] .. "G")
vim.cmd.normal("=" .. ctx.range["end"][1] .. "G")
else
vim.cmd.normal("gg")
vim.cmd.normal("=G")
end
vim.api.nvim_win_set_cursor(0, cursor_position)
callback(nil, nil)
end,
Expand Down

0 comments on commit 51ba214

Please sign in to comment.