diff options
-rw-r--r-- | lua/conform/init.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lua/conform/init.lua b/lua/conform/init.lua index f6ffe38..35ffb6e 100644 --- a/lua/conform/init.lua +++ b/lua/conform/init.lua @@ -721,10 +721,17 @@ M.formatexpr = function(opts) end local end_line = vim.fn.getline(end_lnum) local end_col = end_line:len() - opts.range = { - start = { start_lnum, 0 }, - ["end"] = { end_lnum, end_col }, - } + + if vim.v.count == vim.fn.line("$") then + -- Whole buffer is selected; use buffer formatting + opts.range = nil + else + opts.range = { + start = { start_lnum, 0 }, + ["end"] = { end_lnum, end_col }, + } + end + if M.format(opts) then return 0 elseif opts.lsp_fallback and not vim.tbl_isempty(lsp_format.get_format_clients(opts)) then |